allong.es icon indicating copy to clipboard operation
allong.es copied to clipboard

uncurry

Open raganwald opened this issue 11 years ago • 2 comments

raganwald avatar Mar 07 '13 17:03 raganwald

Would this just be:

uncurry = (fn) -> return -> fn.apply @, arguments...

reinh avatar Apr 10 '13 05:04 reinh

Something like that. If we have a very simple curry that works with functions taking two arguments:

curry = (fn) -> (x) -> (y) -> fn(x, y)

uncurry reverses the operation:

uncurry = (fn) -> (x, y) -> fn(x)(y)

Most of the currying in allong.es is self-uncurrying in that you can call things like map or getWith using either map(list)(fn) or map(list, fn). But I could add a variadic uncurry that can handle any number of arguments.

raganwald avatar Apr 10 '13 13:04 raganwald