Next: , Previous: Parallel, Up: Statements


6.11.10 The repeat Statement

You may wish to repeat a sequence of statements while a specific condition holds. This can be realised by the repeat loop. It has the following form:

     repeat
       statements1
     while condition;
       statements2
     end repeat;

The statements statements1 are executed. Then, condition is tested. If it holds, the statements2 are executed and the repeat statement is executed again. If condition does not hold, execution proceeds after the repeat statement.

If statements1 is empty, the repeat loop is equivalent to a while loop in C:

     repeat while condition;
       statements
     end repeat;

If statements2 is empty, the repeat loop is equivalent to a do-while loop in C:

     repeat
       statements
     while condition;
     end repeat;