Skip to content

Instantly share code, notes, and snippets.

@clintonhalpin
Last active August 29, 2015 14:06
Show Gist options
  • Save clintonhalpin/680e0fdab96333403603 to your computer and use it in GitHub Desktop.
Save clintonhalpin/680e0fdab96333403603 to your computer and use it in GitHub Desktop.
Functional Programming

Functional Programming

Currying

var get = function(property, object) {
  return object[property];
}

get('name');

Fork Function

var fork = _.curry(function(lastly, f, g, x) {
  return lastly(f(x), g(x));
});
var avg = fork( _.divide, _.sum, _.size);
assertEqual(3, avg([1,2,3,4,5]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment