Is there a naming convention for higher order functions? That is, functions which return other functions.
An example in Javascript:
function onlyDivisibleBy(div) { // <-- higher order function
return function (n) {
return n % div === 0;
}
}
var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
arr.filter(onlyDivisibleBy(3)); // [0, 3, 6, 9]
arr.filter(onlyDivisibleBy(5)); // [0, 5]
I've tended to write it as above: that is, optimising for legibility at the invocation point (I'd read the last lines above as "filter the array to get items only divisible by 5"), however at the definition point away from the context in which it's used, it's not so easy to understand what this function does from its name.