We're a place where coders share, stay up-to-date and grow their careers.
This really doesn't seem like currying. It seems counter-productive to even call it that because it seems to go exactly against functional programming's principles by relying on mutability.
Anyways, here's my JavaScript solution for this.
function CurryIt(f) { let currentArgs = []; const curriedF = (...as) => { if (as.length === 0) { const v = f(...currentArgs); currentArgs = []; return v; } else { currentArgs = currentArgs.concat(as); return curriedF; } }; return curriedF; }
This really doesn't seem like currying. It seems counter-productive to even call it that because it seems to go exactly against functional programming's principles by relying on mutability.
Anyways, here's my JavaScript solution for this.