Created
September 3, 2016 17:58
-
-
Save paddyo/cf6c1f818fb5d32c4f058fd2dbe8e3bc 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, args = []) { | |
return function(...x) { | |
let argsn = [...args, ...x]; | |
if(argsn.length >= fn.length) { | |
return fn(...argsn); | |
} | |
return curry(fn, argsn); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Curry's a non-curry'd function. f(a, b, c) {} becomes a => b => c => {}, however it can be called with any number of args, e.g. f(a,b,c), f(a,b), f(a)