any() ‐ For determining if any value in a sequence satisfies a predicate.
Synopsis
Declared in <folly/gen/Base.h>
template<
class Predicate = Identity,
class Filter = /* implementation-defined */,
class NotEmpty = /* implementation-defined */,
class Composed = /* implementation-defined */::Composed<Filter, NotEmpty>>
Composed
any(Predicate pred = Predicate());
Description
The following is an example for checking if any computer is broken:
bool schrepIsMad = from(computers) | any(isBroken);
(because everyone knows Schrep hates broken computers).
Note that if no predicate is provided, 'any()' checks if any of the values are true when cased to bool. To check if any of the scores are nonZero:
bool somebodyScored = from(scores) | any();
Note: Passing an empty sequence through 'any()' will always return false. In fact, 'any()' is equivilent to the composition of 'filter()' and 'notEmpty'.
from(source) | any(pred) == from(source) | filter(pred) | notEmpty
Return Value
A sink returning true if any value satisfies pred.
Parameters
Name |
Description |
pred |
The predicate tested against each value. |
Created with MrDocs