Last active
December 18, 2015 01:29
-
-
Save arian/5704560 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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