Dictionaries
Dictionary Arithmetic
Arithmetic operators (+, -, *, %) applied to two dictionaries operate key-by-key when the keys match — and automatically extend to the union of all keys when the key sets differ.
Matching Keys
When both dictionaries share the same key set, arithmetic is applied value-by-value across corresponding entries:
d1:`a`b`c!1 2 3
d2:`a`b`c!10 20 30
d1+d2 / `a`b`c!11 22 33
d1*d2 / `a`b`c!10 40 90
d2-d1 / `a`b`c!9 18 27Mismatched Keys — Union Behaviour
When the key sets differ, q takes the union of both key sets. Keys present in only one dictionary keep their value; keys present in both get the arithmetic result:
d3:`a`b!1 2
d4:`b`c!20 30
d3+d4 / `a`b`c!1 22 30a (only in d3) → 1, c (only in d4) → 30, b (in both) → 2 + 20 = 22.
Arithmetic Against a Scalar
A scalar on one side is broadcast across every value in the dictionary — the same scalar extension that applies to lists:
prices:`AAPL`MSFT`GOOG!182.5 410.1 142.8
prices * 1.1 / apply 10% mark-up to all pricesComparison Operators
Comparisons (=, <, >, <>) return a boolean dictionary — the same key set, with 0b/1b values:
d:`a`b`c!1 2 3
d>1 / `a`b`c!011b
where d>1 / `b`c — keys where condition holdswhere on a boolean dictionary returns keys (not integer positions), which makes condition-based filtering on dictionaries concise and readable. This is the basis for value-based filtering — see the Lookup By Value section for more patterns.