Skip to content

Instantly share code, notes, and snippets.

@arian
Last active December 18, 2015 01:29
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 arian/5704560 to your computer and use it in GitHub Desktop.
Save arian/5704560 to your computer and use it in GitHub Desktop.
var filter = require('prime/array/filter');
var slice = Array.prototype.slice;
var curry = function(fn){
var args = slice.call(arguments, 1);
return function(self){
fn.apply(null, [self].concat(args);
};
};
var modulo = function(n, i){
return i % n;
};
var even = curry(modulo, 2);
var filterEven = curry(filter, even);
filterEven([1,2,3,4,5]); // [2,4]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment