Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save PatrickJS/5462653 to your computer and use it in GitHub Desktop.
Save PatrickJS/5462653 to your computer and use it in GitHub Desktop.
Write a function that takes a binary function, and makes it callable with two invocations
function applyf(binary) {
return function(x) {
return function(y) {
return binary(x, y);
};
};
}
addf = applyf(add);
addf(3)(4) //=> 7
applyf(mul)(5)(6) //=> 30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment