Created
May 20, 2014 14:48
-
-
Save mauriciosoares/ba7c2e0f77ea5b7e492a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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