ReferenceControlArcReferenceOperators

Operators

Arc operator reference for arithmetic, comparison, logical, assignment, and flow operators

Arithmetic operators

Table

Operator Name Example Result
+ Addition 3 + 2 5
- Subtraction 5 - 2 3
- (unary) Negation -5 -5
* Multiplication 3 * 4 12
/ Division 10 / 3 3 (integer) or 3.333... (float)
% Modulo 10 % 3 1
^ Exponentiation 2 ^ 8 256

Division behavior

Integer division truncates toward zero:

positive := 10 / 3 // 3 (not 3.333)
negative := -10 / 3 // -3

Float division produces a float:

result := 10.0 / 3.0 // 3.333...

Exponentiation

power := 2 ^ 8 // 256
square := 5 ^ 2 // 25
cube := 2.0 ^ 3 // 8.0

Exponentiation is right-associative:

result := 2 ^ 3 ^ 2 // 2 ^ (3 ^ 2) = 2 ^ 9 = 512

Comparison operators

All comparisons return bool (true or false).

Table

Operator Name Example Result
== Equal 3 == 5 false
!= Not equal 3 != 5 true
< Less than 3 < 5 true
> Greater than 3 > 5 false
<= Less than or equal 3 <= 5 true
>= Greater than or equal 3 >= 5 false
in_range := pressure >= 100 and pressure <= 500

Logical operators

Logical operators require bool operands, use short-circuit evaluation, and return bool.

Table

Operator Name Example Result
and Logical AND true and false false
or Logical OR false or true true
not Logical NOT not true false

Short-circuit evaluation

  • and: If the left operand is false, the right operand is not evaluated
  • or: If the left operand is true, the right operand is not evaluated
// Safe: division only happens if b != 0
safe := b != 0 and (a / b) > 10

Assignment operators

Table

Operator Name Example Equivalent
= Assignment x = 5
+= Add and assign x += 5 x = x + 5
-= Subtract and assign x -= 5 x = x - 5
*= Multiply and assign x *= 2 x = x * 2
/= Divide and assign x /= 2 x = x / 2
%= Modulo and assign x %= 3 x = x % 3

Variable declaration operators

Table

Operator Name Example
:= Local variable declaration x := 5
$= Stateful variable declaration count $= 0

Precedence table

Operators listed from highest to lowest precedence.

Table

Precedence Operators Associativity
1 (highest) ^ Right
2 - (unary), not Right
3 *, /, % Left
4 +, - Left
5 <, >, <=, >= Left
6 ==, != Left
7 and Left
8 (lowest) or Left

Precedence examples

// Exponentiation binds tighter than unary minus
-2 ^ 2 // -(2 ^ 2) = -4; write (-2) ^ 2 for 4

// Multiplication before addition
2 + 3 * 4 // 2 + (3 * 4) = 14

// Comparison before logical
a > 5 and b < 10 // (a > 5) and (b < 10)

// Use parentheses for clarity
(a + b) * c

Series operators

Arithmetic, comparison, and logical operators work element-wise on series.

data := [1.0, 2.0, 3.0]

// Series with scalar
scaled := data * 2.0 // [2.0, 4.0, 6.0]

// Series with series (must be equal length)
sum := data + [4.0, 5.0, 6.0] // [5.0, 7.0, 9.0]

// Comparison returns series bool
mask := data > 2.0 // [false, false, true]

// Logical operators apply element-wise to series bool
inverted := not mask // [true, true, false]

String operators

Table

Operator Operation Example
+ Concatenation "Hello" + " World"
== Equality name == "test"
!= Inequality name != ""
msg := "Hello"
greeting := msg + " World" // "Hello World"
is_empty := msg == "" // false

Truthiness

Contexts that test a value accept more than bool: the => conditional flow operator, if conditions, and for conditions.

Table

Type Truthy when
bool true
numeric Non-zero
str Non-empty