Jump to content

Loops/Break: Difference between revisions

→‎{{header|RPL}}: using the handling error mechanism
imported>Brie
(Add Nu)
(→‎{{header|RPL}}: using the handling error mechanism)
Line 3,248:
 
=={{header|RPL}}==
RPL does not have any <code>BREAK</code> command. Flags are of great help to exit loops:
≪ 1 CF
'''WHILE''' 1 FC? '''REPEAT'''
RAND 20 * IP
Line 3,257:
2 DISP '''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'''
 
1,151

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.