日本語 · English

before — cutting a point set to “strictly before p”

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

Category: sugar (stdlib; a Gregorian public word = transform) / Signature: before(p) : Stream -> Stream (p is a dated date-time literal) / Name final (ADR-55, 2026-10-19, spec §5.4) / The 1.1 additive extension

Meaning

Keeps the input points strictly before p (p excluded). The expansion is one filter stage (sugar = spec §4.8):

before(p) = s => s |> filter(t => t < p)

Paired with since (at or after p, inclusive) it cuts the half-open [since, before) — the same boundary convention as the evaluation range [from, to), windows and isOpen.

before is the dual on the end side: in the 1.0 core it could only be written as an epochOrdinal ordinal comparison (with a unit) or as a difference \ (which stops on a union with alignment “none” and drops windows).

Examples

Day granularity — business days strictly before 10/13 (10/12 is Sports Day):

# eval: 2026-10-01..2026-10-20
@JP
bizDay |> before(2026-10-13)
#=> 2026-10-01 2026-10-02 2026-10-05 2026-10-06 2026-10-07 2026-10-08 2026-10-09

Timed — the deadline day from 9:00 up to but not including 17:00 (17:00 is not in):

# eval: 2026-11-04..2026-11-05
@JP
hourly = everyInstant |> strideBy(1h, from: 2026-01-01)
hourly |> since(2026-11-04T09:00) |> before(2026-11-04T17:00)
#=> 2026-11-04T09:00 2026-11-04T10:00 2026-11-04T11:00 2026-11-04T12:00 2026-11-04T13:00 2026-11-04T14:00 2026-11-04T15:00 2026-11-04T16:00

Pitfalls

since (the pair; at or after p) · filter (the expansion) · takeLast (until: is point-inclusive) · epochOrdinal (the 1.0 form) · spec §4.8 / §4.9 · ADR-55.