Skip to content

Instantly share code, notes, and snippets.

@zbigniewTomczak
Created February 19, 2013 14:33
Show Gist options
  • Save zbigniewTomczak/4986427 to your computer and use it in GitHub Desktop.
Save zbigniewTomczak/4986427 to your computer and use it in GitHub Desktop.
Function.prototype.method = function (name, func) {
if (!this.prototype[name]) {
this.prototype[name] = func;
return this;
}
};
Function.method('curry', function () {
var slice = Array.prototype.slice,
args = slice.apply(arguments),
that = this;
return function () {
return that.apply(null, args.concat(slice.apply(arguments)));
};
});
function add(a, b) {
return a+b;
}
var add1 = add.curry(1);
console.log(add1(6));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment