STRUCTURE | DEFINITION |
if |
If x is true then return y else return z.eg:
|
if-else |
The if-else/else-if statement. Subject to the condition
branch the statement will return either the value of the consequent or
the alternative branch. eg:
|
switch |
The first true case condition that is encountered will
determine the result of the switch. If none of the case
conditions hold true, the default action is assumed as
the final return value. This is sometimes also known as
a multi-way branch mechanism.
eg:
switch { case x > (y + z) : 2 * x / abs(y - z); case x < 3 : sin(x + y); default : 1 + x; } |
while |
The structure will repeatedly evaluate the internal
statement(s) 'while' the condition is true. The final
statement in the final iteration will be used as the
return value of the loop.
eg:
while ((x -= 1) > 0) { y := x + z; w := u + y; } |
repeat/until |
The structure will repeatedly evaluate the internal
statement(s) 'until' the condition is true. The final
statement in the final iteration will be used as the
return value of the loop.
eg:
repeat y := x + z; w := u + y; until ((x += 1) > 100) |
for |
The structure will repeatedly evaluate the internal
statement(s) while the condition is true. On each loop
iteration, an 'incrementing' expression is evaluated.
The conditional is mandatory whereas the initialiser
and incrementing expressions are optional.
eg:
for (var x := 0; (x < n) and (x != y); x += 1) { y := y + x / 2 - z; w := u + y; } |
break/break[] |
Break terminates the execution of the nearest enclosed
loop, allowing for the execution to continue on external
to the loop. The default break statement will set the
return value of the loop to NaN, where as the return
based form will set the value to that of the break
expression.
eg:
while ((i += 1) < 10) { if (i < 5) j -= i + 2; else if (i % 2 == 0) break; else break[2i + 3]; } |
continue |
Continue results in the remaining portion of the nearest
enclosing loop body to be skipped.
eg:
for (var i := 0; i < 10; i += 1) { if (i < 5) continue; j -= i + 2; } |
return |
Return immediately from within the current expression.
With the option of passing back a variable number of
values (scalar, vector or string). eg:
|
?: |
Ternary conditional statement, similar to that of the
above denoted if-statement.
eg:
|
~ |
Evaluate each sub-expression, then return as the result
the value of the last sub-expression. This is sometimes
known as multiple sequence point evaluation.
eg:
~(i := x + 1, j := y / z, k := sin(w/u)) == (sin(w/u))) ~{i := x + 1; j := y / z; k := sin(w/u)} == (sin(w/u))) |
[*] |
Evaluate any consequent for which its case statement is
true. The return value will be either zero or the result
of the last consequent to have been evaluated.
eg:
[*] { case (x + 1) > (y - 2) : x := z / 2 + sin(y / pi); case (x + 2) < abs(y + 3) : w / 4 + min(5y,9); case (x + 3) == (y * 4) : y := abs(z / 6) + 7y; } |
[] |
The vector size operator returns the size of the vector
being actioned.
eg:
|
Note: In the tables above, the symbols x, y, z, w, u and v where appropriate may represent any of one the following:
2 + x /vec[3])