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; }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
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.