x-lang

← Index

x/core/list

Boot-layer list plumbing; public list processing lives on the List class.

Boot list layer: %-private walkers only (the top level is sacred, #108); the public list API is the List class.

%as-list

Boot-layer plumbing: normalize any iterable to a list (%fold/%map/%filter self-normalize through it). The PUBLIC conversion surface is (List from-seq); this % helper is not provided.

Returns: LIST — The input as a proper list

Examples:

(%as-list (Vector of 1 2 3)) => (1 2 3)

Folds

%fold

Boot-layer fold; the public face is (List fold).

Parameters:

Returns: ANY — Final accumulated value

Examples:

(%fold (fn (_ acc x) (+ acc x)) 0 '(1 2 3)) => 6

Basics

%length

Boot-layer length; the public face is (List length).

Parameters:

Examples:

(%length '(a b c)) => 3

%append

Boot-layer append; the public face is (List append).

Examples:

(%append '(1 2) '(3) '(4 5)) => (1 2 3 4 5)

%reverse

Boot-layer reverse; the public face is (List reverse).

Parameters:

Examples:

(%reverse '(1 2 3)) => (3 2 1)

Iteration

%map

Boot-layer map; the public face is (List map).

Parameters:

Returns: LIST — New list

Examples:

(%map (fn (_ x) (* x x)) '(1 2 3)) => (1 4 9)
(%map + '(1 2) '(10 20)) => (11 22)

%filter

Boot-layer filter; the public face is (List filter).

Parameters:

Returns: LIST — Filtered list

Examples:

(%filter (fn (_ x) (> x 1)) '(1 2 3)) => (2 3)

%memq?

Boot-layer eq? membership test.

Boot-layer eq? membership; the public face is (List includes?). Cross-base names need %member-str?.

Parameters:

Returns: BOOL — True if x occurs in lst under eq?

Examples:

(%memq? 'b '(a b c)) => #t
(%memq? 'z '(a b c)) => #f

%member-str?

Boot-layer string membership test.

The str=? side of the membership split; convert cross-base symbols to strings and use this.

Parameters:

Returns: BOOL — True if s occurs in lst under str=?

Examples:

(%member-str? "b" (list "a" "b")) => #t

%find

Boot-layer find-first matching element.

Boot-layer find-first; the public face is (List find). A nil result conflates a stored nil with a miss – box at the call site when that matters (the %opt-cell pattern).

Parameters:

Returns: ANY — First element satisfying pred, or nil

Examples:

(%find (fn (_ x) (> x 1)) '(1 2 3)) => 2

%for-each

Boot-layer for-each; the public face is (List for-each).

Parameters: