Scala: higher order functions
Scala: tail recursive version of sum HOF