sUTL
Guide · 03 / 07

3. Builtins

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 -.

Interactive conformance example: JavaScript is required to edit and run it.

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".

Interactive conformance example: JavaScript is required to edit and run it.

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.

Interactive conformance example: JavaScript is required to edit and run it.

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 "&&&".

Interactive conformance example: JavaScript is required to edit and run it.

Collection builtins

Common collection primitives include:

  • len, head, and tail for lists
  • keys and values for maps
  • makemap for converting key/value pairs into a map
  • reduce for iteration
  • removekeys and quicksort in the production Python implementation

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

Interactive conformance example: JavaScript is required to edit and run it.

Conversion and string builtins

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

Interactive conformance example: JavaScript is required to edit and run it.

Next: Quoting and evaluation.