日本語 · English

filter — thin by predicate

Translated from the canonical Japanese page reference/filter.md. The source_sha above records the source revision; a consistency check flags this page when the Japanese original changes.

Category: filter (body-layer core) / Signature: filter(on: P) / filter(x => condition)
Stream -> Stream / name settled (spec §5.4)

Meaning

Keeps only the points that satisfy the predicate. Both forms are taken (where was folded into filter; ADR-25):

Examples

Keep business days only (2026-01-01 is a holiday; 1/3 and 1/4 are a weekend):

# eval: 2026-01-01..2026-01-08
@JP
everyDay |> filter(on: bizDay)
#=> 2026-01-02 2026-01-05 2026-01-06 2026-01-07

Keep Mondays only (label predicate):

# eval: 2026-01-01..2026-01-20
@JP
everyDay |> filter(d => weekday(d) == Mon)
#=> 2026-01-05 2026-01-12 2026-01-19

Combined with a projection, “select by window coordinates” — the 11th of every month:

# eval: 2026-01-01..2026-04-01
@JP
everyDay |> filter(d => ordinalIn(day, month, d) == 11)
#=> 2026-01-11 2026-02-11 2026-03-11

Pitfalls

roll (nudges instead of thinning) · ordinalIn · cycle (the source of label predicates) · I8 · ADR-25/26.