Created
June 13, 2014 06:24
-
-
Save H2CO3/d08b70b0ca5bfb8332cc 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
function curry(fn) { | |
let curry_argc = argc - 1; | |
var curry_args = {}; | |
for var i = 0; i < curry_argc; i++ { | |
curry_args[i] = #i; | |
} | |
return function() { | |
for var i = 0; i < argc; i++ { | |
curry_args[curry_argc + i] = #i; | |
} | |
return call(fn, curry_args); | |
}; | |
} | |
let addThree = curry(function(a, b, c, d) { | |
return a + b + c + d; | |
}, 1, 2); | |
print(addThree(42, 3)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment