[Next] [Prev] [Right] [Left] [Up] [Index] [Root]
The continue statement

The continue statement

The statement

> continue;

inside a while-statement or repeat-statement causes Magma to omit the rest of the statements within the loop and test the loop condition again. If the condition is true, execution proceeds from the beginning of the loop statements.

Within a for-loop, continue; causes Magma to omit the rest of the block of statements and go on to the next element of the domain.

If several loops are nested then the jump is with respect to the innermost enclosing loop.

In a for-statement nested inside another for-statement, the statement

> continue IDENTIFIER;

causes a jump to the condition of the for-loop whose loop identifier is the given identifier. This allows a jump with respect to a loop other than the innermost one.

The continue-statement should be carefully distinguished from the break-statement (see The break statement).

Example

> // product of the composite numbers from 2 to 50
> product := 1;
> for i in [2..50] do
for> if IsPrime(i) then
for|if> continue;
for|if> end if; 
for> product *:= i;
for> end for;
> print product;
49462674552307032732500869107626803200000000000
[Next] [Prev] [Right] [Left] [Up] [Index] [Root]