fxNegate
Returns a predicate that's the logical negation of the one you pass in.
bool Function(T) fxNegate<T>(bool Function(T) f)
Lecture
fxNegate(f) gives you back a new predicate that returns
!f(x) for any x. It's most useful when you
already have a named predicate (isEven, fxIsEmpty,
a fxMatches(pattern) result) and want its opposite as a
function value — for filter, reject, or
anywhere else a predicate is expected — without redefining the logic.
Don't confuse it with fxNot: fxNot
flips a single bool value, fxNegate flips a whole
predicate function. fxNegate(f) is roughly
(x) => fxNot(f(x)).
Demo 1 · Basics
Demo 2 · Negating a library predicate
fxNegate composes with any predicate already in the library,
like the value-based fxIsEmpty:
Try it yourself
Exercise: use fxNegate(isVowel) to keep only the consonants.