Skip to content

Core

Utilities for working with objects and arrays.

Shape and inspect data

  • KEYS(coll) → list of keys/indices. Lists return indices [0,1,...]. Errors on non list/object.
  • VALUES(obj) → list of values from an object. Errors if not an object.
  • ENTRIES(obj) → list of { key, value } pairs. Errors if not an object.
  • GET(obj, key[, default]) → value at key or default when missing. Errors if not an object.

Run it: KEYS/VALUES/ENTRIES example.

Update collections immutably

  • PUT(coll, key, value) → new list/object with the entry added or replaced. List indexes must be within 0..size (append when equal to size).
  • DELETE(coll, key) → remove an entry by key/index. Errors if out of bounds or unsupported type.
  • APPEND(list, value) / PREPEND(list, value) → new lists with value at the end/start.

Run it: PUT/DELETE example and APPEND/PREPEND/COLLECT example.

Walk trees

  • WALK(tree) → sequence describing each node: path, key, value, depth, isLeaf. Works on objects and lists; other values yield a single leaf entry.
  • Combine with COLLECT to materialize the sequence; use MAP/FILTER to inspect paths.

Run it: WALK example.

Normalize iterables

  • COLLECT(iterable) → list from a sequence/iterable. Errors on unsupported types.
  • IS_OBJECT(x) → boolean indicating object-ness (maps only).
  • LISTIFY(x)[] for null, list as-is, or [object]. Errors on unsupported types.

Run it: APPEND/PREPEND/COLLECT example. Run it: LISTIFY/GET example.

Side effects

  • PRINT(...args) → writes to stdout, returns null. Use in CLI/runtime environments; not demonstrated in the playground because browser consoles do not display the call reliably.