Last active
December 5, 2016 19:43
-
-
Save grvcoelho/29914e184075e7609c918cce2f37c400 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 curryN = (len, fn, received = []) => (...args) => { | |
let combined = [...received, ...args] | |
if (args.length === len) { | |
return fn(...combined) | |
} | |
return curryN(len - args.length, fn, combined) | |
} | |
const curry = fn => curryN(fn.length, fn) | |
const sum = curry((a, b) => a + b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.