Skip to content

Instantly share code, notes, and snippets.

@sadah
Created October 27, 2012 10:14
Show Gist options
  • Save sadah/3963976 to your computer and use it in GitHub Desktop.
Save sadah/3963976 to your computer and use it in GitHub Desktop.
Curry?
// from JavaScript Good Parts
Function.prototype.curry = function(){
var slice = Array.prototype.slice,
args = slice.apply(arguments),
that = this;
return function(){
return that.apply(null, args.concat(slice.apply(arguments)));
};
};
var add = function(i, j, k){
return i + j + k;
};
add(1,2,3); // 6
add1 = add.curry(1);
add1(2,3); // 6
add2 = add.curry(1,2);
add2(3); // 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment