Part V — The Modern Experience Layer · Chapter 27 · Lesson 3 of 3
The modern builtin toolkit
The 1.0.0-experience release added more builtins than the language had before it. Nobody memorizes them; everybody learns the shape and discovers the rest with pea stdlib. This lesson maps the territory.
Iteration and shaping
- enumerate / zip — index-aware iteration, and pairwise iteration over two lists.
- map / filter / sum / any / all / min / max / abs — the functional core, now with stricter totality checks.
- sorted / reversed — non-mutating ordering. For projection-then-operation, look at
sort_by,sum_by,index_by,pluck. - chunk / flatten / uniq / compact / partition — list restructuring.
partition(xs, pred)returns a pair of kept and discarded lists. - group_by / frequencies / count_by — bucketing.
group_byreturns a map from key to list. - scan — running totals, like a cumulative fold.
Path and record operations
- get_path / set_path / has_path — dotted-path access on nested maps:
get_path(cfg, "database.pool.size"). - merge / deep_merge — shallow vs recursive map merge.
- pick / omit / pick_by / omit_by / defaults — record projection and default filling.
- invert / map_values / map_keys / to_pairs / from_pairs / rename_keys / assoc / dissoc — structural record transforms.
String and codec helpers
- trim / replace / starts_with / ends_with / strip_prefix / strip_suffix — boundary-safe string manipulation.
- snake_case / kebab_case / slugify / capitalize / title_case / truncate / pad_start / pad_end / center / lines / words — text formatting.
- json_parse / json_dump / b64encode / b64decode / b64decode / hex_encode / hex_decode / url_encode / url_decode / sha256 / html_escape — the codec family.
- now_ms / now_iso / uuid / randint / shuffle / random_choice / sample_list — ambient utilities.
Pipes and application
let total = pipe(
orders,
function(o) { return filter(o, function(r) { return r.status == "paid" }) },
function(o) { return sum_by(o, function(r) { return r.amount }) }
)
pipe threads a value through single-argument functions; apply(fn, args) invokes with a list of arguments. Use pipes for linear transforms; reach for plain code past three stages.
Numbers and correctness
clamp / format_number / floor / ceil / log / exp / pow / gcd / lcm / sign / is_even / is_odd / lerp / between cover the scalar case; parse_int / parse_float with explicit fallbacks replace ad-hoc coercion. The type predicates — is_null / is_list / is_dict / is_string / is_number / is_bool / is_empty — are the honest way to guard the boundary of anything external.
Version note. Everything on this list is additive over v0.63 — no v0.63 program changes behavior, but almost every hand-rolled loop in a v0.63 codebase can become a one-liner now.
Guided practice
- Rewrite your three longest accumulation loops with comprehensions or
map/filter/sum_by. - Replace
cfg["database"]["pool"]["size"]-style access withget_pathanddefaults. - Run
pea stdliband pick one builtin you didn't know — read the signature, write three usages.
Rule of thumb. Before writing a helper function, search pea stdlib. The most-missed builtin in review is always the one that already exists.