Functional Programming Principles in Scala  (Homework)