Compute functions reference
Every tag in the <compute> sub-language, grouped by what it
does. The Compute Language section covers how they fit
together.
Reading the signature column: int|str|list means any of the three, … means any
number of children, ? marks an optional attribute, 1 means exactly one child
expression, and — means the tag yields no value of its own. Slot tags — the children
that carry a job title — are shown by name in the signature of the tag that owns them.
Literals and references
In depth: The compute sub-language
| Tag | Signature | What it does |
|---|---|---|
<int> | v= → int | An integer literal (attribute v) |
<str> | v= → str | A string literal (attribute v) |
<list> | v= or int… → list | A literal list of ints, or one built from nested expressions |
<field> | name= → str | The value of a sequence in scope — the same as ${{X}} |
<var> | name= → int|str|list | A value bound by <let> |
<let> | name= + 1 → — | Name an intermediate result for sibling tags |
<current> | → int|str | The current iteration item (inside <do>) |
<current_index> | → int | The current item's index, counting from zero |
<acc> | → int|str|list | The accumulator (inside <reduce>) |
Lists and iteration
In depth: Lists & iteration
| Tag | Signature | What it does |
|---|---|---|
<each> | <over> <do> → list | Transform every element → a new list |
<reduce> | <over> <init> <do> → int|str|list | Fold a list into one value (<acc>) |
<join> | list + sep=? → str | List → string (attribute sep) |
<at> | <in> <index> + default=? → int|str | An element by index (attribute default) |
<length> | str|list → int | Length of a string or a list |
Arithmetic
In depth: Arithmetic
| Tag | Signature | What it does |
|---|---|---|
<add> | int… → int | Sum of all children (empty → 0) |
<subtract> | int… → int | First minus the sum of the rest |
<multiply> | int… → int | Product (empty → 1) |
<divide> | int int → int | Integer division toward −∞ (2 children) |
<mod> | int int → int | Euclidean remainder, always ≥ 0 |
Strings, encoding, formatting
In depth: Strings & formatting
| Tag | Signature | What it does |
|---|---|---|
<encode> | str(1) + as= → str | Character → number (base36/ascii/hex/…) |
<to_number> | str → int | Digit string → integer |
<pad> | int|str + width= fill=? → str | Pad on the left to a given width (width, fill) |
<concat> | int|str… → str | Join several parts into one string |
<upper> / <lower> | str → str | Upper / lower case |
<capitalize> | str → str | Uppercase the first letter |
<title> | str → str | Uppercase the first letter of every word |
<mask> | str + pattern= → str | Display mask (pattern: x/w/*) |
<slice> | str + from= to=? → str | Substring [from, to) |
<replace> | str + from= to= → str | Replace every occurrence (from, to) |
<trim> | str → str | Strip surrounding whitespace |
<group> | str + size=? sep=? → str | Group digits from the right (size, sep) |
Conditionals
In depth: Conditionals
| Tag | Signature | What it does |
|---|---|---|
<choose> | <when>… <otherwise> → int|str|list | Choose a branch; requires an <otherwise> |
<when> | <test> <then> → — | A branch: <test> predicate + <then> value |
<otherwise> | 1 → int|str|list | The "else" branch (required) |
<test> | 1 → yes|no | Holds one predicate, yields yes or no |
<then> | 1 → int|str|list | The value of the matched branch |
<equals> | int|str ×2 → yes|no | Predicate: two ints are equal |
<greater_than> | int int → yes|no | Predicate: A > B |
<less_than> | int int → yes|no | Predicate: A < B |
<is_digit> | str(1) → yes|no | Predicate: a character is a digit 0–9 |
Wrappers and special
| Tag | Signature | What it does |
|---|---|---|
<over> | 1 → str|list | The input list for <each> / <reduce> |
<do> | 1 → int|str|list | The iteration body for <each> / <reduce> |
<init> | 1 → int|str|list | The accumulator's starting value for <reduce> |
<in> | 1 → list | The list for <at> |
<index> | 1 → int | The item index for <at> |
<result> | 1 → int|str|list | The final value of a <compute> |
<valid> | 1 → — | Reject and retry until the value is valid |
See the Compute Language section for worked examples.