The basic way to control the execution of code is with the if expression. Such an expression typically has the form
if X then Y else Zand is evaluated as follows. First X is evaluated. If the result is true, then the value of Y is provided, and if the result is false, then the value of Z is provided. An error is signalled if the value of X is anything but true or false.
i1 : (-4 .. 4) / |
The else clause may be omitted from an if expression. In that case, if value of the predicate X is false, then null is provided as the value of the if expression.
i2 : (-4 .. 4) / |
There are a variety of predicate functions (such as <, used above) that yield true or false and can be used as the predicate in an if expression. For a list, see Boolean. Boolean results may be combined with not, and, and or.