A coworker of mine sent me a question as follows:
Implement a HOF(higher order function) that performs currying, the signature of your function is as follows:
def curry[A,B,C](f:(A,B) => C) : A => B => C
Similarly, implement a function that performs uncurrying as follows:
def uncurry[A,B,C](f:A => B => C): (A,B) => C
The way I understand currying is that if you have a function that takes multiple parameters, you can repeatedly apply the function to each one of the paramaters until you get the result.
So something along the lines of f:(A,B) => C
turns into A => f(A,_) => f(B)
????
And uncurrying would be to consolidate this application into one function as follows:
f:A=>B=>C
would be f(A,B)
?
Maybe I am just being confused by the syntax here but it would be great if somebody could point out what I am missing here.
Thanks