Skip to content

Instantly share code, notes, and snippets.

@Mizzlr
Created June 16, 2016 08:46
Show Gist options
  • Save Mizzlr/aadd2696a8d550272a6d6d66a33b9c44 to your computer and use it in GitHub Desktop.
Save Mizzlr/aadd2696a8d550272a6d6d66a33b9c44 to your computer and use it in GitHub Desktop.
function curry(f) {
return function (x) {
return function (y) {
return f(x,y);
};
};
};
function uncurry(f) {
return function (x,y) {
return f(x)(y);
};
};
// example
function sumSquare(x,y) {
return x*x + y*y;
};
var curriedSumSquare = curry(sumSquare);
// sumSquare(x,y) can be invoked as
curriedSumSquare(x)(y);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment