Next: Define, Previous: Break, Up: Statements
choose
Statement
The choose
statement chooses an element of a list. Its format
is:
choose $var in expr;
For every element in the list expr a rule path is created; in this
rule path the element is stored in the variable $var. Thus the
number of rule paths can multiply. If, for example, expr has the
value <A, B, C>
, the currently processed rule path has three
continuations: In the first one $var has the value A
, in
the second one it has the value B
and in the third one it has the
value C
. The three paths behave independently from now on.
The choose
statement can also be used for records. In that case, the
variable $var gets a different attribute name of the record
expr in each path.
The choose
statement also works for numbers: