Skip to content

Instantly share code, notes, and snippets.

@uinz
Created March 30, 2018 05:55
Show Gist options
  • Save uinz/b9991d255e19a3aeacecbb2b5a5b1def to your computer and use it in GitHub Desktop.
Save uinz/b9991d255e19a3aeacecbb2b5a5b1def to your computer and use it in GitHub Desktop.
curry
function curry(func) {
return function caller(...args) {
if (args.length >= func.length) {
return func(...args)
} else {
return (..._args) => caller(...args, ..._args)
}
}
}
function add(a, b, c) {
return a + b + c
}
const cAdd = curry(add)
console.log(
cAdd(1, 2)(3, 4)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment