next up previous contents
Next: The define Statement Up: Statements Previous: The Assignment   Contents

The choose Statement

$$ Choose-Statement ::= "choose" Variable "in" Expression ";" .

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; some may fail while others may be processed successfully, and the results can be different.

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:


next up previous contents
Next: The define Statement Up: Statements Previous: The Assignment   Contents
Bjoern Beutel