Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function fixCurry(fn, totalArgs){
totalArgs = totalArgs ||fn.length
return function recursor(){
return arguments.length<fn.length?recursor.bind(this, ...arguments): fn.call(this, ...arguments);
}
}
var add = fixCurry((a,b,c)=>a+b+c);
console.log('Add')
console.log(add(1,2, 3))
console.log(add(1)(2,3))
console.log(add(1)(3)(2))
console.log(add(1,2)(3))
var mul = fixCurry((a,b,c)=>a*b*c);
console.log('Multiple')
console.log(mul(1,2,3))
console.log(mul(1)(2,3))
console.log(mul(1)(3)(2))
console.log(mul(1,2)(3))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.