filter

Lazily filters the given range based on the given predicate.

filter
(
alias predicate
Range
)
(
Range range
)
if (
isInputRange!(Unqual!Range) &&
isPredicateOf!(predicate, ElementType!Range)
)

Return Value

Type: auto

a range containing only elements for which the predicate returns true

Examples

enum a = [1, 2, 3, 4].staticArray;
enum result = a[].filter!(e => e > 2);

enum expected = [3, 4].staticArray;
static assert(result.equal(expected[]));
Suggestion Box / Bug Report