Ramda and lodash/fp already curry a lot of functions.
Currying: if you know the function is curried, ex the docs say that a function has 3 arguments, if you execute the first time with one argument, it will return a new function.
Functions can "meld" aka compose
. If we have functions f, g and h.
- Zooming way out from code
- You start seeing similarities
- Pure functions are the arrows of a "category"
function compose(g, f) {
return function (x) {
return g(f(x))
}
}
Example from the exercise, better than use composition
var isAuthor = function (name, articles) {
return _.contains(name, names(articles));
};