I am on my way to learning Scala after coming from different programming languages (mostly interpreted). I am doing the following exercise and I get an error.
def sum(f: Int => Int)(a: Int, b: Int): Int = {
def loop(a: Int, acc: Int): Int = {
if (a >= b) acc
else loop(a+1, f(a) + acc)
}
loop(a, 0)
}
sum(x => x * x, 2, 4) //Too many arguments
I can't see what is wrong there?