Loops/Downward for: Difference between revisions

Rename Perl 6 -> Raku, alphabetize, minor clean-up
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 119:
OUTINTEGER(1,I)
'END'</lang>
 
 
=={{header|ALGOL 68}}==
Line 155 ⟶ 154:
log i
end repeat</lang>
 
=={{header|ARM Assembly}}==
{{works with|as|Raspberry Pi}}
Line 366:
for(i = 10; i >= 0; --i)
printf("%d\n",i);</lang>
 
=={{header|C++}}==
<lang cpp>for(int i = 10; i >= 0; --i)
std::cout << i << "\n";</lang>
 
=={{header|C sharp|C#}}==
Line 377 ⟶ 373:
Console.WriteLine(i);
}</lang>
 
=={{header|C++}}==
<lang cpp>for(int i = 10; i >= 0; --i)
std::cout << i << "\n";</lang>
 
=={{header|Ceylon}}==
Line 382:
print(i);
}</lang>
 
=={{header|Chapel}}==
 
<lang chapel>for i in 1..10 by -1 do
writeln(i);</lang>
 
In case you wonder why it is not written as <tt>10..1 by -1</tt>: <tt>by</tt> is an operator that works on ranges, and it should work the same when the range was defined earlier, like in
 
<lang chapel>var r = 1..10;
for i in r by -1 do { ... }</lang>
 
=={{header|Clipper}}==
<lang clipper> FOR i := 10 TO 0 STEP -1
? i
NEXT</lang>
 
=={{header|Clojure}}==
Line 478 ⟶ 493:
0
</pre>
 
=={{header|Chapel}}==
 
<lang chapel>for i in 1..10 by -1 do
writeln(i);</lang>
 
In case you wonder why it is not written as <tt>10..1 by -1</tt>: <tt>by</tt> is an operator that works on ranges, and it should work the same when the range was defined earlier, like in
 
<lang chapel>var r = 1..10;
for i in r by -1 do { ... }</lang>
 
=={{header|Clipper}}==
<lang clipper> FOR i := 10 TO 0 STEP -1
? i
NEXT</lang>
 
=={{header|D}}==
Line 650:
SysLib.writeStdout( i );
end</lang>
 
=={{header|Ela}}==
 
===Standard Approach===
 
<lang ela>open monad io
 
each [] = do return ()
each (x::xs) = do
putStrLn $ show x
each xs
 
each [10,9..0] ::: IO</lang>
 
===Alternative Approach===
 
<lang ela>open monad io
 
countDown m n | n < m = do return ()
| else = do
putStrLn $ show n
countDown m (n - 1)
 
_ = countDown 0 10 ::: IO</lang>
 
=={{header|Elixir}}==
Line 708 ⟶ 732:
end for</lang>
 
