ilo 26.5.0

ilo - the token-minimal programming language AI agents write
Documentation
-- Negative indices on slice-shaped builtins count from the end of the
-- list or text, matching Python semantics already in place for `at xs i`,
-- with one ergonomic exception on `slc`'s end bound (see below).
--
--   slc xs s e   accepts negative s and e. `slc xs -1 (len xs)` is the
--                last element as a 1-element list. `slc xs -3 -1` keeps
--                Python-style semantics when start is negative (the
--                penultimate window). When start is non-negative and
--                end is exactly -1, the end is read as "to end of
--                list/text" (see `slc-to-end.ilo`).
--   take n xs    with n<0 keeps all but the last |n|. Equivalent to
--                Python's xs[:n]. `take -1 [10,20,30]` is [10,20]. Use
--                this when you want to "drop the last element".
--   drop n xs    with n<0 keeps only the last |n|. Equivalent to
--                Python's xs[n:]. `drop -1 [10,20,30]` is [30].

last-element xs:L n>L n;slc xs -1 (len xs)
drop-last xs:L n>L n;take -1 xs
keep-last-two xs:L n>L n;slc xs -2 (len xs)
all-but-last xs:L n>L n;take -1 xs
only-last-two xs:L n>L n;drop -2 xs
trim-edges s:t>t;slc s 1 (- (len s) 1)
penultimate xs:L n>L n;slc xs -3 -1

-- run: last-element [10,20,30,40,50]
-- out: [50]
-- run: drop-last [10,20,30,40,50]
-- out: [10, 20, 30, 40]
-- run: keep-last-two [10,20,30,40,50]
-- out: [40, 50]
-- run: all-but-last [10,20,30,40,50]
-- out: [10, 20, 30, 40]
-- run: only-last-two [10,20,30,40,50]
-- out: [40, 50]
-- run: trim-edges "(quoted)"
-- out: quoted
-- run: penultimate [10,20,30,40,50]
-- out: [30, 40]