5 ms·
Obviously the solution as proposed only allows for non-variadic functions to be curried (where 'non-variadic' means that the function needs to be called with a
by antimagic 11y ago
Obviously the solution as proposed only allows for non-variadic functions to be curried (where 'non-variadic' means that the function needs to be called with a fixed number of arguments to work correctly, not that it can't be called with the wrong number of arguments, because clearly Javascript doesn't care).
Does currying even make sense for variadic functions? I can't imagine what that would look like as an implementation.
- ufo 11y agoIts possible to curry a variadic function if there is a way to know when you reached the last argument. For example, in a printf-like function you know the number of inputs once you parse the format string. This example here is a function that sums a variadic list of non-zero numbers. The zero signals the end of the list. http://pastebin.com/xQRbRcJe http://pastebin.com/xQRbRcJe Its certainly very weird though. I wouldn't recommend doing this in real programs.