3. Builtins

Arithmetic, comparison, truthiness, collections and conversions.

sUTL · Guide · Reference · Examples

Builtins are primitive operations supplied by the host interpreter. Dictionary form names the operation with &:

{
  "&": "+",
  "a": 5,
  "b": 2
}

The compact list form folds arguments from left to right:

["&+", 10, 3, 2]

This evaluates to 15 for + and 5 if the operator is changed to -.

Arithmetic and strings

+ adds numbers or concatenates strings. Mixing a string and number returns null. Multiplication is named x, not *, because * is the library path selector.

["&+", "s", "UTL"]

Result: "sUTL".

Equality and comparison

Equality is type-aware: false is not equal to 0. Ordering comparisons require two numbers and return false for other types rather than using host language coercion.

Truthiness and logic

Falsey values are false, null, zero, the empty string, empty list, and empty map. Everything else is truthy.

The logical builtins return booleans:

["&&&", true, {"x": 1}]

The operation is called &&; adding the compact-form & prefix produces the slightly unusual spelling "&&&".

Collection builtins

Common collection primitives include:

sUTL sorts keys and orders values by those sorted keys, providing deterministic cross-host results.

Conversion and string builtins

type, string, number, and boolean convert or describe MLSNBN values. split, trim, pos, lower, and upper provide basic string operations.

Next: Quoting and evaluation.

Continue learning

Previous: 2. Paths · Guide contents · Language reference

Source

Adapted from the sUTL source material.

Back to sUTL · Software & Agents · All topics

View page as JSON