日本語 · English

takeLast — cut off after the last n points (recent N)

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

Category: stride (body-layer core; a separate family from selectors) / Signature: takeLast(n, until:) : Stream -> Stream / name settled (ADR-52)

Meaning

Passes only the last n input points at or before until: (inclusive). The mirror of take (“cut off at the head”) — the word that says “the most recent N firings” in an expression (ADR-52 — revising the ADR-49 deferral once real demand 〈recipe firing-example displays〉 materialized).

The terminus until: is mandatory (the dual of take’s from:; the family’s anchor rule). The output is a pure function of (input, n, until:), and the evaluation range is a cutting window over that extension. There is no “now” in the language — a dynamic “most recent” is produced by the consumer injecting the current time into until: (determinism is unchanged).

Examples

The last 3 firings of a several-times-a-year calendar entry (tensha-nichi class) — the guesswork of “how many days of window fit n firings?” disappears:

# eval: 2026-01-01..2026-12-31
@JP
tensha = [2026-01-06, 2026-03-05, 2026-05-25, 2026-07-24, 2026-10-06, 2026-12-21] covering: 2026-01-01..2026-12-31
tensha |> takeLast(3, until: 2026-08-21)
#=> 2026-03-05 2026-05-25 2026-07-24

While until: ≤ the covering tail, the count runs over the settled past only, so the answer comes out deterministic with no annotation (the mirror-image advantage over forward take, whose “covering tail always sits near now”). To attach a time, count in the day layer and attach the time afterwards (the standard composition with at):

# eval: 2026-01-01..2026-12-31
@JP
tensha = [2026-01-06, 2026-03-05, 2026-05-25, 2026-07-24, 2026-10-06, 2026-12-21] covering: 2026-01-01..2026-12-31
tensha |> takeLast(2, until: 2026-08-21) |> at(T07:00)
#=> 2026-05-25T07:00 2026-07-24T07:00

Pitfalls

take (cut off at the head = the dual) · stride (thin) · strideBy (step by width) · at (the standard composition for attaching times) · ADR-31/38/49/52.