Skip to content

Instantly share code, notes, and snippets.

@sebvilhelm
Created August 12, 2020 12:58
Show Gist options
  • Save sebvilhelm/64800c97eb37f044ecde4d62966c1155 to your computer and use it in GitHub Desktop.
Save sebvilhelm/64800c97eb37f044ecde4d62966c1155 to your computer and use it in GitHub Desktop.
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