Created
August 12, 2020 12:58
-
-
Save sebvilhelm/64800c97eb37f044ecde4d62966c1155 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) { | |
const arity = fn.length; | |
function fun(n, args) { | |
return function(a) { | |
if(n <= 1) { | |
return fn(...args, a); | |
} | |
return fun(n - 1, [...args, a]); | |
} | |
} | |
return fun(arity, []); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment