Created
November 5, 2013 22:43
-
-
Save jremmen/7327680 to your computer and use it in GitHub Desktop.
js: partial application example
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
calculate = function(a, f) { return a.reduce(function(x,y) { return f(x, y) }); } | |
sum = function(a, b) { return a + b; } | |
sub = function(a, b) { return a - b; } | |
sumAll = function(a) { return calculate(a, sum); } | |
subAll = function(a) { return calculate(a, sub); } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment