Loops/Continue: Difference between revisions

added RPL
(Add C3)
(added RPL)
 
(6 intermediate revisions by 6 users not shown)
Line 555:
<syntaxhighlight lang="c3">for (int i = 1; i <= 10; i++)
{
io::printfprint("%d", i);
if (i % 5 == 0)
{
Line 1,457:
 
=={{header|langur}}==
{{works with|langur|0.8.1}}
<syntaxhighlight lang="langur">for .i of 10 {
write .i
Line 1,471 ⟶ 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,616 ⟶ 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,768 ⟶ 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,196 ⟶ 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,649 ⟶ 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,150

edits