raganwald / allong.es

https://leanpub.com/javascriptallongesix
484 stars 28 forks source link

uncurry #4

Open raganwald opened 11 years ago

reinh commented 11 years ago

Would this just be:

uncurry = (fn) -> return -> fn.apply @, arguments...
raganwald commented 11 years ago

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.