Exercise 2: Functional Programming using scala