Skip to content

Instantly share code, notes, and snippets.

@JamieDixon
Created July 7, 2018 13:04
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 JamieDixon/05263ad16dc6320cde09808bcd26deb6 to your computer and use it in GitHub Desktop.
Save JamieDixon/05263ad16dc6320cde09808bcd26deb6 to your computer and use it in GitHub Desktop.
const curry = fn => function innerCurry(...args) {
return args.length >= fn.length ? fn(...args) : innerCurry.bind(null, ...args);
}
const foo = curry((a, b, c) => a + b + c);
foo(1, 2, 3); // 6
foo(1)(2, 3); // 6
foo(1, 2)(3); // 6
foo(1)(2)(3) // 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment