soma.cell

Habits from Python / TypeScript that soma check now redirects

Pitfall 21 of writing Soma, the programming language: a habit from another language, or a rule that surprises, with what the Soma compiler answers and the form to write.

if x == null { }          // error: 'null' does not exist — Soma's null is `()`; also `x ?? default`
xs.includes(v)            // error: no method 'includes' — in Soma: contains(xs, v)
rows.push(o)              // warning: result discarded — push returns a NEW list: rows = push(rows, o)
[a[0]] + rest             // warning: `+` ADDS numeric lists element-wise — concat(a, b) / push(xs, x)
let t = lefft + 1         // error: undefined variable 'lefft' (did you mean 'left'?)

Everyday collection builtins: contains(list|map|string, x), slice(xs, start, end?) (negative indexes count from the end), keys(m) / values(m) / entries(m), sort_by(rows, "field") or sort_by(rows, r => [0 - r.total, r.name], "desc"?) (stable; a list key sorts on several keys), round(x, digits).