Standard Library Reference
The Orbital Standard Library provides domain-agnostic building blocks for S-expressions. These are fundamental operations that compose to form complex logic in guards, effects, and computed fields.
This documentation is automatically generated from the std library source code. All operators listed here are available in every Almadar schema.
How to use operators
Operators are invoked as S-expressions — a JSON array where the first element is the operator name:
["math/abs", -5] // => 5
["str/upper", "hello"] // => "HELLO"
["arr/length", [1, 2, 3]] // => 3
Operators compose naturally:
["str/concat",
["str/upper", "@entity.firstName"],
" ",
["str/upper", "@entity.lastName"]
]
🔢Mathematical Operations
Numeric operations for calculations, rounding, clamping, and randomization.
16 operators
math/abs✨ PureAbsolute value
| Parameter | Type | Description |
|---|---|---|
n | number | The number |
["math/abs", -5] // => 5numberArgs: 1 argumentmath/min✨ PureMinimum of values
| Parameter | Type | Description |
|---|---|---|
...nums | number[] | Numbers to compare |
["math/min", 3, 1, 4] // => 1numberArgs: 2 or moremath/max✨ PureMaximum of values
| Parameter | Type | Description |
|---|---|---|
...nums | number[] | Numbers to compare |
["math/max", 3, 1, 4] // => 4numberArgs: 2 or moremath/clamp✨ PureConstrain value to range [min, max]
| Parameter | Type | Description |
|---|---|---|
n | number | The value to clamp |
min | number | Minimum bound |
max | number | Maximum bound |
["math/clamp", 150, 0, 100] // => 100numberArgs: 3 argumentsmath/floor✨ PureRound down to integer
| Parameter | Type | Description |
|---|---|---|
n | number | The number |
["math/floor", 3.7] // => 3numberArgs: 1 argumentmath/ceil✨ PureRound up to integer
| Parameter | Type | Description |
|---|---|---|
n | number | The number |
["math/ceil", 3.2] // => 4numberArgs: 1 argumentmath/round✨ PureRound to nearest integer or specified decimals
| Parameter | Type | Description |
|---|---|---|
n | number | The number |
decimals (opt) | number | Decimal places (default: 0) |
["math/round", 3.456, 2] // => 3.46numberArgs: 1–2 argumentsmath/pow✨ PureExponentiation (base^exp)
| Parameter | Type | Description |
|---|---|---|
base | number | The base |
exp | number | The exponent |
["math/pow", 2, 8] // => 256numberArgs: 2 argumentsmath/sqrt✨ PureSquare root
| Parameter | Type | Description |
|---|---|---|
n | number | The number |
["math/sqrt", 16] // => 4numberArgs: 1 argumentmath/mod✨ PureModulo (remainder)
| Parameter | Type | Description |
|---|---|---|
a | number | Dividend |
b | number | Divisor |
["math/mod", 7, 3] // => 1numberArgs: 2 argumentsmath/sign✨ PureReturns -1, 0, or 1 indicating sign
| Parameter | Type | Description |
|---|---|---|
n | number | The number |
["math/sign", -42] // => -1numberArgs: 1 argumentmath/lerp✨ PureLinear interpolation between a and b by factor t
| Parameter | Type | Description |
|---|---|---|
a | number | Start value |
b | number | End value |
t | number | Interpolation factor (0-1) |
["math/lerp", 0, 100, 0.5] // => 50numberArgs: 3 argumentsmath/map✨ PureMap value from one range to another
| Parameter | Type | Description |
|---|---|---|
n | number | The value |
inMin | number | Input range minimum |
inMax | number | Input range maximum |
outMin | number | Output range minimum |
outMax | number | Output range maximum |
["math/map", 5, 0, 10, 0, 100] // => 50numberArgs: 5 argumentsmath/random✨ PureRandom number between 0 (inclusive) and 1 (exclusive)
["math/random"] // => 0.7234...numberArgs: 0 argumentsmath/randomInt✨ PureRandom integer in range [min, max] (inclusive)
| Parameter | Type | Description |
|---|---|---|
min | number | Minimum (inclusive) |
max | number | Maximum (inclusive) |
["math/randomInt", 1, 6] // => 4numberArgs: 2 argumentsmath/default✨ PureReturn default if value is null, undefined, or NaN
| Parameter | Type | Description |
|---|---|---|
n | number | null | The value |
default | number | Default value |
["math/default", null, 0] // => 0numberArgs: 2 arguments📝String Operations
Text manipulation including formatting, splitting, trimming, and templating.
27 operators
str/len✨ PureString length
| Parameter | Type | Description |
|---|---|---|
s | string | The string |
["str/len", "hello"] // => 5numberArgs: 1 argumentstr/concat✨ PureConcatenate strings together
| Parameter | Type | Description |
|---|---|---|
strings | string | Strings to concatenate |
["str/concat", "/users/", "@entity.id"] // => "/users/123"textArgs: 1–99 argumentsstr/upper✨ PureConvert to uppercase
| Parameter | Type | Description |
|---|---|---|
s | string | The string |
["str/upper", "hello"] // => "HELLO"textArgs: 1 argumentstr/lower✨ PureConvert to lowercase
| Parameter | Type | Description |
|---|---|---|
s | string | The string |
["str/lower", "HELLO"] // => "hello"textArgs: 1 argumentstr/trim✨ PureRemove leading and trailing whitespace
| Parameter | Type | Description |
|---|---|---|
s | string | The string |
["str/trim", " hello "] // => "hello"textArgs: 1 argumentstr/trimStart✨ PureRemove leading whitespace
| Parameter | Type | Description |
|---|---|---|
s | string | The string |
["str/trimStart", " hello"] // => "hello"textArgs: 1 argumentstr/trimEnd✨ PureRemove trailing whitespace
| Parameter | Type | Description |
|---|---|---|
s | string | The string |
["str/trimEnd", "hello "] // => "hello"textArgs: 1 argumentstr/split✨ PureSplit string into array by delimiter
| Parameter | Type | Description |
|---|---|---|
s | string | The string |
delim | string | Delimiter |
["str/split", "a,b,c", ","] // => ["a", "b", "c"]listArgs: 2 argumentsstr/join✨ PureJoin array elements into string
| Parameter | Type | Description |
|---|---|---|
arr | array | Array to join |
delim | string | Delimiter |
["str/join", ["a", "b", "c"], ", "] // => "a, b, c"textArgs: 2 argumentsstr/slice✨ PureExtract substring
| Parameter | Type | Description |
|---|---|---|
s | string | The string |
start | number | Start index |
end (opt) | number | End index (exclusive) |
["str/slice", "hello", 1, 4] // => "ell"textArgs: 2–3 argumentsstr/replace✨ PureReplace first occurrence
| Parameter | Type | Description |
|---|---|---|
s | string | The string |
find | string | String to find |
replace | string | Replacement |
["str/replace", "hello world", "world", "there"] // => "hello there"textArgs: 3 argumentsstr/replaceAll✨ PureReplace all occurrences
| Parameter | Type | Description |
|---|---|---|
s | string | The string |
find | string | String to find |
replace | string | Replacement |
["str/replaceAll", "a-b-c", "-", "_"] // => "a_b_c"textArgs: 3 argumentsstr/includes✨ PureCheck if string contains substring
| Parameter | Type | Description |
|---|---|---|
s | string | The string |
search | string | Substring to find |
["str/includes", "hello world", "world"] // => truetrue/falseArgs: 2 argumentsstr/startsWith✨ PureCheck if string starts with prefix
| Parameter | Type | Description |
|---|---|---|
s | string | The string |
prefix | string | Prefix to check |
["str/startsWith", "hello", "hel"] // => truetrue/falseArgs: 2 argumentsstr/endsWith✨ PureCheck if string ends with suffix
| Parameter | Type | Description |
|---|---|---|
s | string | The string |
suffix | string | Suffix to check |
["str/endsWith", "hello", "lo"] // => truetrue/falseArgs: 2 argumentsstr/padStart✨ PurePad string from start to target length
| Parameter | Type | Description |
|---|---|---|
s | string | The string |
len | number | Target length |
char (opt) | string | Padding character (default: ) |
["str/padStart", "5", 3, "0"] // => "005"textArgs: 2–3 argumentsstr/padEnd✨ PurePad string from end to target length
| Parameter | Type | Description |
|---|---|---|
s | string | The string |
len | number | Target length |
char (opt) | string | Padding character (default: ) |
["str/padEnd", "5", 3, "0"] // => "500"textArgs: 2–3 argumentsstr/repeat✨ PureRepeat string n times
| Parameter | Type | Description |
|---|---|---|
s | string | The string |
count | number | Repeat count |
["str/repeat", "ab", 3] // => "ababab"textArgs: 2 argumentsstr/reverse✨ PureReverse string
| Parameter | Type | Description |
|---|---|---|
s | string | The string |
["str/reverse", "hello"] // => "olleh"textArgs: 1 argumentstr/capitalize✨ PureCapitalize first character
| Parameter | Type | Description |
|---|---|---|
s | string | The string |
["str/capitalize", "hello"] // => "Hello"textArgs: 1 argumentstr/titleCase✨ PureConvert to Title Case
| Parameter | Type | Description |
|---|---|---|
s | string | The string |
["str/titleCase", "hello world"] // => "Hello World"textArgs: 1 argumentstr/camelCase✨ PureConvert to camelCase
| Parameter | Type | Description |
|---|---|---|
s | string | The string |
["str/camelCase", "hello world"] // => "helloWorld"textArgs: 1 argumentstr/kebabCase✨ PureConvert to kebab-case
| Parameter | Type | Description |
|---|---|---|
s | string | The string |
["str/kebabCase", "Hello World"] // => "hello-world"textArgs: 1 argumentstr/snakeCase✨ PureConvert to snake_case
| Parameter | Type | Description |
|---|---|---|
s | string | The string |
["str/snakeCase", "Hello World"] // => "hello_world"textArgs: 1 argumentstr/default✨ PureReturn default if value is null/undefined/empty
| Parameter | Type | Description |
|---|---|---|
s | string | null | The value |
default | string | Default value |
["str/default", null, "N/A"] // => "N/A"textArgs: 2 argumentsstr/template✨ PureVariable substitution in template string
| Parameter | Type | Description |
|---|---|---|
template | string | Template with {placeholders} |
vars | object | Variables to substitute |
["str/template", "Hello, {name}!", {"name": "World"}] // => "Hello, World!"textArgs: 2 argumentsstr/truncate✨ PureTruncate string with optional suffix
| Parameter | Type | Description |
|---|---|---|
s | string | The string |
len | number | Maximum length |
suffix (opt) | string | Suffix for truncated strings (default: ...) |
["str/truncate", "Hello World", 8, "..."] // => "Hello..."textArgs: 2–3 arguments📋Collection Operations
Work with lists and arrays including filtering, mapping, and aggregation.
39 operators
array/len✨ PureArray length
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
["array/len", [1, 2, 3]] // => 3numberArgs: 1 argumentarray/empty?✨ PureCheck if array is empty
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
["array/empty?", []] // => truetrue/falseArgs: 1 argumentarray/first✨ PureGet first element
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
["array/first", [1, 2, 3]] // => 1any valueArgs: 1 argumentarray/last✨ PureGet last element
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
["array/last", [1, 2, 3]] // => 3any valueArgs: 1 argumentarray/nth✨ PureGet element at index
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
index | number | Index (0-based) |
["array/nth", [1, 2, 3], 1] // => 2any valueArgs: 2 argumentsarray/slice✨ PureExtract subarray
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
start | number | Start index |
end (opt) | number | End index (exclusive) |
["array/slice", [1, 2, 3, 4], 1, 3] // => [2, 3]listArgs: 2–3 argumentsarray/concat✨ PureConcatenate arrays
| Parameter | Type | Description |
|---|---|---|
...arrs | array[] | Arrays to concatenate |
["array/concat", [1, 2], [3, 4]] // => [1, 2, 3, 4]listArgs: 2 or morearray/append✨ PureAdd item to end (returns new array)
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
item | any | Item to add |
["array/append", [1, 2], 3] // => [1, 2, 3]listArgs: 2 argumentsarray/prepend✨ PureAdd item to start (returns new array)
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
item | any | Item to add |
["array/prepend", [2, 3], 1] // => [1, 2, 3]listArgs: 2 argumentsarray/insert✨ PureInsert item at index (returns new array)
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
index | number | Index to insert at |
item | any | Item to insert |
["array/insert", [1, 3], 1, 2] // => [1, 2, 3]listArgs: 3 argumentsarray/remove✨ PureRemove item at index (returns new array)
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
index | number | Index to remove |
["array/remove", [1, 2, 3], 1] // => [1, 3]listArgs: 2 argumentsarray/removeItem✨ PureRemove first matching item (returns new array)
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
item | any | Item to remove |
["array/removeItem", [1, 2, 3, 2], 2] // => [1, 3, 2]listArgs: 2 argumentsarray/reverse✨ PureReverse array order (returns new array)
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
["array/reverse", [1, 2, 3]] // => [3, 2, 1]listArgs: 1 argumentarray/sort✨ PureSort array (returns new array)
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
key (opt) | string | Field to sort by (for objects) |
dir (opt) | string | "asc" or "desc" (default: asc) |
["array/sort", "@items", "price", "desc"]listArgs: 1–3 argumentsarray/shuffle✨ PureRandomly shuffle array (returns new array)
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
["array/shuffle", [1, 2, 3, 4, 5]]listArgs: 1 argumentarray/unique✨ PureRemove duplicates (returns new array)
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
["array/unique", [1, 2, 2, 3, 1]] // => [1, 2, 3]listArgs: 1 argumentarray/flatten✨ PureFlatten nested arrays one level
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
["array/flatten", [[1, 2], [3, 4]]] // => [1, 2, 3, 4]listArgs: 1 argumentarray/zip✨ PurePair elements from two arrays
| Parameter | Type | Description |
|---|---|---|
arr1 | array | First array |
arr2 | array | Second array |
["array/zip", [1, 2], ["a", "b"]] // => [[1, "a"], [2, "b"]]listArgs: 2 argumentsarray/includes✨ PureCheck if array contains item
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
item | any | Item to find |
["array/includes", [1, 2, 3], 2] // => truetrue/falseArgs: 2 argumentsarray/indexOf✨ PureFind index of item (-1 if not found)
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
item | any | Item to find |
["array/indexOf", [1, 2, 3], 2] // => 1numberArgs: 2 argumentsarray/find✨ PureFind first element matching predicate
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
pred | lambda | Predicate function |
["array/find", "@items", ["fn", "x", ["=", "@x.status", "active"]]]any valueArgs: 2 argumentsarray/findIndex✨ PureFind index of first element matching predicate (-1 if none)
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
pred | lambda | Predicate function |
["array/findIndex", "@items", ["fn", "x", ["=", "@x.status", "active"]]]numberArgs: 2 argumentsarray/filter✨ PureKeep elements matching predicate
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
pred | lambda | Predicate function |
["array/filter", "@items", ["fn", "x", [">", "@x.price", 100]]]listArgs: 2 argumentsarray/reject✨ PureRemove elements matching predicate
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
pred | lambda | Predicate function |
["array/reject", "@items", ["fn", "x", ["=", "@x.status", "deleted"]]]listArgs: 2 argumentsarray/map✨ PureTransform each element
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
fn | lambda | Transform function |
["array/map", "@items", ["fn", "x", ["*", "@x.price", 1.1]]]listArgs: 2 argumentsarray/reduce✨ PureReduce array to single value
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
fn | lambda | Reducer function (acc, item) => newAcc |
init | any | Initial accumulator value |
["array/reduce", "@items", ["fn", ["acc", "x"], ["+", "@acc", "@x.price"]], 0]any valueArgs: 3 argumentsarray/every✨ PureCheck if all elements match predicate
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
pred | lambda | Predicate function |
["array/every", "@items", ["fn", "x", [">", "@x.price", 0]]]true/falseArgs: 2 argumentsarray/some✨ PureCheck if any element matches predicate
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
pred | lambda | Predicate function |
["array/some", "@items", ["fn", "x", ["=", "@x.status", "active"]]]true/falseArgs: 2 argumentsarray/count✨ PureCount elements (optionally matching predicate)
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
pred (opt) | lambda | Predicate function |
["array/count", "@tasks", ["fn", "t", ["=", "@t.status", "done"]]]numberArgs: 1–2 argumentsarray/sum✨ PureSum values (optionally by field)
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
key (opt) | string | Field to sum |
["array/sum", "@cart.items", "price"]numberArgs: 1–2 argumentsarray/avg✨ PureAverage of values (optionally by field)
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
key (opt) | string | Field to average |
["array/avg", "@ratings", "score"]numberArgs: 1–2 argumentsarray/min✨ PureMinimum value (optionally by field)
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
key (opt) | string | Field to compare |
["array/min", "@products", "price"]numberArgs: 1–2 argumentsarray/max✨ PureMaximum value (optionally by field)
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
key (opt) | string | Field to compare |
["array/max", "@products", "price"]numberArgs: 1–2 argumentsarray/groupBy✨ PureGroup elements by field value
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
key | string | Field to group by |
["array/groupBy", "@orders", "status"]any valueArgs: 2 argumentsarray/partition✨ PureSplit array by predicate into [matches, nonMatches]
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
pred | lambda | Predicate function |
["array/partition", "@items", ["fn", "x", [">", "@x.price", 50]]]listArgs: 2 argumentsarray/take✨ PureTake first n elements
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
n | number | Number of elements |
["array/take", "@items", 5]listArgs: 2 argumentsarray/drop✨ PureSkip first n elements
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
n | number | Number of elements to skip |
["array/drop", "@items", 5]listArgs: 2 argumentsarray/takeLast✨ PureTake last n elements
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
n | number | Number of elements |
["array/takeLast", "@items", 3]listArgs: 2 argumentsarray/dropLast✨ PureSkip last n elements
| Parameter | Type | Description |
|---|---|---|
arr | array | The array |
n | number | Number of elements to skip |
["array/dropLast", "@items", 2]listArgs: 2 arguments🔑Object Utilities
Access and manipulate object properties safely.
19 operators
object/keys✨ PureGet object keys as array
| Parameter | Type | Description |
|---|---|---|
obj | object | The object |
["object/keys", {"a": 1, "b": 2}] // => ["a", "b"]listArgs: 1 argumentobject/values✨ PureGet object values as array
| Parameter | Type | Description |
|---|---|---|
obj | object | The object |
["object/values", {"a": 1, "b": 2}] // => [1, 2]listArgs: 1 argumentobject/entries✨ PureGet [key, value] pairs as array
| Parameter | Type | Description |
|---|---|---|
obj | object | The object |
["object/entries", {"a": 1}] // => [["a", 1]]listArgs: 1 argumentobject/fromEntries✨ PureCreate object from [key, value] pairs
| Parameter | Type | Description |
|---|---|---|
entries | array | Array of [key, value] pairs |
["object/fromEntries", [["a", 1], ["b", 2]]] // => {"a": 1, "b": 2}any valueArgs: 1 argumentobject/get✨ PureGet nested value by path
| Parameter | Type | Description |
|---|---|---|
obj | object | The object |
path | string | Dot-separated path (e.g., "user.name") |
default (opt) | any | Default if path not found |
["object/get", "@user", "profile.name", "Anonymous"]any valueArgs: 2–3 argumentsobject/set✨ PureSet nested value by path (returns new object)
| Parameter | Type | Description |
|---|---|---|
obj | object | The object |
path | string | Dot-separated path |
value | any | Value to set |
["object/set", "@user", "profile.name", "John"]any valueArgs: 3 argumentsobject/has✨ PureCheck if path exists
| Parameter | Type | Description |
|---|---|---|
obj | object | The object |
path | string | Dot-separated path |
["object/has", "@user", "profile.name"]true/falseArgs: 2 argumentsobject/merge✨ PureShallow merge objects (later wins)
| Parameter | Type | Description |
|---|---|---|
...objs | object[] | Objects to merge |
["object/merge", {"a": 1}, {"b": 2}] // => {"a": 1, "b": 2}any valueArgs: 2 or moreobject/deepMerge✨ PureDeep merge objects (later wins)
| Parameter | Type | Description |
|---|---|---|
...objs | object[] | Objects to merge |
["object/deepMerge", {"a": {"b": 1}}, {"a": {"c": 2}}]any valueArgs: 2 or moreobject/pick✨ PureSelect only specified keys
| Parameter | Type | Description |
|---|---|---|
obj | object | The object |
keys | array | Keys to keep |
["object/pick", "@entity", ["name", "email"]]any valueArgs: 2 argumentsobject/omit✨ PureExclude specified keys
| Parameter | Type | Description |
|---|---|---|
obj | object | The object |
keys | array | Keys to exclude |
["object/omit", "@entity", ["password", "secret"]]any valueArgs: 2 argumentsobject/mapValues✨ PureTransform all values
| Parameter | Type | Description |
|---|---|---|
obj | object | The object |
fn | lambda | Transform function |
["object/mapValues", "@stats", ["fn", "v", ["*", "@v", 100]]]any valueArgs: 2 argumentsobject/mapKeys✨ PureTransform all keys
| Parameter | Type | Description |
|---|---|---|
obj | object | The object |
fn | lambda | Transform function |
["object/mapKeys", "@data", ["fn", "k", ["str/upper", "@k"]]]any valueArgs: 2 argumentsobject/filter✨ PureFilter entries by predicate
| Parameter | Type | Description |
|---|---|---|
obj | object | The object |
pred | lambda | Predicate (key, value) => boolean |
["object/filter", "@data", ["fn", ["k", "v"], ["!=", "@v", null]]]any valueArgs: 2 argumentsobject/empty?✨ PureCheck if object has no keys
| Parameter | Type | Description |
|---|---|---|
obj | object | The object |
["object/empty?", {}] // => truetrue/falseArgs: 1 argumentobject/equals✨ PureDeep equality check
| Parameter | Type | Description |
|---|---|---|
a | object | First object |
b | object | Second object |
["object/equals", {"a": 1}, {"a": 1}] // => truetrue/falseArgs: 2 argumentsobject/clone✨ PureShallow clone object
| Parameter | Type | Description |
|---|---|---|
obj | object | The object |
["object/clone", "@entity"]any valueArgs: 1 argumentobject/deepClone✨ PureDeep clone object
| Parameter | Type | Description |
|---|---|---|
obj | object | The object |
["object/deepClone", "@entity"]any valueArgs: 1 argumentpath✨ PureBuild a dot-separated path string from segments. Used with set effect for dynamic field paths.
| Parameter | Type | Description |
|---|---|---|
...segments | string[] | Path segments to join with dots |
["path", "formValues", "@payload.fieldId"] // => "formValues.customerName"textArgs: 1 or more⏰Date & Time
Work with dates, times, durations, and timestamps.
25 operators
time/now✨ PureCurrent timestamp
["time/now"] // => 1705593600000numberArgs: 0 argumentstime/today✨ PureToday at midnight (local time)
["time/today"]numberArgs: 0 argumentstime/parse✨ PureParse string to timestamp
| Parameter | Type | Description |
|---|---|---|
str | string | Date string |
format (opt) | string | Format pattern |
["time/parse", "2024-01-18", "YYYY-MM-DD"]numberArgs: 1–2 argumentstime/format✨ PureFormat timestamp to string
| Parameter | Type | Description |
|---|---|---|
date | number | Timestamp |
format | string | Format pattern |
["time/format", "@entity.createdAt", "MMM DD, YYYY"]textArgs: 2 argumentstime/year✨ PureGet year from timestamp
| Parameter | Type | Description |
|---|---|---|
date | number | Timestamp |
["time/year", "@entity.createdAt"] // => 2024numberArgs: 1 argumenttime/month✨ PureGet month from timestamp (1-12)
| Parameter | Type | Description |
|---|---|---|
date | number | Timestamp |
["time/month", "@entity.createdAt"] // => 1numberArgs: 1 argumenttime/day✨ PureGet day of month from timestamp (1-31)
| Parameter | Type | Description |
|---|---|---|
date | number | Timestamp |
["time/day", "@entity.createdAt"] // => 18numberArgs: 1 argumenttime/weekday✨ PureGet day of week (0=Sunday, 6=Saturday)
| Parameter | Type | Description |
|---|---|---|
date | number | Timestamp |
["time/weekday", "@entity.createdAt"] // => 4 (Thursday)numberArgs: 1 argumenttime/hour✨ PureGet hour from timestamp (0-23)
| Parameter | Type | Description |
|---|---|---|
date | number | Timestamp |
["time/hour", "@entity.createdAt"] // => 14numberArgs: 1 argumenttime/minute✨ PureGet minute from timestamp (0-59)
| Parameter | Type | Description |
|---|---|---|
date | number | Timestamp |
["time/minute", "@entity.createdAt"] // => 30numberArgs: 1 argumenttime/second✨ PureGet second from timestamp (0-59)
| Parameter | Type | Description |
|---|---|---|
date | number | Timestamp |
["time/second", "@entity.createdAt"] // => 45numberArgs: 1 argumenttime/add✨ PureAdd time to timestamp
| Parameter | Type | Description |
|---|---|---|
date | number | Timestamp |
amount | number | Amount to add |
unit | string | Time unit (year/month/week/day/hour/minute/second/ms) |
["time/add", ["time/now"], 7, "day"]numberArgs: 3 argumentstime/subtract✨ PureSubtract time from timestamp
| Parameter | Type | Description |
|---|---|---|
date | number | Timestamp |
amount | number | Amount to subtract |
unit | string | Time unit |
["time/subtract", ["time/now"], 1, "hour"]numberArgs: 3 argumentstime/diff✨ PureDifference between timestamps
| Parameter | Type | Description |
|---|---|---|
a | number | First timestamp |
b | number | Second timestamp |
unit (opt) | string | Result unit (default: ms) |
["time/diff", "@entity.birthDate", ["time/now"], "year"]numberArgs: 2–3 argumentstime/startOf✨ PureGet start of time period
| Parameter | Type | Description |
|---|---|---|
date | number | Timestamp |
unit | string | Time unit (year/month/week/day/hour/minute) |
["time/startOf", ["time/now"], "month"]numberArgs: 2 argumentstime/endOf✨ PureGet end of time period
| Parameter | Type | Description |
|---|---|---|
date | number | Timestamp |
unit | string | Time unit |
["time/endOf", ["time/now"], "month"]numberArgs: 2 argumentstime/isBefore✨ PureCheck if a is before b
| Parameter | Type | Description |
|---|---|---|
a | number | First timestamp |
b | number | Second timestamp |
["time/isBefore", "@entity.startDate", "@entity.endDate"]true/falseArgs: 2 argumentstime/isAfter✨ PureCheck if a is after b
| Parameter | Type | Description |
|---|---|---|
a | number | First timestamp |
b | number | Second timestamp |
["time/isAfter", ["time/now"], "@entity.deadline"]true/falseArgs: 2 argumentstime/isBetween✨ PureCheck if date is between start and end
| Parameter | Type | Description |
|---|---|---|
date | number | Timestamp to check |
start | number | Range start |
end | number | Range end |
["time/isBetween", ["time/now"], "@entity.startDate", "@entity.endDate"]true/falseArgs: 3 argumentstime/isSame✨ PureCheck if timestamps are same (optionally by unit)
| Parameter | Type | Description |
|---|---|---|
a | number | First timestamp |
b | number | Second timestamp |
unit (opt) | string | Comparison unit |
["time/isSame", "@a", "@b", "day"]true/falseArgs: 2–3 argumentstime/isPast✨ PureCheck if timestamp is in the past
| Parameter | Type | Description |
|---|---|---|
date | number | Timestamp |
["time/isPast", "@entity.expiresAt"]true/falseArgs: 1 argumenttime/isFuture✨ PureCheck if timestamp is in the future
| Parameter | Type | Description |
|---|---|---|
date | number | Timestamp |
["time/isFuture", "@entity.scheduledAt"]true/falseArgs: 1 argumenttime/isToday✨ PureCheck if timestamp is today
| Parameter | Type | Description |
|---|---|---|
date | number | Timestamp |
["time/isToday", "@entity.createdAt"]true/falseArgs: 1 argumenttime/relative✨ PureFormat as relative time ("2 hours ago", "in 3 days")
| Parameter | Type | Description |
|---|---|---|
date | number | Timestamp |
["time/relative", "@entity.lastActivityAt"] // => "2 hours ago"textArgs: 1 argumenttime/duration✨ PureFormat milliseconds as duration ("2h 30m")
| Parameter | Type | Description |
|---|---|---|
ms | number | Duration in milliseconds |
["time/duration", 9000000] // => "2h 30m"textArgs: 1 argument✅Input Validation
Validate user input with common patterns like email, required, length checks.
23 operators
validate/required✨ PureCheck if value is not null, undefined, or empty string
| Parameter | Type | Description |
|---|---|---|
value | any | Value to check |
["validate/required", "@payload.name"]true/falseArgs: 1 argumentvalidate/string✨ PureCheck if value is a string
| Parameter | Type | Description |
|---|---|---|
value | any | Value to check |
["validate/string", "@payload.name"]true/falseArgs: 1 argumentvalidate/number✨ PureCheck if value is a number
| Parameter | Type | Description |
|---|---|---|
value | any | Value to check |
["validate/number", "@payload.age"]true/falseArgs: 1 argumentvalidate/boolean✨ PureCheck if value is a boolean
| Parameter | Type | Description |
|---|---|---|
value | any | Value to check |
["validate/boolean", "@payload.active"]true/falseArgs: 1 argumentvalidate/array✨ PureCheck if value is an array
| Parameter | Type | Description |
|---|---|---|
value | any | Value to check |
["validate/array", "@payload.items"]true/falseArgs: 1 argumentvalidate/object✨ PureCheck if value is an object
| Parameter | Type | Description |
|---|---|---|
value | any | Value to check |
["validate/object", "@payload.data"]true/falseArgs: 1 argumentvalidate/email✨ PureCheck if value is a valid email format
| Parameter | Type | Description |
|---|---|---|
value | string | Email to validate |
["validate/email", "@payload.email"]true/falseArgs: 1 argumentvalidate/url✨ PureCheck if value is a valid URL format
| Parameter | Type | Description |
|---|---|---|
value | string | URL to validate |
["validate/url", "@payload.website"]true/falseArgs: 1 argumentvalidate/uuid✨ PureCheck if value is a valid UUID
| Parameter | Type | Description |
|---|---|---|
value | string | UUID to validate |
["validate/uuid", "@payload.id"]true/falseArgs: 1 argumentvalidate/phone✨ PureCheck if value is a valid phone number
| Parameter | Type | Description |
|---|---|---|
value | string | Phone number to validate |
["validate/phone", "@payload.phone"]true/falseArgs: 1 argumentvalidate/creditCard✨ PureCheck if value is a valid credit card number (Luhn algorithm)
| Parameter | Type | Description |
|---|---|---|
value | string | Card number to validate |
["validate/creditCard", "@payload.cardNumber"]true/falseArgs: 1 argumentvalidate/date✨ PureCheck if value is a valid date
| Parameter | Type | Description |
|---|---|---|
value | any | Value to check |
["validate/date", "@payload.birthDate"]true/falseArgs: 1 argumentvalidate/minLength✨ PureCheck if string/array has minimum length
| Parameter | Type | Description |
|---|---|---|
value | string | array | Value to check |
min | number | Minimum length |
["validate/minLength", "@payload.password", 8]true/falseArgs: 2 argumentsvalidate/maxLength✨ PureCheck if string/array has maximum length
| Parameter | Type | Description |
|---|---|---|
value | string | array | Value to check |
max | number | Maximum length |
["validate/maxLength", "@payload.name", 50]true/falseArgs: 2 argumentsvalidate/length✨ PureCheck if string/array has exact length
| Parameter | Type | Description |
|---|---|---|
value | string | array | Value to check |
exact | number | Required length |
["validate/length", "@payload.code", 6]true/falseArgs: 2 argumentsvalidate/min✨ PureCheck if number is >= minimum
| Parameter | Type | Description |
|---|---|---|
value | number | Number to check |
min | number | Minimum value |
["validate/min", "@payload.age", 18]true/falseArgs: 2 argumentsvalidate/max✨ PureCheck if number is <= maximum
| Parameter | Type | Description |
|---|---|---|
value | number | Number to check |
max | number | Maximum value |
["validate/max", "@payload.quantity", 100]true/falseArgs: 2 argumentsvalidate/range✨ PureCheck if number is within range [min, max]
| Parameter | Type | Description |
|---|---|---|
value | number | Number to check |
min | number | Minimum value |
max | number | Maximum value |
["validate/range", "@payload.rating", 1, 5]true/falseArgs: 3 argumentsvalidate/pattern✨ PureCheck if string matches regex pattern
| Parameter | Type | Description |
|---|---|---|
value | string | String to check |
regex | string | Regex pattern |
["validate/pattern", "@payload.code", "^[A-Z]{3}[0-9]{3}$"]true/falseArgs: 2 argumentsvalidate/oneOf✨ PureCheck if value is in list of allowed values
| Parameter | Type | Description |
|---|---|---|
value | any | Value to check |
options | array | Allowed values |
["validate/oneOf", "@payload.role", ["admin", "user", "guest"]]true/falseArgs: 2 argumentsvalidate/noneOf✨ PureCheck if value is not in list of disallowed values
| Parameter | Type | Description |
|---|---|---|
value | any | Value to check |
options | array | Disallowed values |
["validate/noneOf", "@payload.username", ["admin", "root", "system"]]true/falseArgs: 2 argumentsvalidate/equals✨ PureDeep equality check
| Parameter | Type | Description |
|---|---|---|
a | any | First value |
b | any | Second value |
["validate/equals", "@payload.password", "@payload.confirmPassword"]true/falseArgs: 2 argumentsvalidate/check✨ PureRun multiple validation rules, return { valid, errors }
| Parameter | Type | Description |
|---|---|---|
value | any | Value or object to validate |
rules | object | Validation rules by field |
["validate/check", "@payload.data", {
"name": [["required"], ["minLength", 2], ["maxLength", 50]],
"email": [["required"], ["email"]],
"age": [["number"], ["min", 18]]
}]any valueArgs: 2 arguments🎨Data Formatting
Display formatting for currency, numbers, dates, and file sizes.
9 operators
format/number✨ PureFormat number with locale-aware separators
| Parameter | Type | Description |
|---|---|---|
n | number | Number to format |
opts (opt) | object | Format options (decimals, locale) |
["format/number", 1234567.89] // => "1,234,567.89"textArgs: 1–2 argumentsformat/currency✨ PureFormat as currency
| Parameter | Type | Description |
|---|---|---|
n | number | Amount |
currency | string | Currency code (USD, EUR, etc.) |
locale (opt) | string | Locale (default: en-US) |
["format/currency", 1234.56, "USD"] // => "$1,234.56"textArgs: 2–3 argumentsformat/percent✨ PureFormat as percentage
| Parameter | Type | Description |
|---|---|---|
n | number | Number (0.5 = 50%) |
decimals (opt) | number | Decimal places (default: 0) |
["format/percent", 0.856, 1] // => "85.6%"textArgs: 1–2 argumentsformat/bytes✨ PureFormat bytes as human-readable size
| Parameter | Type | Description |
|---|---|---|
n | number | Bytes |
["format/bytes", 2500000] // => "2.4 MB"textArgs: 1 argumentformat/ordinal✨ PureFormat number as ordinal (1st, 2nd, 3rd)
| Parameter | Type | Description |
|---|---|---|
n | number | Number |
["format/ordinal", 42] // => "42nd"textArgs: 1 argumentformat/plural✨ PureFormat count with singular/plural word
| Parameter | Type | Description |
|---|---|---|
n | number | Count |
singular | string | Singular form |
plural | string | Plural form |
["format/plural", 5, "item", "items"] // => "5 items"textArgs: 3 argumentsformat/list✨ PureFormat array as natural language list
| Parameter | Type | Description |
|---|---|---|
arr | array | Array of strings |
style (opt) | string | "and" or "or" (default: and) |
["format/list", ["Alice", "Bob", "Charlie"], "and"] // => "Alice, Bob, and Charlie"textArgs: 1–2 argumentsformat/phone✨ PureFormat phone number
| Parameter | Type | Description |
|---|---|---|
str | string | Phone number digits |
format (opt) | string | Format pattern (default: US) |
["format/phone", "5551234567"] // => "(555) 123-4567"textArgs: 1–2 argumentsformat/creditCard✨ PureFormat credit card with masked digits
| Parameter | Type | Description |
|---|---|---|
str | string | Card number |
["format/creditCard", "4111111111111234"] // => "•••• •••• •••• 1234"textArgs: 1 argument⏳Async Operations
Control timing with delays, debouncing, retries, and timeouts.
9 operators
async/delay⚡ EffectWait for specified milliseconds, optionally execute an effect after
| Parameter | Type | Description |
|---|---|---|
ms | number | Milliseconds to wait |
effect | expression | Optional effect to execute after delay |
["async/delay", 2000, ["emit", "RETRY"]] // Wait 2s then emitany valueArgs: 1–2 argumentsasync/interval⚡ EffectExecute an effect periodically at a fixed interval
| Parameter | Type | Description |
|---|---|---|
ms | number | Interval in milliseconds |
effect | expression | Effect to execute each interval |
["async/interval", 5000, ["emit", "POLL_TICK"]] // Emit every 5stextArgs: 2 argumentsasync/timeout⚡ EffectAdd timeout to an effect
| Parameter | Type | Description |
|---|---|---|
effect | expression | Effect to execute |
ms | number | Timeout in milliseconds |
["async/timeout", ["call", "api", "fetchData"], 5000]any valueArgs: 2 argumentsasync/debounce⚡ EffectDebounce an event (wait for pause in events)
| Parameter | Type | Description |
|---|---|---|
event | string | Event name to emit |
ms | number | Debounce delay in milliseconds |
["async/debounce", "SEARCH", 300]nothingArgs: 2 argumentsasync/throttle⚡ EffectThrottle an event (emit at most once per interval)
| Parameter | Type | Description |
|---|---|---|
event | string | Event name to emit |
ms | number | Throttle interval in milliseconds |
["async/throttle", "SCROLL", 100]nothingArgs: 2 argumentsasync/retry⚡ EffectRetry an effect with configurable backoff
| Parameter | Type | Description |
|---|---|---|
effect | expression | Effect to retry |
opts | object | { attempts, backoff, baseDelay } |
["async/retry",
["call", "api", "fetchData", { "id": "@entity.id" }],
{ "attempts": 3, "backoff": "exponential", "baseDelay": 1000 }]any valueArgs: 2 argumentsasync/race⚡ EffectExecute effects in parallel, return first to complete
| Parameter | Type | Description |
|---|---|---|
...effects | expression[] | Effects to race |
["async/race", ["call", "api1"], ["call", "api2"]]any valueArgs: 2 or moreasync/all⚡ EffectExecute effects in parallel, wait for all to complete
| Parameter | Type | Description |
|---|---|---|
...effects | expression[] | Effects to execute |
["async/all", ["call", "api1"], ["call", "api2"]]listArgs: 2 or moreasync/sequence⚡ EffectExecute effects in sequence (one after another)
| Parameter | Type | Description |
|---|---|---|
...effects | expression[] | Effects to execute in order |
["async/sequence", ["call", "validate"], ["call", "save"]]listArgs: 2 or more🧠Neural Network Operations
Define and compose neural network layers and modules.
14 operators
nn/sequential✨ PureCreate a sequential neural network from layers
| Parameter | Type | Description |
|---|---|---|
...layers | nn/layer[] | Layers to stack sequentially |
["nn/sequential", ["nn/linear", 16, 64], ["nn/relu"], ["nn/linear", 64, 4]]nn/moduleArgs: 1 or morenn/linear✨ PureFully connected linear layer (output = input * weights + bias)
| Parameter | Type | Description |
|---|---|---|
inFeatures | number | Input dimension |
outFeatures | number | Output dimension |
["nn/linear", 16, 64] // 16 inputs -> 64 outputsnn/layerArgs: 2 argumentsnn/relu✨ PureReLU activation function: max(0, x)
["nn/relu"]nn/layerArgs: 0 argumentsnn/tanh✨ PureTanh activation function: (e^x - e^-x) / (e^x + e^-x)
["nn/tanh"]nn/layerArgs: 0 argumentsnn/sigmoid✨ PureSigmoid activation function: 1 / (1 + e^-x)
["nn/sigmoid"]nn/layerArgs: 0 argumentsnn/softmax✨ PureSoftmax activation function (normalizes to probability distribution)
| Parameter | Type | Description |
|---|---|---|
dim (opt) | number | Dimension to apply softmax (default: -1) |
["nn/softmax"]nn/layerArgs: 0–1 argumentsnn/dropout✨ PureDropout layer for regularization (randomly zeros elements during training)
| Parameter | Type | Description |
|---|---|---|
p (opt) | number | Dropout probability (default: 0.5) |
["nn/dropout", 0.3] // 30% dropoutnn/layerArgs: 0–1 argumentsnn/batchnorm✨ PureBatch normalization layer
| Parameter | Type | Description |
|---|---|---|
numFeatures | number | Number of features to normalize |
["nn/batchnorm", 64]nn/layerArgs: 1 argumentnn/layernorm✨ PureLayer normalization
| Parameter | Type | Description |
|---|---|---|
normalizedShape | number | number[] | Shape to normalize over |
["nn/layernorm", 64]nn/layerArgs: 1 argumentnn/forward✨ PureExecute forward pass through network
| Parameter | Type | Description |
|---|---|---|
module | nn/module | The neural network module |
input | tensor | Input tensor |
["nn/forward", "@entity.architecture", "@entity.sensors"]tensorArgs: 2 argumentsnn/getWeights✨ PureGet network weights as a flat tensor
| Parameter | Type | Description |
|---|---|---|
module | nn/module | The neural network module |
["nn/getWeights", "@entity.architecture"]tensorArgs: 1 argumentnn/setWeights⚡ EffectSet network weights from a flat tensor
| Parameter | Type | Description |
|---|---|---|
module | nn/module | The neural network module |
weights | tensor | New weights as flat tensor |
["nn/setWeights", "@entity.architecture", "@payload.newWeights"]nn/moduleArgs: 2 argumentsnn/paramCount✨ PureGet total number of trainable parameters
| Parameter | Type | Description |
|---|---|---|
module | nn/module | The neural network module |
["nn/paramCount", "@entity.architecture"] // => 3300numberArgs: 1 argumentnn/clone✨ PureCreate a deep copy of the network with same weights
| Parameter | Type | Description |
|---|---|---|
module | nn/module | The neural network module to clone |
["nn/clone", "@entity.architecture"]nn/moduleArgs: 1 argument📊Tensor Operations
Create and manipulate multi-dimensional arrays for numerical computing.
29 operators
tensor/from✨ PureCreate tensor from array
| Parameter | Type | Description |
|---|---|---|
data | array | Array of numbers (can be nested for multi-dimensional) |
["tensor/from", [1.0, 2.0, 3.0]]tensorArgs: 1 argumenttensor/zeros✨ PureCreate tensor filled with zeros
| Parameter | Type | Description |
|---|---|---|
shape | number[] | Shape of the tensor |
["tensor/zeros", [3, 4]] // 3x4 tensor of zerostensorArgs: 1 argumenttensor/ones✨ PureCreate tensor filled with ones
| Parameter | Type | Description |
|---|---|---|
shape | number[] | Shape of the tensor |
["tensor/ones", [3, 4]] // 3x4 tensor of onestensorArgs: 1 argumenttensor/rand✨ PureCreate tensor with random values in [0, 1)
| Parameter | Type | Description |
|---|---|---|
shape | number[] | Shape of the tensor |
["tensor/rand", [16]] // Random 16-element vectortensorArgs: 1 argumenttensor/randn✨ PureCreate tensor with random values from standard normal distribution
| Parameter | Type | Description |
|---|---|---|
shape | number[] | Shape of the tensor |
["tensor/randn", [16]] // Random normal 16-element vectortensorArgs: 1 argumenttensor/shape✨ PureGet tensor shape as array
| Parameter | Type | Description |
|---|---|---|
tensor | tensor | The tensor |
["tensor/shape", "@entity.sensors"] // => [16]number[]Args: 1 argumenttensor/get✨ PureGet element at index
| Parameter | Type | Description |
|---|---|---|
tensor | tensor | The tensor |
index | number | number[] | Index (single for 1D, array for multi-D) |
["tensor/get", "@entity.output", 3] // Get 4th elementnumberArgs: 2 argumentstensor/slice✨ PureGet slice of tensor
| Parameter | Type | Description |
|---|---|---|
tensor | tensor | The tensor |
start | number | Start index |
end | number | End index (exclusive) |
["tensor/slice", "@entity.output", 0, 3] // First 3 elementstensorArgs: 3 argumentstensor/reshape✨ PureReshape tensor to new shape (total elements must match)
| Parameter | Type | Description |
|---|---|---|
tensor | tensor | The tensor |
shape | number[] | New shape |
["tensor/reshape", "@entity.data", [4, 4]] // Reshape to 4x4tensorArgs: 2 argumentstensor/flatten✨ PureFlatten tensor to 1D
| Parameter | Type | Description |
|---|---|---|
tensor | tensor | The tensor |
["tensor/flatten", "@entity.data"]tensorArgs: 1 argumenttensor/add✨ PureElement-wise addition
| Parameter | Type | Description |
|---|---|---|
a | tensor | First tensor |
b | tensor | number | Second tensor or scalar |
["tensor/add", "@entity.a", "@entity.b"]tensorArgs: 2 argumentstensor/sub✨ PureElement-wise subtraction
| Parameter | Type | Description |
|---|---|---|
a | tensor | First tensor |
b | tensor | number | Second tensor or scalar |
["tensor/sub", "@entity.a", "@entity.b"]tensorArgs: 2 argumentstensor/mul✨ PureElement-wise multiplication
| Parameter | Type | Description |
|---|---|---|
a | tensor | First tensor |
b | tensor | number | Second tensor or scalar |
["tensor/mul", "@entity.weights", 0.99] // Decay weightstensorArgs: 2 argumentstensor/div✨ PureElement-wise division
| Parameter | Type | Description |
|---|---|---|
a | tensor | First tensor |
b | tensor | number | Second tensor or scalar |
["tensor/div", "@entity.gradient", "@entity.batchSize"]tensorArgs: 2 argumentstensor/matmul✨ PureMatrix multiplication
| Parameter | Type | Description |
|---|---|---|
a | tensor | First tensor (NxM) |
b | tensor | Second tensor (MxK) |
["tensor/matmul", "@entity.input", "@entity.weights"]tensorArgs: 2 argumentstensor/dot✨ PureDot product of two 1D tensors
| Parameter | Type | Description |
|---|---|---|
a | tensor | First vector |
b | tensor | Second vector |
["tensor/dot", "@entity.a", "@entity.b"]numberArgs: 2 argumentstensor/sum✨ PureSum of tensor elements
| Parameter | Type | Description |
|---|---|---|
tensor | tensor | The tensor |
dim (opt) | number | Dimension to reduce |
["tensor/sum", "@entity.rewards"] // Total rewardnumber | tensorArgs: 1–2 argumentstensor/mean✨ PureMean of tensor elements
| Parameter | Type | Description |
|---|---|---|
tensor | tensor | The tensor |
dim (opt) | number | Dimension to reduce |
["tensor/mean", "@entity.losses"]number | tensorArgs: 1–2 argumentstensor/max✨ PureMaximum value in tensor
| Parameter | Type | Description |
|---|---|---|
tensor | tensor | The tensor |
dim (opt) | number | Dimension to reduce |
["tensor/max", "@entity.qValues"]number | tensorArgs: 1–2 argumentstensor/min✨ PureMinimum value in tensor
| Parameter | Type | Description |
|---|---|---|
tensor | tensor | The tensor |
dim (opt) | number | Dimension to reduce |
["tensor/min", "@entity.distances"]number | tensorArgs: 1–2 argumentstensor/argmax✨ PureIndex of maximum value
| Parameter | Type | Description |
|---|---|---|
tensor | tensor | The tensor |
dim (opt) | number | Dimension to reduce |
["tensor/argmax", "@entity.qValues"] // Best action indexnumber | tensorArgs: 1–2 argumentstensor/norm✨ PureL2 norm of tensor
| Parameter | Type | Description |
|---|---|---|
tensor | tensor | The tensor |
p (opt) | number | Norm order (default 2) (default: 2) |
["tensor/norm", "@entity.gradient"]numberArgs: 1–2 argumentstensor/allInRange✨ PureCheck if all elements are within range [min, max]
| Parameter | Type | Description |
|---|---|---|
tensor | tensor | The tensor |
range | [number, number] | Range as [min, max] |
["tensor/allInRange", "@payload.input", [-1.0, 1.0]]true/falseArgs: 2 argumentstensor/outOfRangeIndices✨ PureGet indices of elements outside range
| Parameter | Type | Description |
|---|---|---|
tensor | tensor | The tensor |
range | [number, number] | Range as [min, max] |
["tensor/outOfRangeIndices", "@payload.input", [-1.0, 1.0]]number[]Args: 2 argumentstensor/clamp✨ PureClamp all elements to range [min, max]
| Parameter | Type | Description |
|---|---|---|
tensor | tensor | The tensor |
min | number | Minimum value |
max | number | Maximum value |
["tensor/clamp", "@entity.output", -10.0, 10.0]tensorArgs: 3 argumentstensor/clampPerDim✨ PureClamp each dimension to its specified range
| Parameter | Type | Description |
|---|---|---|
tensor | tensor | The tensor |
ranges | object | Per-dimension ranges { "0": {min, max}, ... } |
["tensor/clampPerDim", "@entity.rawOutput", "@entity.outputContract.ranges"]tensorArgs: 2 argumentstensor/outOfRangeDims✨ PureGet dimensions that exceed their specified ranges
| Parameter | Type | Description |
|---|---|---|
tensor | tensor | The tensor |
ranges | object | Per-dimension ranges { "0": {min, max}, ... } |
["tensor/outOfRangeDims", "@entity.rawOutput", "@entity.outputContract.ranges"]listArgs: 2 argumentstensor/toArray✨ PureConvert tensor to nested array
| Parameter | Type | Description |
|---|---|---|
tensor | tensor | The tensor |
["tensor/toArray", "@entity.output"]listArgs: 1 argumenttensor/toList✨ PureConvert 1D tensor to flat array
| Parameter | Type | Description |
|---|---|---|
tensor | tensor | The tensor (must be 1D) |
["tensor/toList", "@entity.output"]number[]Args: 1 argument🎯Training Operations
Training loops, loss functions, and optimization for neural networks.
19 operators
train/loop⚡ EffectExecute training loop with constraints
| Parameter | Type | Description |
|---|---|---|
module | nn/module | The neural network to train |
data | array | Training data (array of {input, target} or experiences) |
config | train/config | Training configuration with constraints |
["train/loop", "@entity.architecture", "@entity.buffer", "@entity.trainingConfig"]train/resultArgs: 3 argumentstrain/step⚡ EffectExecute single training step (forward, loss, backward, update)
| Parameter | Type | Description |
|---|---|---|
module | nn/module | The neural network |
input | tensor | Input tensor |
target | tensor | Target tensor |
config | train/config | Training configuration |
["train/step", "@entity.architecture", "@batch.input", "@batch.target", "@entity.config"]train/stepResultArgs: 4 argumentstrain/validate✨ PureValidate model on test cases, returns pass/fail metrics
| Parameter | Type | Description |
|---|---|---|
module | nn/module | The neural network |
testCases | array | Array of {input, expected, tolerance?} |
["train/validate", "@entity.architecture", "@entity.validationSet"]train/validationResultArgs: 2 argumentstrain/checkRegression✨ PureCheck if new model regresses on required invariants
| Parameter | Type | Description |
|---|---|---|
newModule | nn/module | Newly trained network |
oldModule | nn/module | Previous network |
invariants | array | Test cases that must not regress |
["train/checkRegression", "@payload.newWeights", "@entity.architecture", "@entity.requiredInvariants"]train/regressionResultArgs: 3 argumentstrain/checkConstraints✨ PureCheck if network weights satisfy all constraints
| Parameter | Type | Description |
|---|---|---|
module | nn/module | The neural network |
constraints | train/constraints | Constraint specification |
["train/checkConstraints", "@payload.newWeights", "@entity.constraints"]train/constraintResultArgs: 2 argumentstrain/checkWeightMagnitude✨ PureCheck if all weights are within magnitude limit
| Parameter | Type | Description |
|---|---|---|
module | nn/module | The neural network |
maxMagnitude | number | Maximum allowed weight magnitude |
["train/checkWeightMagnitude", "@entity.architecture", 10.0]true/falseArgs: 2 argumentstrain/checkForbiddenOutputs✨ PureCheck if model produces outputs in forbidden regions
| Parameter | Type | Description |
|---|---|---|
module | nn/module | The neural network |
testInputs | array | Inputs to test |
forbiddenRegions | array | Forbidden output regions |
["train/checkForbiddenOutputs", "@entity.architecture", "@entity.testInputs", "@entity.forbiddenOutputRegions"]train/forbiddenResultArgs: 3 argumentstrain/clipGradients⚡ EffectClip gradients to max norm (modifies in place)
| Parameter | Type | Description |
|---|---|---|
module | nn/module | The neural network |
maxNorm | number | Maximum gradient norm |
["train/clipGradients", "@entity.architecture", 1.0]numberArgs: 2 argumentstrain/getGradientNorm✨ PureGet current gradient norm
| Parameter | Type | Description |
|---|---|---|
module | nn/module | The neural network |
["train/getGradientNorm", "@entity.architecture"]numberArgs: 1 argumenttrain/clipWeights⚡ EffectClip weights to max magnitude (modifies in place)
| Parameter | Type | Description |
|---|---|---|
module | nn/module | The neural network |
maxMagnitude | number | Maximum weight magnitude |
["train/clipWeights", "@entity.architecture", 10.0]nothingArgs: 2 argumentstrain/getMaxWeightMagnitude✨ PureGet maximum weight magnitude in network
| Parameter | Type | Description |
|---|---|---|
module | nn/module | The neural network |
["train/getMaxWeightMagnitude", "@entity.architecture"]numberArgs: 1 argumenttrain/mse✨ PureMean squared error loss
| Parameter | Type | Description |
|---|---|---|
predicted | tensor | Predicted values |
target | tensor | Target values |
["train/mse", "@entity.output", "@batch.target"]numberArgs: 2 argumentstrain/crossEntropy✨ PureCross-entropy loss for classification
| Parameter | Type | Description |
|---|---|---|
logits | tensor | Raw model outputs (logits) |
labels | tensor | Target class labels |
["train/crossEntropy", "@entity.logits", "@batch.labels"]numberArgs: 2 argumentstrain/huber✨ PureHuber loss (smooth L1, robust to outliers)
| Parameter | Type | Description |
|---|---|---|
predicted | tensor | Predicted values |
target | tensor | Target values |
delta (opt) | number | Threshold for quadratic vs linear (default: 1) |
["train/huber", "@entity.qValues", "@batch.targets", 1.0]numberArgs: 2–3 argumentstrain/sgd⚡ EffectStochastic gradient descent optimizer step
| Parameter | Type | Description |
|---|---|---|
module | nn/module | The neural network |
lr | number | Learning rate |
momentum (opt) | number | Momentum factor (default: 0) |
["train/sgd", "@entity.architecture", 0.01, 0.9]nothingArgs: 2–3 argumentstrain/adam⚡ EffectAdam optimizer step
| Parameter | Type | Description |
|---|---|---|
module | nn/module | The neural network |
lr | number | Learning rate |
beta1 (opt) | number | First moment decay (default: 0.9) |
beta2 (opt) | number | Second moment decay (default: 0.999) |
["train/adam", "@entity.architecture", 0.001]nothingArgs: 2–4 argumentstrain/sampleBatch✨ PureSample random batch from experience buffer
| Parameter | Type | Description |
|---|---|---|
buffer | array | Experience buffer |
batchSize | number | Number of samples |
["train/sampleBatch", "@entity.experienceBuffer", 32]listArgs: 2 argumentstrain/computeReturns✨ PureCompute discounted returns from rewards
| Parameter | Type | Description |
|---|---|---|
rewards | array | Array of rewards |
gamma | number | Discount factor |
["train/computeReturns", "@episode.rewards", 0.99]tensorArgs: 2 argumentstrain/computeAdvantages✨ PureCompute GAE advantages for policy gradient
| Parameter | Type | Description |
|---|---|---|
rewards | array | Array of rewards |
values | tensor | Value estimates |
config | object | Config with gamma, lambda |
["train/computeAdvantages", "@episode.rewards", "@episode.values", { "gamma": 0.99, "lambda": 0.95 }]tensorArgs: 3 arguments🎲Probabilistic Programming
Distribution sampling, Bayesian inference via rejection sampling, and statistical summaries.
16 operators
prob/seed⚡ EffectSet seeded PRNG for deterministic probabilistic sampling
| Parameter | Type | Description |
|---|---|---|
n | number | Seed value (integer) |
["prob/seed", 42]nothingArgs: 1 argumentprob/flip✨ PureBernoulli trial: returns true with probability p
| Parameter | Type | Description |
|---|---|---|
p | number | Probability of true (0 to 1) |
["prob/flip", 0.5] // => true or false with equal probabilitytrue/falseArgs: 1 argumentprob/gaussian✨ PureSample from a Gaussian (normal) distribution
| Parameter | Type | Description |
|---|---|---|
mu | number | Mean |
sigma | number | Standard deviation |
["prob/gaussian", 0, 1] // => standard normal samplenumberArgs: 2 argumentsprob/uniform✨ PureSample from a uniform distribution [lo, hi)
| Parameter | Type | Description |
|---|---|---|
lo | number | Lower bound (inclusive) |
hi | number | Upper bound (exclusive) |
["prob/uniform", 0, 10] // => number in [0, 10)numberArgs: 2 argumentsprob/beta✨ PureSample from a Beta(alpha, beta) distribution
| Parameter | Type | Description |
|---|---|---|
alpha | number | Alpha shape parameter (> 0) |
beta | number | Beta shape parameter (> 0) |
["prob/beta", 2, 5] // => number in [0, 1], mean ~ 0.286numberArgs: 2 argumentsprob/categorical✨ PureWeighted random selection from items
| Parameter | Type | Description |
|---|---|---|
items | array | Array of items to choose from |
weights | number[] | Array of weights (same length as items) |
["prob/categorical", ["a", "b", "c"], [1, 2, 1]] // => "b" most likelyany valueArgs: 2 argumentsprob/poisson✨ PureSample from a Poisson distribution
| Parameter | Type | Description |
|---|---|---|
lambda | number | Rate parameter (> 0) |
["prob/poisson", 4] // => non-negative integer, mean ~ 4numberArgs: 1 argumentprob/condition⚡ EffectMark current sample as rejected if predicate is false
| Parameter | Type | Description |
|---|---|---|
predicate | boolean | Condition that must hold |
["prob/condition", [">", "@entity.x", 0]]nothingArgs: 1 argumentprob/sample✨ PureEvaluate an expression n times and collect results
| Parameter | Type | Description |
|---|---|---|
n | number | Number of samples |
expr | SExpr | Expression to evaluate (lazy) |
["prob/sample", 1000, ["prob/flip", 0.5]] // => array of booleanslistArgs: 2 argumentsprob/posterior✨ PureRejection sampling: returns accepted query values
| Parameter | Type | Description |
|---|---|---|
model | SExpr | Model expression (lazy, may call set/condition) |
evidence | SExpr | Evidence expression (lazy, boolean) |
query | SExpr | Query expression (lazy, value to collect) |
n | number | Number of samples to attempt |
["prob/posterior", model, evidence, query, 5000]listArgs: 4 argumentsprob/infer✨ PureLike posterior but returns {mean, variance, samples, acceptRate}
| Parameter | Type | Description |
|---|---|---|
model | SExpr | Model expression (lazy) |
evidence | SExpr | Evidence expression (lazy, boolean) |
query | SExpr | Query expression (lazy) |
n | number | Number of samples to attempt |
["prob/infer", model, evidence, query, 5000]objectArgs: 4 argumentsprob/expected-value✨ PureMean of numeric samples
| Parameter | Type | Description |
|---|---|---|
samples | number[] | Array of numeric samples |
["prob/expected-value", [2, 4, 6, 8]] // => 5numberArgs: 1 argumentprob/variance✨ PurePopulation variance of numeric samples
| Parameter | Type | Description |
|---|---|---|
samples | number[] | Array of numeric samples |
["prob/variance", [2, 4, 4, 4, 5, 5, 7, 9]] // => 4numberArgs: 1 argumentprob/histogram✨ PureBin numeric samples into a histogram
| Parameter | Type | Description |
|---|---|---|
samples | number[] | Array of numeric samples |
bins | number | Number of bins |
["prob/histogram", [1, 2, 3, 4, 5], 2] // => {binEdges, counts}objectArgs: 2 argumentsprob/percentile✨ PureGet the p-th percentile (0-100) from samples
| Parameter | Type | Description |
|---|---|---|
samples | number[] | Array of numeric samples |
p | number | Percentile (0 to 100) |
["prob/percentile", [1, 2, 3, 4, 5], 50] // => 3numberArgs: 2 argumentsprob/credible-interval✨ PureCompute symmetric credible interval from samples
| Parameter | Type | Description |
|---|---|---|
samples | number[] | Array of numeric samples |
alpha | number | Significance level (e.g., 0.05 for 95% interval) |
["prob/credible-interval", samples, 0.05] // => [lo, hi]listArgs: 2 arguments