Skip to content

Instantly share code, notes, and snippets.

@koshuang
Created July 27, 2013 14:42
Show Gist options
  • Save koshuang/6095044 to your computer and use it in GitHub Desktop.
Save koshuang/6095044 to your computer and use it in GitHub Desktop.
functional basis
function addf (x) {
return function(y) {
return x + y;
}
}
function add (x, y) {
return x + y;
}
function mul (x, y) {
return x * y;
}
function applyf (binary) {
return function(x) {
return function (y) {
return binary(x, y);
}
}
}
var addf = applyf(add);
console.log(addf(3)(4));
console.log(applyf(mul)(5)(6));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment