compounding in Scala