Open hoegrammer opened 8 years ago
Extending arity is really designed for an initial 2 defined arguments in your base function, i.e.
fjs.curry((x, y) => { return x + y; });
Imagine it's passing the result back in as the first arg, then the next as the second - like a fold.
I should probably document and implement this better.
This doesn't really match the mathematical definition of currying. The functionality you've added to is is a combination of unapply
and reduce
from Ramda. Using that library and the addition function you used above, it would look more like this:
R.unapply(R.reduce((x, y) => (x + y), 0))
I like this and I'm thinking of using it in my next project but I'm struggling to understand why currying increases arity and whether this is a good idea. Is it taken from another functional language? The only one I am familiar with is Haskell which does not do that.
When I try currying a function with 3 inputs and then increasing the arity, I get strange results: