Skip to content

Instantly share code, notes, and snippets.

@ovaillancourt
Created February 28, 2013 23:03
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 ovaillancourt/5060916 to your computer and use it in GitHub Desktop.
Save ovaillancourt/5060916 to your computer and use it in GitHub Desktop.
function add( x,y ){
return x + y;
}
function staticAdd( x ){
return function( y ){
return x + y;
}
}
var addFive = staticAdd( 5 );
addFive( 3 ) // 8
function partialApplicator( x, cb ){
return function( y ){
return cb( x, y );
}
}
var addFive = partialApplicator( 5, add );
function mult( x, y ){
return x * y;
}
var multFive = partialApplicator( 5, mult );
multFive( 8 ) // 40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment