Skip to content

Instantly share code, notes, and snippets.

@jremmen
Created November 5, 2013 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jremmen/7327680 to your computer and use it in GitHub Desktop.
Save jremmen/7327680 to your computer and use it in GitHub Desktop.
js: partial application example
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