Skip to content

Operators

OperatorDescriptionExample
+Addition / string concatenation10 + 313
-Subtraction10 - 37
*Multiplication10 * 330
/Division10 / 33.333...
%Modulo (remainder)10 % 31
- (unary)Negation-10
+ (unary)Identity+10

Decimal arithmetic works as expected:

5.5 / 2.0; // 2.75

The + operator also concatenates strings:

"Hello" + ", " + "World!"; // "Hello, World!"
  • + concatenates two Strings, adds two Numbers, or transposes an Event by a Number (semitones)
  • - subtracts two Numbers, or transposes an Event down by a Number
  • *, /, % work on Numbers only
// Event transposition (inside pattern callbacks / schedulers)
event + 7; // transpose up a fifth
event - 12; // transpose down an octave
// Direct note arithmetic is a type error
C4 + 2; // type error — use pattern combinators for transposition

NUL does not propagate through arithmetic — using NUL as an operand is a type error.

NUL + 1; // type error
5 * NUL; // type error

All comparison operators return a boolean (true or false).

OperatorDescriptionExample
==Equal5 == 5true
!=Not equal5 != 3true
<Less than3 < 5true
>Greater than5 > 3true
<=Less than or equal5 <= 5true
>=Greater than or equal5 >= 3true

String comparison is also supported:

"apple" == "apple"; // true

Equality (==, !=) works across types in two cases:

  • Note ↔ Number — compared by MIDI value
  • NUL ↔ anythingNUL == NUL is true; NUL equals nothing else
C4 == 60; // true — Note compared by MIDI value
D4 != 62; // false
NUL == NUL; // true
NUL == 0; // false — NUL is not zero
NUL == false; // false — NUL is not false

Ordering operators (<, >, <=, >=) compare Number, Note, and Event values — all coerce to their numeric (f64) representation:

D4 > C4; // true — 62 > 60
A4 >= 69; // true

NUL can be tested for equality but not ordered:

NUL == NUL; // true
5 != NUL; // true
NUL < 1; // type error — NUL has no ordering
OperatorDescriptionExample
&&Logical AND (short-circuit)true && falsefalse
||Logical OR (short-circuit)true || falsetrue
!Logical NOT!truefalse

Short-circuit evaluation means && stops at the first false and || stops at the first true:

let val = 7;
val > 5 && val < 10; // true

Logical operators require Boolean operands — there is no truthy coercion. See Truthiness for where truthiness applies.

true && 0; // type error — 0 is a Number, not a Boolean
!NUL; // type error — NUL is not a Boolean

These combine an arithmetic operation with assignment. They follow the same type rules as their arithmetic counterparts.

OperatorEquivalent
+=x = x + value
-=x = x - value
*=x = x * value
/=x = x / value
%=x = x % value
let count = 1;
count += 1; // 2
count *= 3; // 6

The << operator sends a pattern or value to a target — a track or an effect parameter.

melody << [C4 E4 G4 E4]; // send pattern to a MIDI track
echo.Feedback << 0.6; // set an effect parameter
filter.Cutoff << Sine(2).range_exp(400, 4000); // modulate with a signal

For full details see MIDI Tracks, Effects, Routing, and Signals & Automation.

The >> operator routes audio from one node to another. Without explicit routing, tracks go to master automatically.

kicks >> drum_bus;
snares >> drum_bus;
drum_bus >> master;

See Routing for submix buses and routing chains.

The & operator creates a reference to an array, dictionary, or class instance, enabling shared mutable state. It only works on identifiers — not arbitrary expressions — and only on compound types (using & on a primitive like a Number or String is a type error).

References auto-dereference transparently: field access, method calls, and operators work the same whether you hold a value or a reference.

let nums = #[1, 2, 3];
let nums_ref = &nums;
nums_ref.push(4);
PRINT nums; // [1, 2, 3, 4] — both see the change

See References for details.

From highest to lowest:

  1. Unary (-, +, !)
  2. Multiplicative (*, /, %)
  3. Additive (+, -)
  4. Comparison (<, >, <=, >=)
  5. Equality (==, !=)
  6. Logical AND (&&)
  7. Logical OR (||)

<< and >> are statement-level operators (not part of expression precedence). They bind an entire right-hand expression to a target.

Parentheses override precedence:

2 + 3 * 4; // 14 (multiplication first)
(2 + 3) * 4; // 20 (parentheses first)

Quick reference for which types work with which operators.

OperatorNumber ↔ NumberString ↔ StringNote ↔ NumberEvent ↔ NumberNUL as operand
+NumberStringerrorEventerror
-NumbererrorerrorEventerror
* / %Numbererrorerrorerrorerror
== !=BooleanBooleanBooleanerrorBoolean
< > <= >=BooleanerrorBooleanBooleanerror
&& || !errorerrorerrorerrorerror
  • Logical operators accept only Boolean ↔ Boolean.
  • & accepts only identifiers bound to Array, Dict, or class Instance.
  • << accepts Track/Parameter on the left; Pattern/Signal/Value on the right.
  • >> accepts AudioTrack on both sides (or master on the right).