Skip to content

Instantly share code, notes, and snippets.

@paddyo
Created September 3, 2016 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paddyo/cf6c1f818fb5d32c4f058fd2dbe8e3bc to your computer and use it in GitHub Desktop.
Save paddyo/cf6c1f818fb5d32c4f058fd2dbe8e3bc to your computer and use it in GitHub Desktop.
function curry(fn, args = []) {
return function(...x) {
let argsn = [...args, ...x];
if(argsn.length >= fn.length) {
return fn(...argsn);
}
return curry(fn, argsn);
}
}
@paddyo
Copy link
Author

paddyo commented Sep 3, 2016

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment