Skip to content

Instantly share code, notes, and snippets.

@aztecrex
Created October 18, 2015 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aztecrex/75ab4af15b1669c4ed24 to your computer and use it in GitHub Desktop.
Save aztecrex/75ab4af15b1669c4ed24 to your computer and use it in GitHub Desktop.
Curry function, my answer to Omniscient.js Workshop task #13
var curry = function (fn) {
var me = this;
function gen(cur) {
return function () {
var next = cur.concat(Array.prototype.slice.call(arguments))
if (next.length >= fn.length) {
return fn.apply(me, next)
} else {
return gen(next)
}
}
}
return gen([]);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment