I don't like curry. Help me reverse the effects of this evil question - Make me some curry - by uncurrying functions.
- Given a blackbox curried function, output its uncurried equivalent.
- The curried function will take a single argument and output either another curried function or a value of another type.
- The uncurried function you create will take the same number of arguments as the curried function, but all at once.
- In languages without first-class functions, you can use an object with a method in place of a curried function - but please specify this.
- The curried function may also output a function pointer instead.
- If your language does not allow function pointers or makes passing around functions hard to work with, but allows evaluating strings to make functions (e.g. APL), you can use strings to represent both curried functions and your uncurried output function.
- You can also take the number of arguments of the functions as an input to help you determine the depth of currying.
- You may choose to return a function that takes a tuple, list, or other single value containing all the arguments.
- You may constrain the arguments and return type to a data type of your choosing, but that type should have more than 1 possible value.
fis the inputted curried function and
gis your uncurried function,
f(a1)(a2)...(aN)must always equal
g(a1, a2, ..., aN).
- The order of arguments in the uncurried function should be the same as in the original curried function.
For example, given the function
a -> b -> c -> a + b + c, you can return a function that looks like
(a, b, c) -> a + b + c or
arr -> arr + arr + arr -> ... but not
(c, b, a) -> ... (wrong order). If you also take the number of arguments of the function as input, then
(a, b) -> c -> ... would be an acceptable output given the input 2 (2 arguments are curried).
Since Rust is the language of the month, I will be offering a 50 rep bounty on Rust answer to this question if you haven't used Rust before.