Skip to content

Instantly share code, notes, and snippets.

@Shinpeim
Created October 26, 2014 13:56
Show Gist options
  • Save Shinpeim/b974274acb475d2a1d18 to your computer and use it in GitHub Desktop.
Save Shinpeim/b974274acb475d2a1d18 to your computer and use it in GitHub Desktop.
var f = function(a){
return a + 1;
}
var g = function(b){
return - b
}
function compose(f, g){
return function(a){
return g(f(a));
}
}
console.log( [1, 2, 3, 4].map(compose(f, g)) ); // => [ -2, -3, -4, -5 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment