Func programming in Scala