Skip to content

Instantly share code, notes, and snippets.

@pfftdammitchris
Created September 8, 2019 18:40
Show Gist options
  • Save pfftdammitchris/7ea45ba02c153084ea6c02571d1bcd1c to your computer and use it in GitHub Desktop.
Save pfftdammitchris/7ea45ba02c153084ea6c02571d1bcd1c to your computer and use it in GitHub Desktop.
const curry = (fn) => {
return function curried(...args) {
const done = args.length >= fn.length
if (done) {
return fn.apply(this, args)
} else {
return (...args2) => curried.apply(this, [...args, ...args2])
}
}
}
// This is invalid because it uses ...args. The curry does not understand where to stop
function func(...args) {
//
}
const currying = curry(func)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment