User Guide
• Until a counter variable value exceeds a limit (for/from loop)
• For each operand of an expression (for/in loop)
• Until a boolean condition does not hold (while loop)
for/from Loop
The for/from loop statement repeats a statement sequence until a counter
variable value exceeds a limit.
Syntax
The for/from loop has the following syntax.
for counter from initial by increment to final do
statement_sequence
end do;
>
The behavior of the for/from loop is:
1. Assign the initial value to the name counter.
2. Compare the value of counter to the value of final. If the counter value
exceeds the final value, exit the loop. (This is the loop bound test.)
3. Execute the statement_sequence.
4. Increment the counter value by the value of increment.
5. Repeat steps 2 to 4, until Maple exits the loop.
The from, by, and to clauses are optional and can be in any order between
the for clause and the do keyword.
Table 8.1 lists the default clause values.
326 • 8 Basic Programming