Functional Programming Principle in Scala