function programming in scala 2