Operations and precedence

Numbat operators and other language constructs, ordered by precedence form high to low:

Operation / operatorSyntax
square, cube, …, , x⁻¹, …
factorialx!
exponentiationx^y, x**y
multiplication (implicit)x y (whitespace)
unary negation-x
divisionx per y
divisionx / y, x ÷ y
multiplication (explicit)x * y, x · y, x × y
subtractionx - y
additionx + y
comparisonsx < y, x <= y, x ≤ y, … x == y, x != y
logical negation!x
logical ‘and’x && y
logical ‘or’x || y
unit conversionx -> y, x → y, x ➞ y, x to y
conditionalsif x then y else z
reverse function callx |> f

Note that implicit multiplication has a higher precedence than division, i.e. 50 cm / 2 m will be parsed as 50 cm / (2 m).

Also, note that per-division has a higher precedence than /-division. This means 1 / meter per second will be parsed as 1 / (meter per second).

If in doubt, you can always look at the pretty-printing output (second line in the snippet below) to make sure that your input was parsed correctly:

>>> 1 / meter per second

  1 / (meter / second)

    = 1 s/m