Loops/Continue: Difference between revisions

added RPL
(added RPL)
(12 intermediate revisions by 8 users not shown)
Line 456:
}
quit</syntaxhighlight>
 
=={{header|BCPL}}==
In BCPL, the <tt>continue</tt> statement is named <tt>loop</tt>.
 
<syntaxhighlight lang="bcpl">get "libhdr"
 
let start() be
for i = 1 to 10
$( writen(i)
if i rem 5 = 0
$( wrch('*N')
loop
$)
writes(", ")
$)</syntaxhighlight>
{{out}}
<pre>1, 2, 3, 4, 5
6, 7, 8, 9, 10</pre>
 
=={{header|Befunge}}==
Line 531 ⟶ 549:
}
cout << ", ";
}</syntaxhighlight>
 
=={{header|C3}}==
{{trans|Java}}
<syntaxhighlight lang="c3">for (int i = 1; i <= 10; i++)
{
io::print(i);
if (i % 5 == 0)
{
io::printn();
continue;
}
io::print(", ");
}</syntaxhighlight>
 
Line 657 ⟶ 688:
(return-from continue))
(write-string ", ")))</syntaxhighlight>
 
=={{header|Cowgol}}==
<syntaxhighlight lang="cowgol">include "cowgol.coh";
 
var n: uint8 := 0;
while n < 10 loop
n := n + 1;
print_i8(n);
if n % 5 == 0 then
print_nl();
continue;
end if;
print(", ");
end loop;</syntaxhighlight>
{{out}}
<pre>1, 2, 3, 4, 5
6, 7, 8, 9, 10</pre>
 
=={{header|D}}==
Line 809 ⟶ 857:
Loops.continue</syntaxhighlight>
 
{{out}}
<pre>
1, 2, 3, 4, 5
6, 7, 8, 9, 10
</pre>
 
=={{header|EMal}}==
<syntaxhighlight lang="emal">
for int i = 1; i <= 10; ++i
write(i)
if i % 5 == 0
writeLine()
continue
end
write(", ")
end
</syntaxhighlight>
{{out}}
<pre>
Line 1,392 ⟶ 1,457:
 
=={{header|langur}}==
{{works with|langur|0.8.1}}
<syntaxhighlight lang="langur">for .i of 10 {
write .i
Line 1,406 ⟶ 1,470:
'Hello, World!' // never gets executed
^}</syntaxhighlight>
 
=={{header|LDPL}}==
<syntaxhighlight lang="ldpl">data:
i is number
n is number
 
procedure:
for i from 1 to 11 step 1 do
display i
modulo i by 5 in n
if n is equal to 0 then
display lf
continue
end if
display ", "
repeat</syntaxhighlight>
<pre>
1, 2, 3, 4, 5
6, 7, 8, 9, 10
</pre>
 
=={{header|Lingo}}==
Line 1,551 ⟶ 1,635:
)
)$</syntaxhighlight>
Using sprint and newline
<syntaxhighlight lang="maxima">
for n:1 thru 10 do (
sprint(n),
if n=5 then newline())$
</syntaxhighlight>
 
=={{header|MAXScript}}==
Line 1,703 ⟶ 1,793:
40 PRINT ",";
50 NEXT</syntaxhighlight>
 
=={{header|Nu}}==
<syntaxhighlight lang="nu">
for i in 1..10 {
print -n $i
if $i mod 5 == 0 {
print ""
continue
}
print -n ", "
}
</syntaxhighlight>
 
=={{header|Objeck}}==
Line 2,131 ⟶ 2,233:
next
</syntaxhighlight>
 
=={{header|RPL}}==
You need an <code>IF..THEN..ELSE</code> structure to do that in RPL.
« ""
1 10 '''FOR''' j
j +
'''IF''' j 5 MOD '''THEN''' ", " + '''ELSE''' "" '''END'''
'''NEXT''' DROP
» '<span style="color:blue">TASK</span>' STO
 
=={{header|Ruby}}==
Line 2,584 ⟶ 2,695:
=={{header|Wren}}==
From v0.4.0 Wren has a ''continue'' keyword which works in the expected fashion.
<syntaxhighlight lang="ecmascriptwren">for (i in 1..10) {
System.write(i)
if (i%5 == 0) {
1,151

edits