Like most programming languages, Mathics3 has common program-flow control statements for conditions, loops, etc.:
If[cond, pos, neg]True, and neg if it evaluates to False.Which[$cond_1$, $expr_1$, $cond_2$, $expr_2$, ...]True, $expr_2$ if $cond_2$ evaluates to True, etc.Do[expr, {i, max}]For[start, test, incr, body]True.While[test, body]True.Nest[f, expr, n]NestWhile[f, expr, test]True.FixedPoint[f, expr]If[2 < 3, a, b]
x = 3; Which[x < 2, a, x > 4, b, x < 5, c]
Compound statements can be entered with ;. The result of a compound expression is its last part or Null if it ends with a ;.
1; 2; 3
1; 2; 3;
Inside For, While, and Do loops, Break[] exits the loop, and Continue[] continues to the next iteration.
For[i = 1, i <= 5, i++, If[i == 4, Break[]]; Print[i]]