Skip to content

Instantly share code, notes, and snippets.

@davidbarral
Created February 11, 2018 16:00
Show Gist options
  • Save davidbarral/0a59e868b2a6bd7285b6df0069bce196 to your computer and use it in GitHub Desktop.
Save davidbarral/0a59e868b2a6bd7285b6df0069bce196 to your computer and use it in GitHub Desktop.
Curry: final version
const curry = fn => {
const curryN = (n, fn) => (...args) =>
args.length >= n
? fn(...args)
: curryN(n - args.length, (...innerArgs) => fn(...args, ...innerArgs));
return curryN(fn.length, fn);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment