Loops/Downward for: Difference between revisions

m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(5 intermediate revisions by 4 users not shown)
Line 345:
=={{header|ALGOL-M}}==
Sadly, ALGOL-M's FOR statement does not allow a negative value
for STEP, so in order to count down we either have to use a WHILE loop if we wish to count down.
or move the subtraction into the body of the FOR loop
<syntaxhighlight lang="ALGOL">
begin
Line 351 ⟶ 352:
integer i;
 
write("First approach :");
i := 10;
while (i >= 0) do
begin
writeon(i);
i := i - 1;
end;
 
write("Second approach:");
for i := 0 step 1 until 10 do
writeon(10-i);
 
end
Line 362 ⟶ 368:
{{out}}
<pre>
First approach : 10 9 8 7 6 5 4 3 2 1 0
Second approach: 10 9 8 7 6 5 4 3 2 1 0
</pre>
 
Line 582 ⟶ 589:
Disp 10-I▶Dec,i
End</syntaxhighlight>
 
=={{header|Bait}}==
}</syntaxhighlight lang="bait">
fun main() {
for i := 10; i >= 0; i -= 1 {
println(i)
}
}
}</syntaxhighlight>
 
=={{header|BASIC}}==
Line 1,571 ⟶ 1,587:
 
=={{header|langur}}==
<syntaxhighlight lang="langur">
You can use a for in loop to count downward. You cannot use a for of loop for this.
for i in 10..0 {
writeln .i
}
</syntaxhighlight>
 
<syntaxhighlight lang="langur">for .i in 10..0 {
for i = 10; writelni > -1; .i -= 1 {
writeln i
}</syntaxhighlight>
}
 
</syntaxhighlight lang="langur">for .i = 10; .i > -1; .i -= 1 {
writeln .i
}</syntaxhighlight>
 
=={{header|Lasso}}==
Line 1,883 ⟶ 1,901:
<syntaxhighlight lang="pascal">for i := 10 downto 0 do
writeln(i);</syntaxhighlight>
 
=={{header|PascalABC.NET}}==
<syntaxhighlight lang="delphi">
##
for var i:=10 downto 0 do
Print(i);
</syntaxhighlight>
{{out}}
<pre>
10 9 8 7 6 5 4 3 2 1 0
</pre>
 
=={{header|Peloton}}==
1,007

edits