Functional programming principles in Scala