Yes, although there is one subtlety here: should `flip` return a curried function, or an uncurried function? This isn't an issue in Haskell since it only has unary functions.
Udon.flip = function(f) {
return function(x) {
if(arguments.length > 1) {
return f(arguments[1])(x);
}
return function(y) {
return f(y)(x);
};
};
}; (a, b) -> c
representation. If the uniform/canonical way to use functions is defined to be curried, then flip can simply return them curried.Which it does:
curry :: ((a, b) -> c) -> a -> b -> c
uncurry :: (a -> b -> c) -> (a, b) -> c