Created
October 6, 2015 18:36
-
-
Save DrBoolean/211dcd6ffe01fab42ad5 to your computer and use it in GitHub Desktop.
D13
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
function curry(fx) { | |
var arity = fx.length; | |
function f1() { | |
var args = Array.prototype.slice.call(arguments, 0); | |
if (args.length >= arity) return fx.apply(null, args); | |
function f2() { | |
return f1.apply(null, args.concat(Array.prototype.slice.call(arguments, 0))); | |
} | |
f2.toString = function() { | |
return fToString(fx)+'('+args.join(', ')+')'; | |
} | |
return f2; | |
}; | |
f1.toString = function() { return fToString(fx); } | |
return f1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment