日本語 · English

last — select the last in each window

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

Category: selector (body-layer core) · Signature: last : Stream(windowed) -> Stream · name settled (spec §5.4)

Meaning

Selects the last element within each window. Window-relative (I4). The default target is the innermost window; when nesting makes it ambiguous, name the target window explicitly with of: w (§4.3; the example in first). “Month-end”, “fiscal-year-end”, “the last day of the week” — all of them are really this.

monthEnd, which looks like a generator, is in fact a public boundary word of a primitive definition, monthEnd = month |> last — a reuse of last, not a separate mechanism (spec §3.6).

Examples

The last day of each month (calendar-day based; business-day adjustment is the job of a downstream roll — the I8 separation):

# eval: 2026-01-01..2026-04-01
@JP
everyDay |> within(month) |> last
#=> 2026-01-31 2026-02-28 2026-03-31

The last day of the week (Sunday under wkst: Mon):

# eval: 2026-01-05..2026-01-26
@JP
everyDay |> within(week) |> last
#=> 2026-01-11 2026-01-18 2026-01-25

Pitfalls

first · nth · roll · shift · public boundary words (spec §3.6).