Filtering selects elements from a collection when a predicate returns true. A predicate is a function that always returns either true or false. section 4.10
Filtering pizza sales
Define predicates such as islarge or isbbq, then filter sales before mapping each result to its price and reducing the prices with sum. Large pizzas total 37.25, while BBQ chicken pizzas total 37.5. section 4.10.1
ys = filter(p, xs)
Use filter(p, xs) to apply predicate p to collection xs and return the matching subset. section 4.10
Filtering supports increasingly structured selection:
- Apply built-in predicates to ranges, numbers, or characters, such as filter(iseven, 1:10). section 4.10
- Write predicates that test several object properties, then filter arrays of domain objects such as screws. section 13.5.3
- Convert filtered results into reusable sets and combine them with set operations. section 13.5.4
- View filtering as a data-flow stage that transforms incoming data and clarifies complex pipelines. section 3.9
































