Skip to content

Instantly share code, notes, and snippets.

@ducin
Created August 6, 2013 07:28
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 ducin/6162784 to your computer and use it in GitHub Desktop.
Save ducin/6162784 to your computer and use it in GitHub Desktop.
currying is a mechanism to pre-fill arguments of a later function call
if (!Function.prototype.curry) {
(function () {
var slice = Array.prototype.slice;
Function.prototype.curry = function () {
var target = this;
var args = slice.call(arguments);
return function () {
var allArgs = args;
if (arguments.length > 0) {
allArgs = args.concat(slice.call(arguments));
}
return target.apply(this, allArgs);
};
};
}());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment