I was looking to write an "all-or-nothing" function over an array. One approach is, of course, to leverage Array.prototype.every and do something like
function allOrNothing(arr, f, fInv) {
return arr.every(f) || arr.every(fInv);
}
where f and fInv are indicator functions, and fInv is an "inverse" function of f. For example, if f = (x) => x != null, then fInv = (x) => x == null.
This leads me to think: is it possible to get the function fInv from f?
!(logical 'not')? As infInv = x => !f(x)?