Created
July 20, 2015 23:37
-
-
Save alkhe/af86d57fcadd21f9e587 to your computer and use it in GitHub Desktop.
Simple function currying.
This file contains 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
let curry = fn => { | |
let total = fn.length; | |
let len = 0; | |
let argarr = []; | |
let recur = (...args) => { | |
len += args.length; | |
argarr = argarr.concat(args); | |
return len >= total ? fn(...argarr) : recur; | |
} | |
return recur; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment