Skip to content

Instantly share code, notes, and snippets.

@joshbeckman
Created October 28, 2013 15:45
Show Gist options
  • Save joshbeckman/7199231 to your computer and use it in GitHub Desktop.
Save joshbeckman/7199231 to your computer and use it in GitHub Desktop.
Curried Functions
function add (verb, a, b) {
return "The " + verb + " of " + a + ' and ' + b + ' is ' + (a + b)
}
add('sum', 5, '6')
//=> 'The sum of 5 and 6 is 11'
// Here is the curried version:
function addCurried (verb) {
return function (a) {
return function (b) {
return "The " + verb + " of " + a + ' and ' + b + ' is ' + (a + b)
}
}
}
addCurried('total')(6)(5)
//=> 'The total of 6 and 5 is 11'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment