monad(m) |
Derive standard monad combinators from a block m with bind and return fields. Returns a block with bind, return, map, then, and-then, join, sequence, map-m, and filter-m |
deep-fold(emit, next-state, s, b) |
Depth-first fold over nested blocks and lists. emit(state, block) returns a list of results at each block node. next-state(state, child-key) updates state for recursion into a child. s is the initial state |
deep-transform(rule, data) |
Recursively transform a nested structure. At each node, call rule(node). If it returns non-null, use that as the replacement (stop recursing into that node). If it returns null, recurse into children (block values and list elements) |
any? |
Predicate that matches any value. For use in match? patterns |
match?(pat, target) |
Structural predicate. Returns true if target conforms to pattern. Pattern values are interpreted by type: blocks and lists recurse as sub-patterns, functions are applied as predicates, literals are exact equality checks. Open matching: extra keys in target are ignored |
bit.and(l, r) |
Bitwise AND of integers l and r |
bit.or(l, r) |
Bitwise OR of integers l and r |
bit.xor(l, r) |
Bitwise XOR of integers l and r |
bit.not(n) |
Bitwise NOT of integer n |
bit.shl(n, k) |
Left shift n by k bits |
bit.shr(n, k) |
Arithmetic right shift n by k bits |
bit.popcount(n) |
Count set bits in integer n |
bit.ctz(n) |
Count trailing zeros in integer n (position of lowest set bit). Returns 64 if n is 0 |
bit.clz(n) |
Count leading zeros in integer n |
par-map(f, xs) |
EXPERIMENTAL (macOS/Linux only, semantics may change without notice). par-map(f, xs) - parallel map, order-preserving. Same value as xs map(f) but STRICT: it forces the spine of xs and every result, so it is unusable on an infinite or partially-consumed list and raises an error that map would have left unevaluated. f must be pure and return serialisable data |
par-sum(f, xs) |
EXPERIMENTAL (macOS/Linux only, semantics may change without notice). par-sum(f, xs) - parallel sum of f(x) over xs. Same value as xs map(f) sum; strict in the same way as par-map |
par-max(f, xs) |
EXPERIMENTAL (macOS/Linux only, semantics may change without notice). par-max(f, xs) - parallel max of f(x) over xs. Same value as xs map(f) max-of; strict in the same way as par-map |
par-min(f, xs) |
EXPERIMENTAL (macOS/Linux only, semantics may change without notice). par-min(f, xs) - parallel min of f(x) over xs. Same value as xs map(f) min-of; strict in the same way as par-map |
par-concat(f, xs) |
EXPERIMENTAL (macOS/Linux only, semantics may change without notice). par-concat(f, xs) - parallel map-then-concat. Same value as xs map(f) concat; strict in the same way as par-map |
render(value) |
Serialise value to a YAML string |
render-as(fmt, value) |
Serialise value to a string in the named format. Pipeline-friendly: data render-as(:json). Supported formats: :yaml, :json, :toml, :text, :edn, :html, :eu |
parse-as(fmt, str) |
Parse a string of structured data in the named format and return eucalypt data. The inverse of render-as. Supported formats: :json, :yaml, :toml, :csv, :xml, :edn, :jsonl. Content is parsed as inert data; embedded eucalypt expressions (e.g. YAML !eu tags) are never evaluated |
assert(p?, s, v) |
If v p? is true then return v otherwise error with message s |
__dbg-render(v) |
Print value v to stderr and return v unchanged. opts keys: label (string) |
dbg(opts, v) |
|
__dbg-val(v) |
Debug-trace value or function. On a value, prints it to stderr and returns it. On a function, returns a wrapped version that traces each output |
__dbg-after(f, x) |
|
(▶ x) |
|
alter?(k?, v!, k, v) |
If k satisfies k? then v! else v |
update?(k?, f, k, v) |
If k satisfies k? then v! else v |
vec.of |
Convert list xs of primitive values to a vec for O(1) indexed access |
vec.from-list |
Alias of vec.of: convert list xs of primitive values to a vec |
vec.len |
Return the number of elements in vec v |
vec.nth |
Return the element at index n (0-based) in vec v |
vec.slice |
Return a new vec with elements in the range [from, to) of v |
vec.sample(n, v, stream) |
Random monad action: pick n random elements from vec v without replacement; a negative n samples nothing; a non-integer n is an error |
vec.shuffle(v, stream) |
Random monad action: return vec v in random order |
vec.to-list |
Convert vec v back to a cons-list |
arr.zeros |
Create an array of zeros with the given shape list |
arr.fill |
Create an array filled with val with the given shape list |
arr.from-flat |
Create an array from a flat list of numbers with the given shape |
arr.get |
Get element at coordinate list coords in array a. Pipeline: a arr.get(coords) |
arr.set |
Return new array with element at coords set to val. Pipeline: a arr.set(coords, val) |
arr.shape |
Return shape of array a as a list of integers |
arr.rank |
Return number of dimensions of array a |
arr.length |
Return total number of elements in array a |
arr.to-list |
Return flat list of elements in row-major order |
arr.array? |
True if x is an array |
arr.transpose |
Reverse all axes of array a |
arr.reshape |
Reshape array a to new shape (total elements must match). Pipeline: a arr.reshape(shape) |
arr.slice(axis, idx, a) |
Take a slice along axis at idx, reducing rank by 1. Pipeline: a arr.slice(axis, idx) |
arr.add |
Element-wise addition; b may be a scalar |
arr.sub |
Element-wise subtraction; b may be a scalar |
arr.mul |
Element-wise multiplication; b may be a scalar |
arr.div |
Element-wise division; b may be a scalar |
arr.indices |
Return list of coordinate lists for all elements in row-major order |
arr.map(f, a) |
Apply f to each element, return new array of same shape |
arr.map-indexed(f, a) |
Apply f(coords, val) to each element, return new array of same shape |
arr.fold(f, init, a) |
Left-fold f over all elements of a in row-major order |
arr.neighbours(coords, offsets, a) |
Return list of values at valid neighbouring coordinates. Pipeline: a arr.neighbours(coords, offsets). offsets is a list of offset lists (one per neighbour direction). Out-of-bounds neighbours are omitted |
arr.unit-arrays(shape) |
List of arrays with a single 1 at each coordinate position |
is-array?(x) |
True if x is an n-dimensional array |
graph.union-find(n, edges) |
Connected components via union-find. |
Given n nodes and edges as [[i,j],...], return list of n component labels |
|
graph.topo-sort(n, edges) |
Topological ordering via Kahn’s algorithm. |
Given n nodes and directed edges as [[from,to],...], return node ordering. |
|
| Partial result if cycle exists (check count(result) = n) |
|
graph.kruskal-edges(n, edges) |
Kruskal-order merge history. |
Process edges in order via union-find. Return flat list of |
|
[edge-index, remaining-components, ...] for each edge that merges |
|
| two distinct components |
|
let |
Identity monad for sequential let-bindings. Use :let blocks for sequential evaluation without the self-reference gotcha |
for |
List monad for list comprehensions. Each binding draws from a list; subsequent bindings can depend on earlier ones. Use [x] filter(pred?) for guards |
as-spec(t) |
Convert type-data to a match?-compatible pattern. |