Previous Up Next

25.3.6  Breaking out of loop

The break command exits a loop without finishing it.

Example

Define a program:

testbreak(a,b):={ local r; while (true) { if (b==0) { break; } r:=irem(a,b); a:=b; b:=r; } return a; }

Then:

testbreak(4,0)
     
4           

since the while loop is interrupted when b is 0 and a is 4.


Previous Up Next