Skip to content

Operators and access

These expression operators cover constructed values and ordinary data carried by native wrappers. Opaque native operands retain explicit host contracts. Native set operators have a separate host-dependent contract. All operations share the request’s finite work, result and nesting limits.

From strongest to weakest, the common expression reader uses:

Level Forms
Access and update a[i], a[i, j], tuple.1, row.field, with
Optional fallback default
Prefix not, unary +, unary -
Multiplicative *, /, div, mod
Additive +, -
Integer range ..
String concatenation ++
Ordering and membership <, <=, >, >=, in
Equality ==, =, !=
Conjunction and, /\
Disjunction or, \/

Binary operators at the same level associate left to right. Pipelines apply to the completed expression; group a pipeline result before using it as an operand. Native union, intersect and except have equal precedence and associate left to right between native pipeline operands. Parentheses make their grouping explicit. See the expression guide.

+number, -number, left + right, left - right -> number

Accept signed 64-bit integers and finite floats. -3 + 5 returns 2. Integer results are checked for overflow, including negating the minimum integer. A mixed integer/float calculation requires exact binary64 representation of the integer. There is no string-to-number coercion.

left * right, left / right, left div right, left mod right

Multiplication accepts integers or finite floats. / returns a float, including for integer operands: 5 / 2 returns 2.5. div and mod require integers: -5 div 2 returns -2, and -5 mod 2 returns -1. Division truncates toward zero; the remainder has the dividend’s sign. Zero divisors, integer overflow, nonfinite float results and nonzero float results underflowing to zero fail. Mixed numeric multiplication/division requires exactly representable integers. See checked arithmetic.

lower..upper -> set<int>

Construct an inclusive ascending integer set. 2..4 contains 2, 3, 4 in that order; 4..2 is empty. Endpoints must be integers. The full range is eager and spends the request budget; it does not form an unbounded iterator.

left == right, left = right, left != right -> bool

= aliases == in expressions. Equality requires compatible underlying types; it does not coerce numbers or text. Arrays and tuples compare by position, sets by membership and dictionaries by key/value associations. Thus {1, 2} == {2, 1} is true. Keyed arrays also retain their typed axes and present cells. Two absences compare equal; absence differs from a present value. Declared optional types must remain compatible even when both values are absent. Ordinary lists, tuples, records, sets and dictionaries keep this admission when carried by a native wrapper. Deferred compatibility is checked only when the comparison executes, including pairs after an earlier unequal value. Opaque native leaves retain the host’s exact identity contract. Structural collection-key identity keeps distinct value kinds separate. See collection equality.

left < right, left <= right, left > right, left >= right -> bool

Compare present integers and finite floats. 2 < 3 returns true. Mixed integer/float comparisons require an exactly representable integer. Strings, nominal members, Booleans, absence and collection operands fail. String and nominal ordering are available through sort/extrema instead. These numeric expressions do not use the structural order used by set and dictionary-key sorting. Native wrappers around ordinary data follow the same numeric rule; wrapping [1] and [2] natively does not admit [1] < [2]. Genuinely native operands without an ordinary data view retain their explicit domain comparison.

element in set -> bool

Test structural membership in a constructed set: {1, 2} in {{2, 1}} returns true. An empty compatible set returns false. A strict scalar or nominal set requires its declared element type; a general set accepts constructed values. Arrays and dictionaries are not membership operands; use has_key for stored entries. With host support, item in seen also tests a native identity set, preserving owner identity. The in token in a comprehension instead introduces its generator source.

not condition, left and right, left /\ right, left or right, left \/ right

Constructed operands must be known Booleans. and skips the right operand after false; or skips it after true. not false is true. Preflight still checks both operands. /\ aliases and, and \/ aliases or. Native predicates can also return unknown: negation preserves it, and a decisive false conjunction or true disjunction can settle it. Native filter keeps known true; a native match guard or path target with unresolved truth fails. See predicate truth.

array[index], array[i, j], dictionary[key], row.field, tuple.1

Read one value. Positional arrays and tuples use one-based positions; [4, 9][2] returns 9, and (4, 9).1 returns 4. a[i, j] abbreviates a[(i, j)] for a keyed array. Dictionary keys can be constructed values; dot access names a static string field. Keyed access retains declared key types, rank and missing cells. A missing position, field or cell fails. lookup supplies optional access. A native field keeps the host’s value and source ownership; it does not implicitly render it. See literals and access.

record with {field: replacement, ...} -> record

Return a record with existing fields replaced. {"limit": 8} with {limit: 12} returns {"limit": 12}. Evaluate the base once, then replacements in written order in surrounding scope. Preserve field order, retained contracts, native children and aliases. Missing or duplicate targets fail. This form does not insert or remove fields and does not update a general dictionary or keyed array. See record updates.

source | stage | stage

Apply stages left to right to a completed expression. [3, 1, 3] | unique | count returns 2. Explicit sources supply their own input; bare constructed filter/map/flat_map/count use the host’s immutable constructed input. Native stages use the host’s current native input and type rules. A scalar count cannot feed a collection stage. Tally returns a composable dictionary. The generator pipe in [x | x in source] is a separate comprehension delimiter. See constructed pipelines and native forms.