{"path":"/sutl/guide/builtins","content":{"title":"3. Builtins","summary":"Arithmetic, comparison, truthiness, collections and conversions.","body":"[sUTL](/sutl) · [Guide](/sutl/guide) · [Reference](/sutl/reference) · [Examples](/sutl/examples)\n\nBuiltins are primitive operations supplied by the host interpreter. Dictionary\nform names the operation with `&`:\n\n```json\n{\n  \"&\": \"+\",\n  \"a\": 5,\n  \"b\": 2\n}\n```\n\nThe compact list form folds arguments from left to right:\n\n```json\n[\"&+\", 10, 3, 2]\n```\n\nThis evaluates to `15` for `+` and `5` if the operator is changed to `-`.\n\n## Arithmetic and strings\n\n`+` adds numbers or concatenates strings. Mixing a string and number returns\nnull. Multiplication is named `x`, not `*`, because `*` is the library path\nselector.\n\n```json\n[\"&+\", \"s\", \"UTL\"]\n```\n\nResult: `\"sUTL\"`.\n\n## Equality and comparison\n\nEquality is type-aware: `false` is not equal to `0`. Ordering comparisons\nrequire two numbers and return false for other types rather than using host\nlanguage coercion.\n\n## Truthiness and logic\n\nFalsey values are `false`, null, zero, the empty string, empty list, and empty\nmap. Everything else is truthy.\n\nThe logical builtins return booleans:\n\n```json\n[\"&&&\", true, {\"x\": 1}]\n```\n\nThe operation is called `&&`; adding the compact-form `&` prefix produces the\nslightly unusual spelling `\"&&&\"`.\n\n## Collection builtins\n\nCommon collection primitives include:\n\n- `len`, `head`, and `tail` for lists\n- `keys` and `values` for maps\n- `makemap` for converting key/value pairs into a map\n- `reduce` for iteration\n- `removekeys` and `quicksort` in the production Python implementation\n\nsUTL sorts `keys` and orders `values` by those sorted keys, providing\ndeterministic cross-host results.\n\n## Conversion and string builtins\n\n`type`, `string`, `number`, and `boolean` convert or describe MLSNBN values.\n`split`, `trim`, `pos`, `lower`, and `upper` provide basic string operations.\n\nNext: [Quoting and evaluation](/sutl/guide/quoting-and-evaluation).\n\n## Continue learning\n\n[Previous: 2. Paths](/sutl/guide/paths) · [Guide contents](/sutl/guide) · [Language reference](/sutl/reference)\n\n## Source\n\nAdapted from [the sUTL source material](https://github.com/emlynoregan/sutllang-site/blob/e59ecafd364848cd71a1d18ce74cdf67f2f69328/content/guide/03-builtins.md).\n\n[Back to sUTL](/sutl) · [Software & Agents](/topics/software-and-agents) · [All topics](/guide)","author":"Emlyn O'Regan"}}