=={{header|ElaF_Sharp|F#}}==
Using an enumerable expression:
<lang fsharp>for i in 10..-1..0 do
printfn "%d" i</lang>
 
Using the 'downto' keyword:
===Standard Approach===
<lang fsharp>for i = 10 downto 0 do
 
printfn "%d" i</lang>
<lang ela>open monad io
 
each [] = do return ()
each (x::xs) = do
putStrLn $ show x
each xs
 
each [10,9..0] ::: IO</lang>
 
===Alternative Approach===
 
<lang ela>open monad io
 
countDown m n | n < m = do return ()
| else = do
putStrLn $ show n
countDown m (n - 1)
 
_ = countDown 0 10 ::: IO</lang>
 
=={{header|Factor}}==
Line 806 ⟶ 815:
println[i]
</lang>
 
=={{header|F_Sharp|F#}}==
Using an enumerable expression:
<lang fsharp>for i in 10..-1..0 do
printfn "%d" i</lang>
 
Using the 'downto' keyword:
<lang fsharp>for i = 10 downto 0 do
printfn "%d" i</lang>
 
=={{header|FutureBasic}}==
Line 840:
0
</pre>
 
=={{header|GAP}}==
<lang gap>for i in [10, 9 .. 0] do
Print(i, "\n");
od;</lang>
 
=={{header|GML}}==
<lang GML>for(i = 10; i >= 0; i -= 1)
show_message(string(i))</lang>
 
=={{header|Gambas}}==
Line 864 ⟶ 855:
10 9 8 7 6 5 4 3 2 1 0
</pre>
 
=={{header|GAP}}==
<lang gap>for i in [10, 9 .. 0] do
Print(i, "\n");
od;</lang>
 
=={{header|GML}}==
<lang GML>for(i = 10; i >= 0; i -= 1)
show_message(string(i))</lang>
 
=={{header|Go}}==
Line 952:
for (i = 10; i >= 0; --i)
Print("%d\n", i);</lang>
 
=={{header|Icon}} and {{header|Unicon}}==
There are four looping controls 'every', 'repeat', 'until', and 'while' (see [[Icon%2BUnicon/Intro#Looping_Controls|Introduction to Icon and Unicon/Looping Controls]] for more information.) The closest to a 'for' loop is 'every'.
<lang Icon>every i := 10 to 0 by -1 do {
# things to do within the loop
}
</lang>
 
=={{header|IDL}}==
Line 964 ⟶ 971:
 
<lang idl>print,10-indgen(11)</lang>
 
=={{header|Icon}} and {{header|Unicon}}==
There are four looping controls 'every', 'repeat', 'until', and 'while' (see [[Icon%2BUnicon/Intro#Looping_Controls|Introduction to Icon and Unicon/Looping Controls]] for more information.) The closest to a 'for' loop is 'every'.
<lang Icon>every i := 10 to 0 by -1 do {
# things to do within the loop
}
</lang>
 
=={{header|Inform 6}}==
Line 1,144:
end
</lang>
 
 
=={{header|M2000 Interpreter}}==
Line 1,308 ⟶ 1,307:
NEW I FOR I=10:-1:1 WRITE I WRITE:I'=1 ", "
KILL I QUIT</lang>
 
=={{header|Nemerle}}==
<lang Nemerle>for (i = 10; i >= 0; i--) {WriteLine($"$i")}</lang>
<lang Nemerle>foreach (i in [10, 9 .. 0]) {WriteLine($"$i")}</lang>
 
=={{header|NetRexx}}==
<lang NetRexx>/* NetRexx */
options replace format comments java crossref savelog symbols nobinary
 
say
say 'Loops/Downward for'
 
loop i_ = 10 to 0 by -1
say i_.right(2)
end i_
</lang>
 
=={{header|NewLISP}}==
Line 1,327 ⟶ 1,342:
1
0</pre>
 
=={{header|Nemerle}}==
<lang Nemerle>for (i = 10; i >= 0; i--) {WriteLine($"$i")}</lang>
<lang Nemerle>foreach (i in [10, 9 .. 0]) {WriteLine($"$i")}</lang>
 
=={{header|NetRexx}}==
<lang NetRexx>/* NetRexx */
options replace format comments java crossref savelog symbols nobinary
 
say
say 'Loops/Downward for'
 
loop i_ = 10 to 0 by -1
say i_.right(2)
end i_
</lang>
 
=={{header|NS-HUBASIC}}==
Line 1,398 ⟶ 1,397:
<lang perl>foreach (reverse 0..10) {
print "$_\n";
}</lang>
 
=={{header|Perl 6}}==
{{works with|Rakudo Star|2010.08}}
 
<lang perl6>for 10 ... 0 {
.say;
}</lang>
 
Line 1,451 ⟶ 1,443:
Alternatively, the range operator might be used as well which simply returns a contiguous range of integers:
<lang powershell>10..0</lang>
 
=={{header|PureBasic}}==
<lang PureBasic>For i=10 To 0 Step -1
Debug i
Next</lang>
 
=={{header|Prolog}}==
Line 1,479 ⟶ 1,466:
true.
</pre>
 
=={{header|PureBasic}}==
<lang PureBasic>For i=10 To 0 Step -1
Debug i
Next</lang>
 
=={{header|Python}}==
Line 1,501 ⟶ 1,493:
(displayln i))
</lang>
 
=={{header|Raku}}==
(formerly Perl 6)
{{works with|Rakudo Star|2010.08}}
 
<lang perl6>for 10 ... 0 {
.say;
}</lang>
 
=={{header|REBOL}}==
Line 1,536:
say j
end</lang>
 
=={{header|Ring}}==
count from 10 to 0 by -1 step:
Line 1,578 ⟶ 1,579:
(display i)
(newline))</lang>
 
=={{header|Seed7}}==
<lang seed7>for i range 10 downto 0 do
writeln(i);
end for;</lang>
 
=={{header|Scilab}}==
Line 1,603 ⟶ 1,599:
0
</pre>
 
=={{header|Seed7}}==
<lang seed7>for i range 10 downto 0 do
writeln(i);
end for;</lang>
 
=={{header|Sidef}}==
Line 1,776 ⟶ 1,777:
ENDLOOP
</lang>
 
=={{header|UnixPipes}}==
{{works with|OpenBSD|4.9}}
<lang bash>yes '' | cat -n | head -n 11 | while read n; do
expr $n - 1
done | tail -r</lang>
 
This pipe uses several nonstandard commands: <code>cat -n</code> and <code>tail -r</code> might not work with some systems.
If there is no <code>tail -r</code>, try <code>tac</code>.
 
=={{header|UNIX Shell}}==
Line 1,814 ⟶ 1,806:
done
</lang>
 
=={{header|UnixPipes}}==
{{works with|OpenBSD|4.9}}
<lang bash>yes '' | cat -n | head -n 11 | while read n; do
expr $n - 1
done | tail -r</lang>
 
This pipe uses several nonstandard commands: <code>cat -n</code> and <code>tail -r</code> might not work with some systems.
If there is no <code>tail -r</code>, try <code>tac</code>.
 
=={{header|Ursa}}==
Line 1,835 ⟶ 1,836:
Debug.Print i
Next i</lang>
 
=={{header|Vedit macro language}}==
<lang vedit>for (#1 = 10; #1 >= 0; #1--) {
10,343

edits