NEW ARRAY
Build arrays with NEW ARRAY and sequential ENLIST statements. No bracket syntax — arrays are always constructed explicitly. Array verbs operate on any array value regardless of how it was produced.
NEW ARRAY
Each ENLIST adds one element. No AND or AFTER between them — they are sequential within the block.
NEW ARRAY
OPEN NEST
ENLIST "red"
ENLIST "green"
ENLIST "blue"
CLOSE NEST
SET ?colors
AFTER EMIT ?colors
Try it ›
ENLIST with expressions and variables
UPPER "ocalt" SET ?name
NEW ARRAY
OPEN NEST
ENLIST ?name
ENLIST CALCULATE "2 + 2"
ENLIST true
CLOSE NEST
SET ?arr
AFTER EMIT ?arr
Try it ›
ENLIST AS (n) — positional index
Inserts at a specific 0-based index. If any ENLIST in the block uses AS (n), all of them must — mixing indexed and non-indexed in the same block is an error.
NEW ARRAY
OPEN NEST
ENLIST "third" AS (2)
ENLIST "first" AS (0)
ENLIST "second" AS (1)
CLOSE NEST
SET ?arr
AFTER EMIT ?arr
(* → ["first","second","third"] *)
SORT
Primitives sort by value. Objects sort by a named field via WITH "field". Default ascending — FORMAT "desc" for descending.
SPLIT "banana,apple,cherry,date" WITH "," SET ?fruits
AFTER SORT ?fruits SET ?asc
AFTER EMIT ?asc
Try it ›
SPLIT "banana,apple,cherry,date" WITH "," SET ?fruits
AFTER SORT ?fruits FORMAT "desc" SET ?desc
AFTER EMIT ?desc
Try it ›
(* Sort objects by field *)
QUERY "products" FROM "shop" SET ?rows
AFTER SORT ?rows WITH "price" FORMAT "desc" SET ?sorted
AFTER EMIT ?sorted
REVERSE
Reverses an array. Also works on a string — reverses the character order.
SPLIT "a,b,c,d" WITH "," SET ?arr
AFTER REVERSE ARRAY ?arr SET ?rev
AFTER EMIT ?rev
(* → ["d","c","b","a"] *)
Try it ›
(* On a string — reverses characters *)
REVERSE STRING "Engineering Magic" SET ?r
AFTER EMIT ?r
(* → "cigaM gnireenignE" *)
Try it ›
UNIQUE
Removes duplicate values. Comparison is by display string. Preserves order of first occurrence.
SPLIT "a,b,a,c,b,d" WITH "," SET ?arr
AFTER UNIQUE ?arr SET ?deduped
AFTER EMIT ?deduped
(* → ["a","b","c","d"] *)
Try it ›
FLATTEN
One level of nesting only. Values that are not arrays pass through unchanged.
PARSE JSON `[[1,2],[3,4],[5]]` SET ?nested
AFTER FLATTEN ?nested SET ?flat
AFTER EMIT ?flat
(* → [1,2,3,4,5] *)
Try it ›
FIRST / LAST
Returns null on an empty array.
SPLIT "alpha,beta,gamma" WITH "," SET ?arr
AFTER FIRST ?arr SET ?f
AFTER LAST ?arr SET ?l
AFTER EMIT ?f & " / " & ?l
(* → "alpha / gamma" *)
Try it ›
PLUCK
WHERE is required. Objects missing the named field return null at that position.
PARSE JSON `[{"name":"Alice","age":30},{"name":"Bob","age":25}]` SET ?users
AFTER PLUCK ?users WHERE "name" SET ?names
AFTER EMIT ?names
(* → ["Alice","Bob"] *)
Try it ›
SLICE
Works on arrays and strings. FROM is inclusive, TO is exclusive.
SPLIT "a,b,c,d,e" WITH "," SET ?arr
AFTER SLICE ?arr FROM 1 TO 3 SET ?mid
AFTER EMIT ?mid
(* → ["b","c"] *)
Try it ›
LENGTH
Element count on arrays, character count on strings, byte count on binary.
SPLIT "a,b,c" WITH "," SET ?arr
AFTER LENGTH ?arr SET ?n
AFTER EMIT ?n
(* → 3 *)
Try it ›
APPEND
Push a value onto an existing array, insert at a specific index, or set a key on an object. Writes back to the source variable automatically — the result is also returned via SET if used.
SPLIT "a,b,c" WITH "," SET ?arr
AFTER APPEND "d" INTO ?arr
AFTER EMIT ?arr
(* → ["a","b","c","d"] *)
Try it ›
(* Insert at index *)
SPLIT "a,b,c" WITH "," SET ?arr
AFTER APPEND "x" AS "1" INTO ?arr
AFTER EMIT ?arr
(* → ["a","x","b","c"] *)
Try it ›
(* Set a key on an object *)
NEW JSON OBJECT OPEN NEST SET "name" AS "Alice" CLOSE NEST SET ?obj
AFTER APPEND "30" AS "age" INTO ?obj
AFTER EMIT ?obj
(* → {"name":"Alice","age":"30"} *)
Try it ›
COLLAPSE — from multivariable
Primary way to build an array from dynamic parallel branches. See Multivariable & COLLAPSE.
UPPER "alpha" SET ?r
AND UPPER "beta" SET ?r
AND UPPER "gamma" SET ?r
COLLAPSE ?r SET ?all
AFTER EMIT ?all(0)(result) & " / " & ?all(1)(result) & " / " & ?all(2)(result)
Try it ›
| Verb | Key modifiers | Notes |
NEW ARRAY OPEN NEST ENLIST v ... CLOSE NEST | ENLIST v AS (n) for positional | Cannot mix indexed and non-indexed in one block |
SORT ?arr | WITH "field" — FORMAT "desc" | — |
REVERSE ARRAY ?arr | — | Reverses element order |
UNIQUE ?arr | — | Deduplicates by display string |
FLATTEN ?arr | — | One level only |
FIRST ?arr | — | null if empty |
LAST ?arr | — | null if empty |
PLUCK ?arr WHERE "field" | WHERE required | — |
SLICE ?arr FROM n TO n | — | Also works on strings |
LENGTH ?arr | — | Also works on strings and binary |
COLLAPSE ?multi | — | From multivariable only |