Cleaner way for coding a repetitive application of a function
What's wrong with straight recursion?

def ntimes[A](n:Int, f:A=&gt;A, a:A):A = if (n==0) a else ntimes(n-1, f, f(a))


Another clean option is

Iterator.iterate(a)(f).drop(n).next