Last active
August 29, 2015 14:22
-
-
Save oosby/18f7a939f9fe25b03e71 to your computer and use it in GitHub Desktop.
Curry
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 curryMe(x, y, z) { | |
return x / y * z; | |
}; | |
function currier() { | |
var f = Array.prototype.shift.call(arguments); | |
var a = Array.prototype.slice.call(arguments); | |
function maker () { | |
var b = Array.prototype.slice.call(arguments), | |
c = a.concat(b); | |
console.log(c) | |
if (c.length === f.length) { | |
return f.apply(this, c); | |
} else { | |
a = c; | |
return maker; | |
} | |
} | |
return maker; | |
}; | |
var sample = currier(curryMe, 2)(4)(3); | |
console.log(sample) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment