Skip to content

Instantly share code, notes, and snippets.

@mauriciosoares
Created May 20, 2014 14:48
Show Gist options
  • Save mauriciosoares/ba7c2e0f77ea5b7e492a to your computer and use it in GitHub Desktop.
Save mauriciosoares/ba7c2e0f77ea5b7e492a to your computer and use it in GitHub Desktop.
function curry(fn) {
var slice = Array.prototype.slice,
stored_args = slice.call(arguments, 1);
return function() {
var new_args = slice.call(arguments),
args = stored_args.concat(new_args);
return fn.apply(null, args);
}
}
function add(x, y) {
return x + y;
}
console.log(curry(add, 5)(7));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment