Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Operators and symbols

Infix operators

This list contains all the infix operators, an example of how the operator would be used, a short explanation, and its precedence. An operator with a higher precedence will be grouped before an operator with less precedence.

OperatorExampleExplanationPrecedence
ina in []Membership operator1
..0..10Range generation2
||true || falseLogic OR3
&&true && falseLogic AND4
>1 > 0“Greater” comparison5
>=1 >= 0“Greater or equal” comparison5
<1 < 0“Less” comparison5
<=1 <= 0“Less or equal” comparison5
/=9 /= 9Negated equality5
='a' = 'a'Equality5
^2 ^ 3Bitwise XOR6
&1 & 0Bitwise AND7
<<1 << 2Left shift8
>>8 >> 2Right shift8
-8 - 3Arithmetic substraction9
+1 + 1Arithmetic addition9
/1 / 2Arithmetic division10
%5 % 7Division remainder10
*5 * 7Arithmetic multiplication10
**2 ** 5Exponentiation11

Comparison order

All six comparison operators work between any two values and use the same total order as sorted. Different types are ordered as follows:

Bool < Char < Number < Symbol < String < Tuple < List < Set < Dictionary < Function < Range < Generator < Error.

Integers, floats, and fractions share numeric ordering. Comparisons use the exact stored value, without rounding integers or fractions to floats. Thus 1 = 1.0, but 1//10 < 0.1 because the float is slightly greater than one tenth. Positive and negative zero compare equal. Infinities bound finite numbers; negative NaNs sort before negative infinity and positive NaNs after positive infinity, with NaN bit patterns providing a deterministic order within each group.

Collections compare lexicographically, recursively using this order. Sets compare their sorted elements; dictionaries compare their sorted key/value pairs. Equal numeric values are also interchangeable as set elements and dictionary keys. Function and generator ordering can depend on identity within an execution; comparing a generator does not consume it.

For example, 0.5 < "cesar" and [0.5] < [1] are both true.

Prefix operators

This list contains all the prefix operators, an example of how the operator would be used, and a short explanation.

OperatorExampleExplanation
~~1Bitwise negation
!!falseLogic negation
--5Additive inverse