Skip to content

Control Flow

Andrew Johnson edited this page Nov 13, 2024 · 7 revisions

LSTS offers a standard assortment of control flow operators.

If Expressions

Ternary if can be used in expression position.

print(if condition then "true" else "false")

Match Expressions

Match expressions permit destructuring of data in a controlled intentional manner.

print(match xyz {
   XY { x-field: X { i } } => i;
   XYZ { z-field: Z { i } } => i;
})

While Loops

While loops are a common feature available in most languages.

while x < 2 { x += 1; }

For Iteration

For loops allow the programmer to traverse through iterable data.

for(x in [1,2,3]) { print(x); }

Clone this wiki locally