Skip to content

Control Flow

If / Else

cond ? then : else is the expression form of if/else — it produces a value, so you can use it inline in an assignment, a function argument, or a return. Only the chosen branch is evaluated (lazy), so a side effect in the untaken branch never fires.

Ternary

It binds looser than every other operator (including && / ||), so a + b > 4 ? x : y parses as ((a + b) > 4) ? x : y, and a ? b : c ? d : e parses as a ? b : (c ? d : e).

While Loop

Tulpar supports both C-style for loops and for-each loops:

For Loops

match is a Rust-style pattern match. Unlike a C switch, it is an expression — it produces a value, so you can assign it directly. Each arm is pattern => body; _ is the catch-all wildcard. Arms support single literals, |-alternatives, and inclusive lo .. hi ranges.

Match as an expression

Patterns can match a set of values or a range. The subject is evaluated once, and the first matching arm wins:

Alternatives and ranges

match also works in statement position with block arms, and the subject may be any expression (int, string, or bool):

Statement-position match