Created
September 8, 2019 18:40
-
-
Save pfftdammitchris/7ea45ba02c153084ea6c02571d1bcd1c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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