Skip to content

Instantly share code, notes, and snippets.

@tdd
Created Feb 3, 2015
Embed
What would you like to do?
Partial application
function add(a, b, c) {
return a + b + c;
}
function partial(fx) {
var initial = Array.prototype.slice.call(arguments, 1);
return function() {
var args = Array.prototype.slice.call(arguments);
return fx.apply(this, initial.concat(args));
};
}
var add22 = partial(add, 2, 20);
add22(20);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment