Functional programming exercises in Scala