Skip to content

Instantly share code, notes, and snippets.

@CatTail
Created May 9, 2013 14:04
Show Gist options
  • Save CatTail/5547620 to your computer and use it in GitHub Desktop.
Save CatTail/5547620 to your computer and use it in GitHub Desktop.
Curry and uncurry
Function.prototype.uncurryThis = function() {
var f = this;
return function() {
var a = arguments, b = [].slice.call(a, 1);
return f.apply(a[0], b);
};
};
Function.prototype.curry = function() {
var fn = this;
var args = [].slice.call(arguments, 0);
return function() {
return fn.apply(this, args.concat([].slice.call(arguments, 0)));
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment