So I according to what I've read I've gotten this form of currying down:
def arithmetic_iter(op: (Int, Int) => Int, f: Int => Int, base: Int)(a: Int, b: Int): Int = {
def iter(a: Int, base: Int): Int =
if (a > b) base
else iter(a + 1, op(base, f(a)))
iter(a, base)
}
However, I wanted to do something like this:
def route(m:Message) = {
(e: Endpoint) => e.send(m)
}
With the function above. So I came up with this number:
def arithmetic_iter_lambda(op: (Int, Int) => Int, f: Int => Int, base: Int)(a: Int, b: Int): Int = {
(a: Int, b: Int) =>
Int = {
def iter(a: Int, base: Int): Int =
if (a > b) base
else iter(a + 1, op(base, f(a)))
iter(a, base)
}
}
Unfortunately, I get an error that says: reassignment to val.
So I'm stuck on how to fix arithmetic_iter_lambda.