Loops/Break: Difference between revisions
Content added Content deleted
imported>Brie (Add Nu) |
(→{{header|RPL}}: using the handling error mechanism) |
||
Line 3,248: | Line 3,248: | ||
=={{header|RPL}}== |
=={{header|RPL}}== |
||
RPL does not have any <code>BREAK</code> command. |
RPL does not have any <code>BREAK</code> command. Flags are of great help to exit loops: |
||
≪ 1 CF |
|||
'''WHILE''' 1 FC? '''REPEAT''' |
'''WHILE''' 1 FC? '''REPEAT''' |
||
RAND 20 * IP |
RAND 20 * IP |
||
Line 3,257: | Line 3,257: | ||
2 DISP '''END''' |
2 DISP '''END''' |
||
'''END''' |
'''END''' |
||
≫ |
|||
The error handling mechanism provides another way to break a loop: |
|||
≪ '''IFERR''' |
|||
'''WHILE''' 1 '''REPEAT''' |
|||
RAND 20 * IP DUP 1 DISP |
|||
'''IF''' 10 == '''THEN''' 0 DUP / '''END''' |
|||
RAND 20 * IP 2 DISP |
|||
'''END''' |
|||
'''THEN''' DROP2 '''END''' |
|||
≫ |
≫ |
||