Loops/Downward for: Difference between revisions
Content added Content deleted
Puppydrum64 (talk | contribs) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 25: | Line 25: | ||
=={{header|11l}}== |
=={{header|11l}}== |
||
< |
<syntaxhighlight lang="11l">L(i) (10..0).step(-1) |
||
print(i)</ |
print(i)</syntaxhighlight> |
||
=={{header|360 Assembly}}== |
=={{header|360 Assembly}}== |
||
Use of BXLE and BCT opcodes. |
Use of BXLE and BCT opcodes. |
||
< |
<syntaxhighlight lang="360asm">* Loops/Downward for 27/07/2015 |
||
LOOPDOWN CSECT |
LOOPDOWN CSECT |
||
USING LOOPDOWN,R12 |
USING LOOPDOWN,R12 |
||
Line 55: | Line 55: | ||
BUFFER DC CL80' ' |
BUFFER DC CL80' ' |
||
YREGS |
YREGS |
||
END LOOPDOWN</ |
END LOOPDOWN</syntaxhighlight> |
||
=={{header|6502 Assembly}}== |
=={{header|6502 Assembly}}== |
||
Code is called as a subroutine (i.e. JSR Start). |
Code is called as a subroutine (i.e. JSR Start). |
||
Printing routines are only partially coded here, specific OS/hardware routines for printing are left unimplemented. |
Printing routines are only partially coded here, specific OS/hardware routines for printing are left unimplemented. |
||
< |
<syntaxhighlight lang="6502asm">;An OS/hardware specific routine that is setup to display the Ascii character |
||
;value contained in the Accumulator |
;value contained in the Accumulator |
||
Send = $9000 ;routine not implemented here |
Send = $9000 ;routine not implemented here |
||
Line 97: | Line 97: | ||
ORA #$30 |
ORA #$30 |
||
JSR Send ;routine not implemented here |
JSR Send ;routine not implemented here |
||
RTS </ |
RTS </syntaxhighlight> |
||
=={{header|68000 Assembly}}== |
=={{header|68000 Assembly}}== |
||
Code is called as a subroutine, i.e. "JSR ForLoop." OS/Hardware specific printing subroutines are unimplemented here. |
Code is called as a subroutine, i.e. "JSR ForLoop." OS/Hardware specific printing subroutines are unimplemented here. |
||
< |
<syntaxhighlight lang="68000devpac">ForLoop: |
||
MOVE.W #10,D0 |
MOVE.W #10,D0 |
||
loop: |
loop: |
||
JSR Print_D0_As_Ascii ;some routine that converts the digits of D0 into ascii characters and prints them to screen. |
JSR Print_D0_As_Ascii ;some routine that converts the digits of D0 into ascii characters and prints them to screen. |
||
DBRA D0,loop ;repeat until D0.W = $FFFF |
DBRA D0,loop ;repeat until D0.W = $FFFF |
||
rts</ |
rts</syntaxhighlight> |
||
=={{header|8086 Assembly}}== |
=={{header|8086 Assembly}}== |
||
It is typically much easier for assembly languages to loop downwards than forwards, as they can do so without using a redundant equality check. The 8086's <code>LOOP</code> instruction will loop a section of code, using the <code>CX</code> register as the loop counter. |
It is typically much easier for assembly languages to loop downwards than forwards, as they can do so without using a redundant equality check. The 8086's <code>LOOP</code> instruction will loop a section of code, using the <code>CX</code> register as the loop counter. |
||
< |
<syntaxhighlight lang="asm"> .model small ;.exe file, max 128 KB |
||
.stack 1024 ;reserve 1 KB for the stack pointer. |
.stack 1024 ;reserve 1 KB for the stack pointer. |
||
Line 169: | Line 169: | ||
ret |
ret |
||
end start ;EOF</ |
end start ;EOF</syntaxhighlight> |
||
=={{header|AArch64 Assembly}}== |
=={{header|AArch64 Assembly}}== |
||
{{works with|as|Raspberry Pi 3B version Buster 64 bits}} |
{{works with|as|Raspberry Pi 3B version Buster 64 bits}} |
||
<syntaxhighlight lang="aarch64 assembly"> |
|||
<lang AArch64 Assembly> |
|||
/* ARM assembly AARCH64 Raspberry PI 3B */ |
/* ARM assembly AARCH64 Raspberry PI 3B */ |
||
/* program loopdownward64.s */ |
/* program loopdownward64.s */ |
||
Line 224: | Line 224: | ||
/* for this file see task include a file in language AArch64 assembly */ |
/* for this file see task include a file in language AArch64 assembly */ |
||
.include "../includeARM64.inc" |
.include "../includeARM64.inc" |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Ada}}== |
=={{header|Ada}}== |
||
< |
<syntaxhighlight lang="ada">for I in reverse 0..10 loop |
||
Put_Line(Integer'Image(I)); |
Put_Line(Integer'Image(I)); |
||
end loop;</ |
end loop;</syntaxhighlight> |
||
=={{header|Agena}}== |
=={{header|Agena}}== |
||
Tested with Agena 2.9.5 Win32 |
Tested with Agena 2.9.5 Win32 |
||
< |
<syntaxhighlight lang="agena">for i from 10 downto 0 do |
||
print( i ) |
print( i ) |
||
od</ |
od</syntaxhighlight> |
||
=={{header|ALGOL 60}}== |
=={{header|ALGOL 60}}== |
||
Line 244: | Line 244: | ||
'''end''' |
'''end''' |
||
{{works with|ALGOL 60|OS/360}} |
{{works with|ALGOL 60|OS/360}} |
||
< |
<syntaxhighlight lang="algol60">'BEGIN' 'COMMENT' Loops/Downward for - Algol60 - 23/06/2018; |
||
'INTEGER' I; |
'INTEGER' I; |
||
'FOR' I := 10 'STEP' -1 'UNTIL' 0 'DO' |
'FOR' I := 10 'STEP' -1 'UNTIL' 0 'DO' |
||
OUTINTEGER(1,I) |
OUTINTEGER(1,I) |
||
'END'</ |
'END'</syntaxhighlight> |
||
=={{header|ALGOL 68}}== |
=={{header|ALGOL 68}}== |
||
Line 254: | Line 254: | ||
{{works with|ALGOL 68G|Any - tested with release mk15-0.8b.fc9.i386}} |
{{works with|ALGOL 68G|Any - tested with release mk15-0.8b.fc9.i386}} |
||
{{works with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release 1.8.8d.fc9.i386}} |
{{works with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release 1.8.8d.fc9.i386}} |
||
< |
<syntaxhighlight lang="algol68">FOR i FROM 10 BY -1 TO 0 DO |
||
print((i,new line)) |
print((i,new line)) |
||
OD</ |
OD</syntaxhighlight> |
||
As a common extension the DOWNTO is sometimes included to optimise |
As a common extension the DOWNTO is sometimes included to optimise |
||
the loop termination logic. The DOWNTO is available in Marcel's |
the loop termination logic. The DOWNTO is available in Marcel's |
||
[[ALGOL 68G]] and [[Cambridge ALGOL 68C]]. |
[[ALGOL 68G]] and [[Cambridge ALGOL 68C]]. |
||
< |
<syntaxhighlight lang="algol68">FOR i FROM 10 DOWNTO 0 DO |
||
print((i,new line)) |
print((i,new line)) |
||
OD</ |
OD</syntaxhighlight> |
||
=={{header|ALGOL W}}== |
=={{header|ALGOL W}}== |
||
< |
<syntaxhighlight lang="algolw">begin |
||
for i := 10 step -1 until 0 do |
for i := 10 step -1 until 0 do |
||
begin |
begin |
||
write( i ) |
write( i ) |
||
end |
end |
||
end.</ |
end.</syntaxhighlight> |
||
=={{header|Amazing Hopper}}== |
=={{header|Amazing Hopper}}== |
||
<syntaxhighlight lang="amazing hopper"> |
|||
<lang Amazing Hopper> |
|||
#include <flow.h> |
#include <flow.h> |
||
Line 283: | Line 283: | ||
BACK-IF-NOT-ZERO(i--, ciclo abajo) |
BACK-IF-NOT-ZERO(i--, ciclo abajo) |
||
END |
END |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 299: | Line 299: | ||
</pre> |
</pre> |
||
=={{header|AmigaE}}== |
=={{header|AmigaE}}== |
||
< |
<syntaxhighlight lang="amigae">PROC main() |
||
DEF i |
DEF i |
||
FOR i := 10 TO 0 STEP -1 |
FOR i := 10 TO 0 STEP -1 |
||
WriteF('\d\n', i) |
WriteF('\d\n', i) |
||
ENDFOR |
ENDFOR |
||
ENDPROC</ |
ENDPROC</syntaxhighlight> |
||
=={{header|AppleScript}}== |
=={{header|AppleScript}}== |
||
< |
<syntaxhighlight lang="applescript">repeat with i from 10 to 0 by -1 |
||
log i |
log i |
||
end repeat</ |
end repeat</syntaxhighlight> |
||
=={{header|ARM Assembly}}== |
=={{header|ARM Assembly}}== |
||
{{works with|as|Raspberry Pi}} |
{{works with|as|Raspberry Pi}} |
||
<syntaxhighlight lang="arm assembly"> |
|||
<lang ARM Assembly> |
|||
/* ARM assembly Raspberry PI */ |
/* ARM assembly Raspberry PI */ |
||
Line 428: | Line 428: | ||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Arturo}}== |
=={{header|Arturo}}== |
||
< |
<syntaxhighlight lang="rebol">loop 10..0 'i [ |
||
print i |
print i |
||
]</ |
]</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 451: | Line 451: | ||
=={{header|Asymptote}}== |
=={{header|Asymptote}}== |
||
Asymptote's control structures are similar to those in C, C++, or Java |
Asymptote's control structures are similar to those in C, C++, or Java |
||
< |
<syntaxhighlight lang="asymptote">for(int i = 10; i >=0; --i) { |
||
write(i); |
write(i); |
||
}</ |
}</syntaxhighlight> |
||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |
||
< |
<syntaxhighlight lang="autohotkey">x := 10 |
||
While (x >= 0) |
While (x >= 0) |
||
{ |
{ |
||
Line 463: | Line 463: | ||
} |
} |
||
MsgBox % output |
MsgBox % output |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Avail}}== |
=={{header|Avail}}== |
||
< |
<syntaxhighlight lang="avail">For each i from 10 to 0 by -1 do [Print: “i” ++ "\n";];</syntaxhighlight> |
||
Note that <code>10 to 0 by -1</code> section isn't a fixed part of the loop syntax, but a call to the <code>_to_by_</code> method, which returns a tuple of integers in a range separated by a particular step size, in this case returning <code><10, 9, 8, 7, 6, 5, 4, 3, 2, 1></code>. |
Note that <code>10 to 0 by -1</code> section isn't a fixed part of the loop syntax, but a call to the <code>_to_by_</code> method, which returns a tuple of integers in a range separated by a particular step size, in this case returning <code><10, 9, 8, 7, 6, 5, 4, 3, 2, 1></code>. |
||
=={{header|AWK}}== |
=={{header|AWK}}== |
||
< |
<syntaxhighlight lang="awk">BEGIN { |
||
for(i=10; i>=0; i--) { |
for(i=10; i>=0; i--) { |
||
print i |
print i |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Axe}}== |
=={{header|Axe}}== |
||
Axe does not support for loops with step sizes other than 1. |
Axe does not support for loops with step sizes other than 1. |
||
< |
<syntaxhighlight lang="axe">For(I,0,10) |
||
Disp 10-I▶Dec,i |
Disp 10-I▶Dec,i |
||
End</ |
End</syntaxhighlight> |
||
=={{header|BASIC}}== |
=={{header|BASIC}}== |
||
==={{header|Applesoft BASIC}}=== |
==={{header|Applesoft BASIC}}=== |
||
< |
<syntaxhighlight lang="applesoftbasic">FOR I = 10 TO 0 STEP -1 : PRINT I : NEXT I</syntaxhighlight> |
||
==={{header|BaCon}}=== |
==={{header|BaCon}}=== |
||
< |
<syntaxhighlight lang="freebasic">' Downward for |
||
FOR i = 10 DOWNTO 0 : PRINT i : NEXT</ |
FOR i = 10 DOWNTO 0 : PRINT i : NEXT</syntaxhighlight> |
||
==={{header|BASIC256}}=== |
==={{header|BASIC256}}=== |
||
{{works with|QBasic}} |
{{works with|QBasic}} |
||
< |
<syntaxhighlight lang="basic256">for i = 10 to 0 step -1 |
||
print i; " "; |
print i; " "; |
||
next i |
next i |
||
print |
print |
||
end</ |
end</syntaxhighlight> |
||
==={{header|BBC BASIC}}=== |
==={{header|BBC BASIC}}=== |
||
< |
<syntaxhighlight lang="bbcbasic"> FOR i% = 10 TO 0 STEP -1 |
||
PRINT i% |
PRINT i% |
||
NEXT</ |
NEXT</syntaxhighlight> |
||
==={{header|Commodore BASIC}}=== |
==={{header|Commodore BASIC}}=== |
||
< |
<syntaxhighlight lang="basic">10 FOR I = 10 TO 0 STEP -1 |
||
20 PRINT I |
20 PRINT I |
||
30 NEXT</ |
30 NEXT</syntaxhighlight> |
||
==={{header|FreeBASIC}}=== |
==={{header|FreeBASIC}}=== |
||
< |
<syntaxhighlight lang="freebasic">' FB 1.05.0 Win64 |
||
For i As Integer = 10 To 0 Step -1 |
For i As Integer = 10 To 0 Step -1 |
||
Line 515: | Line 515: | ||
Next |
Next |
||
Print |
Print |
||
Sleep</ |
Sleep</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 522: | Line 522: | ||
==={{header|FutureBasic}}=== |
==={{header|FutureBasic}}=== |
||
< |
<syntaxhighlight lang="futurebasic"> |
||
window 1, @"Countdown", ( 0, 0, 400, 300 ) |
window 1, @"Countdown", ( 0, 0, 400, 300 ) |
||
Line 532: | Line 532: | ||
HandleEvents |
HandleEvents |
||
</syntaxhighlight> |
|||
</lang> |
|||
Output: |
Output: |
||
<pre> |
<pre> |
||
Line 550: | Line 550: | ||
==={{header|Gambas}}=== |
==={{header|Gambas}}=== |
||
'''[https://gambas-playground.proko.eu/?gist=b236db5bdb1087fa90e934a5a8210e1f Click this link to run this code]''' |
'''[https://gambas-playground.proko.eu/?gist=b236db5bdb1087fa90e934a5a8210e1f Click this link to run this code]''' |
||
< |
<syntaxhighlight lang="gambas">Public Sub Main() |
||
Dim siCount As Short |
Dim siCount As Short |
||
Line 557: | Line 557: | ||
Next |
Next |
||
End</ |
End</syntaxhighlight> |
||
Output: |
Output: |
||
<pre> |
<pre> |
||
Line 565: | Line 565: | ||
==={{header|GW-BASIC}}=== |
==={{header|GW-BASIC}}=== |
||
{{works with|PC-BASIC|any}} |
{{works with|PC-BASIC|any}} |
||
< |
<syntaxhighlight lang="qbasic"> |
||
10 FOR I% = 10 TO 0 STEP -1 |
10 FOR I% = 10 TO 0 STEP -1 |
||
20 PRINT I% |
20 PRINT I% |
||
30 NEXT I% |
30 NEXT I% |
||
</syntaxhighlight> |
|||
</lang> |
|||
==={{header|IS-BASIC}}=== |
==={{header|IS-BASIC}}=== |
||
< |
<syntaxhighlight lang="is-basic">100 FOR I=10 TO 0 STEP-1 |
||
110 PRINT I |
110 PRINT I |
||
120 NEXT</ |
120 NEXT</syntaxhighlight> |
||
==={{header|Liberty BASIC}}=== |
==={{header|Liberty BASIC}}=== |
||
{{works with|Just BASIC}} |
{{works with|Just BASIC}} |
||
{{works with|Run BASIC}} |
{{works with|Run BASIC}} |
||
<syntaxhighlight lang="lb"> |
|||
<lang lb> |
|||
for i = 10 to 0 step -1 |
for i = 10 to 0 step -1 |
||
print i |
print i |
||
next i |
next i |
||
end</ |
end</syntaxhighlight> |
||
==={{header|Microsoft Small Basic}}=== |
==={{header|Microsoft Small Basic}}=== |
||
< |
<syntaxhighlight lang="microsoftsmallbasic"> |
||
For i = 10 To 0 Step -1 |
For i = 10 To 0 Step -1 |
||
TextWindow.WriteLine(i) |
TextWindow.WriteLine(i) |
||
EndFor</ |
EndFor</syntaxhighlight> |
||
==={{header|NS-HUBASIC}}=== |
==={{header|NS-HUBASIC}}=== |
||
< |
<syntaxhighlight lang="ns-hubasic">10 FOR 1=10 TO 0 STEP -1 |
||
20 PRINT I |
20 PRINT I |
||
30 NEXT</ |
30 NEXT</syntaxhighlight> |
||
==={{header|PureBasic}}=== |
==={{header|PureBasic}}=== |
||
< |
<syntaxhighlight lang="purebasic">For i=10 To 0 Step -1 |
||
Debug i |
Debug i |
||
Next</ |
Next</syntaxhighlight> |
||
==={{header|QB64}}=== |
==={{header|QB64}}=== |
||
''CBTJD'': 2020/03/14 |
''CBTJD'': 2020/03/14 |
||
< |
<syntaxhighlight lang="qbasic">FOR n = 10 TO 0 STEP -1 |
||
PRINT n |
PRINT n |
||
NEXT</ |
NEXT</syntaxhighlight> |
||
==={{header|QBASIC}}=== |
==={{header|QBASIC}}=== |
||
< |
<syntaxhighlight lang="qbasic">for i = 10 to 0 step -1 |
||
print i |
print i |
||
next i</ |
next i</syntaxhighlight> |
||
==={{header|Run BASIC}}=== |
==={{header|Run BASIC}}=== |
||
{{works with|Just BASIC}} |
{{works with|Just BASIC}} |
||
{{works with|Liberty BASIC}} |
{{works with|Liberty BASIC}} |
||
< |
<syntaxhighlight lang="lb">for i = 10 to 0 step -1 |
||
print i |
print i |
||
next i |
next i |
||
end</ |
end</syntaxhighlight> |
||
==={{header|TI-83 BASIC}}=== |
==={{header|TI-83 BASIC}}=== |
||
< |
<syntaxhighlight lang="ti83b"> |
||
:For(I,10,0,-1 |
:For(I,10,0,-1 |
||
:Disp I |
:Disp I |
||
:End |
:End |
||
</syntaxhighlight> |
|||
</lang> |
|||
==={{header|TI-89 BASIC}}=== |
==={{header|TI-89 BASIC}}=== |
||
< |
<syntaxhighlight lang="ti89b">Local i |
||
For i, 10, 0, –1 |
For i, 10, 0, –1 |
||
Disp i |
Disp i |
||
EndFor</ |
EndFor</syntaxhighlight> |
||
==={{header|True BASIC}}=== |
==={{header|True BASIC}}=== |
||
{{works with|QBasic}} |
{{works with|QBasic}} |
||
< |
<syntaxhighlight lang="basic">FOR i = 10 TO 0 STEP -1 |
||
PRINT i; " "; |
PRINT i; " "; |
||
NEXT i |
NEXT i |
||
PRINT |
PRINT |
||
END</ |
END</syntaxhighlight> |
||
==={{Header|Tiny BASIC}}=== |
==={{Header|Tiny BASIC}}=== |
||
< |
<syntaxhighlight lang="tiny basic"> LET i = 10 |
||
10 IF i = -1 THEN END |
10 IF i = -1 THEN END |
||
PRINT i |
PRINT i |
||
LET i = i - 1 |
LET i = i - 1 |
||
GOTO 10 |
GOTO 10 |
||
END</ |
END</syntaxhighlight> |
||
==={{header|Yabasic}}=== |
==={{header|Yabasic}}=== |
||
{{works with|QBasic}} |
{{works with|QBasic}} |
||
< |
<syntaxhighlight lang="yabasic">for i = 10 to 0 step -1 |
||
print i, " "; |
print i, " "; |
||
next i |
next i |
||
print |
print |
||
end</ |
end</syntaxhighlight> |
||
==={{header|XBasic}}=== |
==={{header|XBasic}}=== |
||
{{works with|Windows XBasic}} |
{{works with|Windows XBasic}} |
||
< |
<syntaxhighlight lang="xbasic">PROGRAM "downwardfor" |
||
DECLARE FUNCTION Entry() |
DECLARE FUNCTION Entry() |
||
Line 668: | Line 668: | ||
NEXT i% |
NEXT i% |
||
END FUNCTION |
END FUNCTION |
||
END PROGRAM</ |
END PROGRAM</syntaxhighlight> |
||
==={{header|ZX Spectrum Basic}}=== |
==={{header|ZX Spectrum Basic}}=== |
||
< |
<syntaxhighlight lang="zxbasic">10 FOR l = 10 TO 0 STEP -1 |
||
20 PRINT l |
20 PRINT l |
||
30 NEXT l</ |
30 NEXT l</syntaxhighlight> |
||
=={{header|Batch File}}== |
=={{header|Batch File}}== |
||
< |
<syntaxhighlight lang="dos">@echo off |
||
for /l %%D in (10,-1,0) do echo %%D</ |
for /l %%D in (10,-1,0) do echo %%D</syntaxhighlight> |
||
=={{header|bc}}== |
=={{header|bc}}== |
||
< |
<syntaxhighlight lang="bc">for (i = 10; i >= 0; i--) i |
||
quit</ |
quit</syntaxhighlight> |
||
=={{header|Befunge}}== |
=={{header|Befunge}}== |
||
< |
<syntaxhighlight lang="befunge">55+>:.:v |
||
@ ^ -1_</ |
@ ^ -1_</syntaxhighlight> |
||
=={{header|BQN}}== |
=={{header|BQN}}== |
||
Line 691: | Line 691: | ||
Each (<code>¨</code>) is an operator in BQN that helps with emulating loops like for and foreach. |
Each (<code>¨</code>) is an operator in BQN that helps with emulating loops like for and foreach. |
||
<lang |
<syntaxhighlight lang="bqn">•Show¨⌽↕11</syntaxhighlight> |
||
=={{header|Bracmat}}== |
=={{header|Bracmat}}== |
||
< |
<syntaxhighlight lang="bracmat"> 10:?i |
||
& whl'(out$!i&!i+-1:~<0:?i)</ |
& whl'(out$!i&!i+-1:~<0:?i)</syntaxhighlight> |
||
=={{header|Brainf***}}== |
=={{header|Brainf***}}== |
||
< |
<syntaxhighlight lang="brainf***">>++++++++[-<++++++>] //cell 0 now contains 48 the ASCII code for "0" |
||
<+.-. //print the digits 1 and 0 |
<+.-. //print the digits 1 and 0 |
||
>++++++++++. //cell 1 now contains the carriage return; print it! |
>++++++++++. //cell 1 now contains the carriage return; print it! |
||
Line 704: | Line 704: | ||
<<+++++++++>> //cell 0 now contains 57 the ASCII code for "9" |
<<+++++++++>> //cell 0 now contains 57 the ASCII code for "9" |
||
[<<.->.>-] //print and decrement the display digit; print a newline; decrement the loop variable |
[<<.->.>-] //print and decrement the display digit; print a newline; decrement the loop variable |
||
<<.>. //print the final 0 and a final newline</ |
<<.>. //print the final 0 and a final newline</syntaxhighlight> |
||
=={{header|Brat}}== |
=={{header|Brat}}== |
||
< |
<syntaxhighlight lang="brat">10.to 0 { n | p n }</syntaxhighlight> |
||
=={{header|C}}== |
=={{header|C}}== |
||
< |
<syntaxhighlight lang="c">int i; |
||
for(i = 10; i >= 0; --i) |
for(i = 10; i >= 0; --i) |
||
printf("%d\n",i);</ |
printf("%d\n",i);</syntaxhighlight> |
||
=={{header|C sharp|C#}}== |
=={{header|C sharp|C#}}== |
||
< |
<syntaxhighlight lang="csharp">for (int i = 10; i >= 0; i--) |
||
{ |
{ |
||
Console.WriteLine(i); |
Console.WriteLine(i); |
||
}</ |
}</syntaxhighlight> |
||
=={{header|C++}}== |
=={{header|C++}}== |
||
< |
<syntaxhighlight lang="cpp">for(int i = 10; i >= 0; --i) |
||
std::cout << i << "\n";</ |
std::cout << i << "\n";</syntaxhighlight> |
||
=={{header|Ceylon}}== |
=={{header|Ceylon}}== |
||
< |
<syntaxhighlight lang="ceylon">for (i in 10..0) { |
||
print(i); |
print(i); |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Chapel}}== |
=={{header|Chapel}}== |
||
< |
<syntaxhighlight lang="chapel">for i in 1..10 by -1 do |
||
writeln(i);</ |
writeln(i);</syntaxhighlight> |
||
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 |
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 |
||
< |
<syntaxhighlight lang="chapel">var r = 1..10; |
||
for i in r by -1 do { ... }</ |
for i in r by -1 do { ... }</syntaxhighlight> |
||
=={{header|Clipper}}== |
=={{header|Clipper}}== |
||
< |
<syntaxhighlight lang="clipper"> FOR i := 10 TO 0 STEP -1 |
||
? i |
? i |
||
NEXT</ |
NEXT</syntaxhighlight> |
||
=={{header|Clojure}}== |
=={{header|Clojure}}== |
||
< |
<syntaxhighlight lang="csharp">(doseq [x (range 10 -1 -1)] (println x))</syntaxhighlight> |
||
=={{header|COBOL}}== |
=={{header|COBOL}}== |
||
free-form |
free-form |
||
< |
<syntaxhighlight lang="cobol">identification division. |
||
program-id. countdown. |
program-id. countdown. |
||
environment division. |
environment division. |
||
Line 763: | Line 763: | ||
display counter-disp |
display counter-disp |
||
end-perform |
end-perform |
||
stop run.</ |
stop run.</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>10 |
<pre>10 |
||
Line 780: | Line 780: | ||
This could be written either in the array comprehension style, |
This could be written either in the array comprehension style, |
||
or in "regular" for loop style. |
or in "regular" for loop style. |
||
< |
<syntaxhighlight lang="coffeescript"># The more compact "array comprehension" style |
||
console.log i for i in [10..0] |
console.log i for i in [10..0] |
||
Line 788: | Line 788: | ||
# More compact version of the above |
# More compact version of the above |
||
for i in [10..0] then console.log i</ |
for i in [10..0] then console.log i</syntaxhighlight> |
||
<pre>10 |
<pre>10 |
||
9 |
9 |
||
Line 804: | Line 804: | ||
=={{header|ColdFusion}}== |
=={{header|ColdFusion}}== |
||
With tags: |
With tags: |
||
< |
<syntaxhighlight lang="cfm"><cfloop index = "i" from = "10" to = "0" step = "-1"> |
||
#i# |
#i# |
||
</cfloop></ |
</cfloop></syntaxhighlight> |
||
With script: |
With script: |
||
< |
<syntaxhighlight lang="cfm"><cfscript> |
||
for( i = 10; i <= 0; i-- ) |
for( i = 10; i <= 0; i-- ) |
||
{ |
{ |
||
writeOutput( i ); |
writeOutput( i ); |
||
} |
} |
||
</cfscript></ |
</cfscript></syntaxhighlight> |
||
=={{header|Common Lisp}}== |
=={{header|Common Lisp}}== |
||
< |
<syntaxhighlight lang="lisp">(loop for i from 10 downto 1 do |
||
(print i))</ |
(print i))</syntaxhighlight> |
||
=== Using DO === |
=== Using DO === |
||
< |
<syntaxhighlight lang="lisp"> |
||
(do ((n 10 (decf n))) ; Initialize to 0 and downward in every loop |
(do ((n 10 (decf n))) ; Initialize to 0 and downward in every loop |
||
((< n 0)) ; Break condition when negative |
((< n 0)) ; Break condition when negative |
||
(print n)) ; On every loop print value |
(print n)) ; On every loop print value |
||
</syntaxhighlight> |
|||
</lang> |
|||
=== Using Tagbody and Go === |
=== Using Tagbody and Go === |
||
< |
<syntaxhighlight lang="lisp"> |
||
(let ((count 10)) ; Create local variable count = 10 |
(let ((count 10)) ; Create local variable count = 10 |
||
(tagbody |
(tagbody |
||
Line 835: | Line 835: | ||
(if (not (< count 0)) ; Ends loop when negative |
(if (not (< count 0)) ; Ends loop when negative |
||
(go dec)))) ; Loops back to tag dec |
(go dec)))) ; Loops back to tag dec |
||
</syntaxhighlight> |
|||
</lang> |
|||
=== Using Recursion === |
=== Using Recursion === |
||
< |
<syntaxhighlight lang="lisp"> |
||
(defun down-to-0 (count) |
(defun down-to-0 (count) |
||
(print count) |
(print count) |
||
Line 844: | Line 844: | ||
(down-to-0 (1- count)))) |
(down-to-0 (1- count)))) |
||
(down-to-0 10) |
(down-to-0 10) |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
Line 862: | Line 862: | ||
=={{header|Computer/zero Assembly}}== |
=={{header|Computer/zero Assembly}}== |
||
< |
<syntaxhighlight lang="6502asm">LDA 28 |
||
SUB 29 |
SUB 29 |
||
STA 31 |
STA 31 |
||
Line 873: | Line 873: | ||
byte 11 |
byte 11 |
||
byte 1 |
byte 1 |
||
byte 0</ |
byte 0</syntaxhighlight> |
||
{{out}}[http://www.edmundgriffiths.com/czero.html?hexdump=3c9d5f5ca6c0e00000000000000000000000000000000000000000000b01000a Emulator with program loaded] |
{{out}}[http://www.edmundgriffiths.com/czero.html?hexdump=3c9d5f5ca6c0e00000000000000000000000000000000000000000000b01000a Emulator with program loaded] |
||
=={{header|Crystal}}== |
=={{header|Crystal}}== |
||
< |
<syntaxhighlight lang="crystal">10.step(to: 0, by: -1).each { |i| |
||
puts i |
puts i |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|D}}== |
=={{header|D}}== |
||
< |
<syntaxhighlight lang="d">import std.stdio: writeln; |
||
void main() { |
void main() { |
||
Line 892: | Line 892: | ||
foreach_reverse (i ; 0 .. 10 + 1) |
foreach_reverse (i ; 0 .. 10 + 1) |
||
writeln(i); |
writeln(i); |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>10 |
<pre>10 |
||
Line 932: | Line 932: | ||
uses the macro f - [p] to print, this can be replaced by any complex expressions. |
uses the macro f - [p] to print, this can be replaced by any complex expressions. |
||
< |
<syntaxhighlight lang="dc">c |
||
[macro s(swap) - (a b : b a)]s. |
[macro s(swap) - (a b : b a)]s. |
||
Line 944: | Line 944: | ||
0 10 ldx [p] sf !<m |
0 10 ldx [p] sf !<m |
||
q</ |
q</syntaxhighlight> |
||
Using it |
Using it |
||
< |
<syntaxhighlight lang="dc">|dc < ./for.dc |
||
10 |
10 |
||
9 |
9 |
||
... |
... |
||
0</ |
0</syntaxhighlight> |
||
=={{header|Delphi}}== |
=={{header|Delphi}}== |
||
Line 957: | Line 957: | ||
=={{header|Draco}}== |
=={{header|Draco}}== |
||
< |
<syntaxhighlight lang="draco">proc nonrec main() void: |
||
byte i; |
byte i; |
||
for i from 10 downto 0 do |
for i from 10 downto 0 do |
||
write(i," ") |
write(i," ") |
||
od |
od |
||
corp</ |
corp</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>10 9 8 7 6 5 4 3 2 1 0</pre> |
<pre>10 9 8 7 6 5 4 3 2 1 0</pre> |
||
=={{header|DWScript}}== |
=={{header|DWScript}}== |
||
< |
<syntaxhighlight lang="pascal">for i := 10 downto 0 do |
||
PrintLn(i);</ |
PrintLn(i);</syntaxhighlight> |
||
=={{header|E}}== |
=={{header|E}}== |
||
< |
<syntaxhighlight lang="e">for i in (0..10).descending() { println(i) }</syntaxhighlight> |
||
=={{header|EasyLang}}== |
=={{header|EasyLang}}== |
||
<lang>for i = 10 downto 0 |
<syntaxhighlight lang="text">for i = 10 downto 0 |
||
print i |
print i |
||
.</ |
.</syntaxhighlight> |
||
=={{header|EchoLisp}}== |
=={{header|EchoLisp}}== |
||
< |
<syntaxhighlight lang="scheme"> |
||
(for ((longtemps-je-me-suis-couché-de-bonne-heure (in-range 10 -1 -1))) |
(for ((longtemps-je-me-suis-couché-de-bonne-heure (in-range 10 -1 -1))) |
||
(write longtemps-je-me-suis-couché-de-bonne-heure)) |
(write longtemps-je-me-suis-couché-de-bonne-heure)) |
||
→ 10 9 8 7 6 5 4 3 2 1 0 |
→ 10 9 8 7 6 5 4 3 2 1 0 |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|EDSAC order code}}== |
=={{header|EDSAC order code}}== |
||
Including a full routine to print integers in decimal would probably be overkill; at least, it would obscure what is essentially a simple program. We therefore cheat slightly by printing "10\r\n" manually, and using the loop only to print "9\r\n" down to "0\r\n". Note that character codes are stored in the high 5 bits of the 17-bit EDSAC word: so we actually count down from 36,864 to 0 in steps of 4,096. |
Including a full routine to print integers in decimal would probably be overkill; at least, it would obscure what is essentially a simple program. We therefore cheat slightly by printing "10\r\n" manually, and using the loop only to print "9\r\n" down to "0\r\n". Note that character codes are stored in the high 5 bits of the 17-bit EDSAC word: so we actually count down from 36,864 to 0 in steps of 4,096. |
||
< |
<syntaxhighlight lang="edsac">[ Loop with downward counter |
||
========================== |
========================== |
||
Line 1,042: | Line 1,042: | ||
[ 20 ] OF [ character c = '9' ] |
[ 20 ] OF [ character c = '9' ] |
||
EZPF [ start when loaded ]</ |
EZPF [ start when loaded ]</syntaxhighlight> |
||
=={{header|EGL}}== |
=={{header|EGL}}== |
||
< |
<syntaxhighlight lang="egl">for ( i int from 10 to 0 decrement by 1 ) |
||
SysLib.writeStdout( i ); |
SysLib.writeStdout( i ); |
||
end</ |
end</syntaxhighlight> |
||
=={{header|Ela}}== |
=={{header|Ela}}== |
||
Line 1,053: | Line 1,053: | ||
===Standard Approach=== |
===Standard Approach=== |
||
< |
<syntaxhighlight lang="ela">open monad io |
||
each [] = do return () |
each [] = do return () |
||
Line 1,060: | Line 1,060: | ||
each xs |
each xs |
||
each [10,9..0] ::: IO</ |
each [10,9..0] ::: IO</syntaxhighlight> |
||
===Alternative Approach=== |
===Alternative Approach=== |
||
< |
<syntaxhighlight lang="ela">open monad io |
||
countDown m n | n < m = do return () |
countDown m n | n < m = do return () |
||
Line 1,071: | Line 1,071: | ||
countDown m (n - 1) |
countDown m (n - 1) |
||
_ = countDown 0 10 ::: IO</ |
_ = countDown 0 10 ::: IO</syntaxhighlight> |
||
=={{header|Elixir}}== |
=={{header|Elixir}}== |
||
< |
<syntaxhighlight lang="elixir">iex(1)> Enum.each(10..0, fn i -> IO.puts i end) |
||
10 |
10 |
||
9 |
9 |
||
Line 1,086: | Line 1,086: | ||
1 |
1 |
||
0 |
0 |
||
:ok</ |
:ok</syntaxhighlight> |
||
=={{header|Erlang}}== |
=={{header|Erlang}}== |
||
< |
<syntaxhighlight lang="erlang">%% Implemented by Arjun Sunel |
||
-module(downward_loop). |
-module(downward_loop). |
||
-export([main/0]). |
-export([main/0]). |
||
Line 1,103: | Line 1,103: | ||
io:format("~p~n",[N]) |
io:format("~p~n",[N]) |
||
end. |
end. |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
<pre>10 |
<pre>10 |
||
Line 1,119: | Line 1,119: | ||
=={{header|ERRE}}== |
=={{header|ERRE}}== |
||
<syntaxhighlight lang="erre"> |
|||
<lang ERRE> |
|||
FOR I%=10 TO 0 STEP -1 DO |
FOR I%=10 TO 0 STEP -1 DO |
||
PRINT(I%) |
PRINT(I%) |
||
END FOR |
END FOR |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Euphoria}}== |
=={{header|Euphoria}}== |
||
< |
<syntaxhighlight lang="euphoria">for i = 10 to 0 by -1 do |
||
? i |
? i |
||
end for</ |
end for</syntaxhighlight> |
||
=={{header|F_Sharp|F#}}== |
=={{header|F_Sharp|F#}}== |
||
Using an enumerable expression: |
Using an enumerable expression: |
||
< |
<syntaxhighlight lang="fsharp">for i in 10..-1..0 do |
||
printfn "%d" i</ |
printfn "%d" i</syntaxhighlight> |
||
Using the 'downto' keyword: |
Using the 'downto' keyword: |
||
< |
<syntaxhighlight lang="fsharp">for i = 10 downto 0 do |
||
printfn "%d" i</ |
printfn "%d" i</syntaxhighlight> |
||
=={{header|Factor}}== |
=={{header|Factor}}== |
||
< |
<syntaxhighlight lang="factor">11 <iota> <reversed> [ . ] each</syntaxhighlight> |
||
=={{header|FALSE}}== |
=={{header|FALSE}}== |
||
< |
<syntaxhighlight lang="false">10[$0>][$." "1-]#.</syntaxhighlight> |
||
=={{header|Fantom}}== |
=={{header|Fantom}}== |
||
< |
<syntaxhighlight lang="fantom"> |
||
class DownwardFor |
class DownwardFor |
||
{ |
{ |
||
Line 1,158: | Line 1,158: | ||
} |
} |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|FBSL}}== |
=={{header|FBSL}}== |
||
< |
<syntaxhighlight lang="qbasic">#APPTYPE CONSOLE |
||
FOR DIM i = 10 DOWNTO 0 |
FOR DIM i = 10 DOWNTO 0 |
||
Line 1,168: | Line 1,168: | ||
PAUSE |
PAUSE |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Fermat}}== |
=={{header|Fermat}}== |
||
< |
<syntaxhighlight lang="fermat">for i = 10 to 0 by -1 do !!i; od</syntaxhighlight> |
||
=={{header|Forth}}== |
=={{header|Forth}}== |
||
Unlike the incrementing 10 0 DO-LOOP, this will print eleven numbers. The LOOP words detect crossing the floor of the end limit. |
Unlike the incrementing 10 0 DO-LOOP, this will print eleven numbers. The LOOP words detect crossing the floor of the end limit. |
||
< |
<syntaxhighlight lang="forth">: loop-down 0 10 do i . -1 +loop ;</syntaxhighlight> |
||
=={{header|Fortran}}== |
=={{header|Fortran}}== |
||
{{Works with|Fortran|90 and later}} |
{{Works with|Fortran|90 and later}} |
||
< |
<syntaxhighlight lang="fortran">DO i = 10, 0, -1 |
||
WRITE(*, *) i |
WRITE(*, *) i |
||
END DO</ |
END DO</syntaxhighlight> |
||
{{works with|Fortran|77 and later}} |
{{works with|Fortran|77 and later}} |
||
< |
<syntaxhighlight lang="fortran"> PROGRAM DOWNWARDFOR |
||
C Initialize the loop parameters. |
C Initialize the loop parameters. |
||
INTEGER I, START, FINISH, STEP |
INTEGER I, START, FINISH, STEP |
||
Line 1,195: | Line 1,195: | ||
STOP |
STOP |
||
END</ |
END</syntaxhighlight> |
||
=={{header|Frink}}== |
=={{header|Frink}}== |
||
< |
<syntaxhighlight lang="frink"> |
||
for i = 10 to 0 step -1 |
for i = 10 to 0 step -1 |
||
println[i] |
println[i] |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|GAP}}== |
=={{header|GAP}}== |
||
< |
<syntaxhighlight lang="gap">for i in [10, 9 .. 0] do |
||
Print(i, "\n"); |
Print(i, "\n"); |
||
od;</ |
od;</syntaxhighlight> |
||
=={{header|GML}}== |
=={{header|GML}}== |
||
< |
<syntaxhighlight lang="gml">for(i = 10; i >= 0; i -= 1) |
||
show_message(string(i))</ |
show_message(string(i))</syntaxhighlight> |
||
=={{header|Go}}== |
=={{header|Go}}== |
||
< |
<syntaxhighlight lang="go">for i := 10; i >= 0; i-- { |
||
fmt.Println(i) |
fmt.Println(i) |
||
}</ |
}</syntaxhighlight> |
||
::< |
::<syntaxhighlight lang="go">package main |
||
import "fmt" |
import "fmt" |
||
Line 1,229: | Line 1,229: | ||
} |
} |
||
fmt.Println("blast off") |
fmt.Println("blast off") |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Groovy}}== |
=={{header|Groovy}}== |
||
< |
<syntaxhighlight lang="groovy">for (i in (10..0)) { |
||
println i |
println i |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Harbour}}== |
=={{header|Harbour}}== |
||
< |
<syntaxhighlight lang="visualfoxpro">FOR i := 10 TO 0 STEP -1 |
||
? i |
? i |
||
NEXT</ |
NEXT</syntaxhighlight> |
||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||
< |
<syntaxhighlight lang="haskell">import Control.Monad |
||
main :: IO () |
main :: IO () |
||
main = forM_ [10,9 .. 0] print</ |
main = forM_ [10,9 .. 0] print</syntaxhighlight> |
||
=={{header|Haxe}}== |
=={{header|Haxe}}== |
||
Line 1,251: | Line 1,251: | ||
Haxe lacks a downward for-loop, but it is easy to create an iterator to serve that purpose. |
Haxe lacks a downward for-loop, but it is easy to create an iterator to serve that purpose. |
||
< |
<syntaxhighlight lang="haxe">class Step { |
||
var end:Int; |
var end:Int; |
||
var step:Int; |
var step:Int; |
||
Line 1,272: | Line 1,272: | ||
} |
} |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,278: | Line 1,278: | ||
=={{header|hexiscript}}== |
=={{header|hexiscript}}== |
||
< |
<syntaxhighlight lang="hexiscript">for let i 10; i >= 0; i-- |
||
println i |
println i |
||
endfor</ |
endfor</syntaxhighlight> |
||
=={{header|HicEst}}== |
=={{header|HicEst}}== |
||
< |
<syntaxhighlight lang="hicest">DO i = 10, 0, -1 |
||
WRITE() i |
WRITE() i |
||
ENDDO</ |
ENDDO</syntaxhighlight> |
||
=={{header|HolyC}}== |
=={{header|HolyC}}== |
||
< |
<syntaxhighlight lang="holyc">I8 i; |
||
for (i = 10; i >= 0; --i) |
for (i = 10; i >= 0; --i) |
||
Print("%d\n", i);</ |
Print("%d\n", i);</syntaxhighlight> |
||
=={{header|Icon}} and {{header|Unicon}}== |
=={{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'. |
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'. |
||
< |
<syntaxhighlight lang="icon">every i := 10 to 0 by -1 do { |
||
# things to do within the loop |
# things to do within the loop |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|IDL}}== |
=={{header|IDL}}== |
||
Line 1,303: | Line 1,303: | ||
Using a loop (with an "increment of minus one" ): |
Using a loop (with an "increment of minus one" ): |
||
< |
<syntaxhighlight lang="idl">for i=10,0,-1 do print,i</syntaxhighlight> |
||
But in IDL one would rarely use loops (for anything) since practically everything can be done with vectors/arrays. |
But in IDL one would rarely use loops (for anything) since practically everything can be done with vectors/arrays. |
||
Line 1,309: | Line 1,309: | ||
The "IDL way of doing things" for the countdown requested in the task would probably be this: |
The "IDL way of doing things" for the countdown requested in the task would probably be this: |
||
<lang |
<syntaxhighlight lang="idl">print,10-indgen(11)</syntaxhighlight> |
||
=={{header|Inform 6}}== |
=={{header|Inform 6}}== |
||
< |
<syntaxhighlight lang="inform 6">for(i = 10: i >= 0: i--) |
||
print i, "^";</ |
print i, "^";</syntaxhighlight> |
||
=={{header|Io}}== |
=={{header|Io}}== |
||
< |
<syntaxhighlight lang="io">for(i,10,0,-1, |
||
i println |
i println |
||
)</ |
)</syntaxhighlight> |
||
=={{header|J}}== |
=={{header|J}}== |
||
Line 1,326: | Line 1,326: | ||
J does support loops for those times they can't be avoided (just like many languages support gotos for those time they can't be avoided). |
J does support loops for those times they can't be avoided (just like many languages support gotos for those time they can't be avoided). |
||
< |
<syntaxhighlight lang="j">3 : 0 ] 11 |
||
for_i. i. - y do. |
for_i. i. - y do. |
||
smoutput i |
smoutput i |
||
end. |
end. |
||
)</ |
)</syntaxhighlight> |
||
Though it's rare to see J code like this. |
Though it's rare to see J code like this. |
||
Line 1,336: | Line 1,336: | ||
That said, a convenient routine for generating intervals in J might be: |
That said, a convenient routine for generating intervals in J might be: |
||
< |
<syntaxhighlight lang="j">thru=: <. + i.@(+*)@-~</syntaxhighlight> |
||
For example: |
For example: |
||
< |
<syntaxhighlight lang="j"> 10 thru 0 |
||
10 9 8 7 6 5 4 3 2 1 0</ |
10 9 8 7 6 5 4 3 2 1 0</syntaxhighlight> |
||
(or <code>,.10 thru 0</code> if you want each number on a line by itself) |
(or <code>,.10 thru 0</code> if you want each number on a line by itself) |
||
Line 1,348: | Line 1,348: | ||
=={{header|Java}}== |
=={{header|Java}}== |
||
< |
<syntaxhighlight lang="java"> |
||
for (int i = 10; i >= 0; i--) { |
for (int i = 10; i >= 0; i--) { |
||
System.out.println(i); |
System.out.println(i); |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|JavaScript}}== |
=={{header|JavaScript}}== |
||
< |
<syntaxhighlight lang="javascript">for (var i=10; i>=0; --i) print(i);</syntaxhighlight> |
||
Alternatively, remaining for the moment within an imperative idiom of JavaScript, in which programs are composed of statements, we could trim the computational costs over longer reversed iterations by moving the mutation into the test, and dropping the third term of a for() statement: |
Alternatively, remaining for the moment within an imperative idiom of JavaScript, in which programs are composed of statements, we could trim the computational costs over longer reversed iterations by moving the mutation into the test, and dropping the third term of a for() statement: |
||
< |
<syntaxhighlight lang="javascript">for (var i = 11; i--;) console.log(i);</syntaxhighlight> |
||
and it sometimes might be more natural, especially at scales at which optimisation becomes an issue, to go one step further and express the same computation with the more economical while statement. |
and it sometimes might be more natural, especially at scales at which optimisation becomes an issue, to go one step further and express the same computation with the more economical while statement. |
||
< |
<syntaxhighlight lang="javascript">var i = 11; |
||
while (i--) console.log(i);</ |
while (i--) console.log(i);</syntaxhighlight> |
||
In a functional idiom of JavaScript, however, we need an expression with a value (which can be composed within superordinate expressions), rather than a statement, which produces a side-effect but returns no information-bearing value. |
In a functional idiom of JavaScript, however, we need an expression with a value (which can be composed within superordinate expressions), rather than a statement, which produces a side-effect but returns no information-bearing value. |
||
Line 1,370: | Line 1,370: | ||
If we have grown over-attached to the English morpheme 'for', we might think first of turning to '''Array.forEach()''', and write something like: |
If we have grown over-attached to the English morpheme 'for', we might think first of turning to '''Array.forEach()''', and write something like: |
||
< |
<syntaxhighlight lang="javascript">function range(m, n) { |
||
return Array.apply(null, Array(n - m + 1)).map( |
return Array.apply(null, Array(n - m + 1)).map( |
||
function (x, i) { |
function (x, i) { |
||
Line 1,382: | Line 1,382: | ||
console.log(x); |
console.log(x); |
||
} |
} |
||
);</ |
);</syntaxhighlight> |
||
Line 1,389: | Line 1,389: | ||
We can get an expression (assuming that the range() function (above) is defined) but replacing Array.forEach with '''Array.map()''' |
We can get an expression (assuming that the range() function (above) is defined) but replacing Array.forEach with '''Array.map()''' |
||
< |
<syntaxhighlight lang="javascript">console.log( |
||
range(0, 10).reverse().map( |
range(0, 10).reverse().map( |
||
function (x) { |
function (x) { |
||
Line 1,395: | Line 1,395: | ||
} |
} |
||
).join('\n') |
).join('\n') |
||
);</ |
);</syntaxhighlight> |
||
but in this case, we are simply mapping an identity function over the values, so the expression simplifies down to: |
but in this case, we are simply mapping an identity function over the values, so the expression simplifies down to: |
||
< |
<syntaxhighlight lang="javascript">console.log( |
||
range(0, 10).reverse().join('\n') |
range(0, 10).reverse().join('\n') |
||
);</ |
);</syntaxhighlight> |
||
=={{header|jq}}== |
=={{header|jq}}== |
||
If range/3 is available in your jq: |
If range/3 is available in your jq: |
||
<lang |
<syntaxhighlight lang="jq">range(10;-1;-1)</syntaxhighlight> |
||
Otherwise: |
Otherwise: |
||
range(-10;1) | -. |
range(-10;1) | -. |
||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
< |
<syntaxhighlight lang="julia">for i in 10:-1:0 |
||
println(i) |
println(i) |
||
end</ |
end</syntaxhighlight> |
||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |
||
< |
<syntaxhighlight lang="scala"> |
||
// version 1.3.61 |
// version 1.3.61 |
||
Line 1,421: | Line 1,421: | ||
(10 downTo 0).forEach { println(it) } |
(10 downTo 0).forEach { println(it) } |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Lambdatalk}}== |
=={{header|Lambdatalk}}== |
||
< |
<syntaxhighlight lang="scheme"> |
||
{def downward_for |
{def downward_for |
||
{lambda {:i} |
{lambda {:i} |
||
Line 1,434: | Line 1,434: | ||
{downward_for 10} |
{downward_for 10} |
||
-> 10 9 8 7 6 5 4 3 2 1 0 (end of loop) |
-> 10 9 8 7 6 5 4 3 2 1 0 (end of loop) |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|langur}}== |
=={{header|langur}}== |
||
You can use a for in loop to count downward. You cannot use a for of loop for this. |
You can use a for in loop to count downward. You cannot use a for of loop for this. |
||
< |
<syntaxhighlight lang="langur">for .i in 10..0 { |
||
writeln .i |
writeln .i |
||
}</ |
}</syntaxhighlight> |
||
< |
<syntaxhighlight lang="langur">for .i = 10; .i > -1; .i -= 1 { |
||
writeln .i |
writeln .i |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Lasso}}== |
=={{header|Lasso}}== |
||
< |
<syntaxhighlight lang="lasso">loop(-from=10, -to=0, -by=-1) => {^ loop_count + ' ' ^}</syntaxhighlight> |
||
=={{header|Lhogho}}== |
=={{header|Lhogho}}== |
||
Slightly different syntax for <code>for</code> compared to Logo. |
Slightly different syntax for <code>for</code> compared to Logo. |
||
< |
<syntaxhighlight lang="logo">for "i [10 0] [print :i]</syntaxhighlight> |
||
=={{header|Lingo}}== |
=={{header|Lingo}}== |
||
< |
<syntaxhighlight lang="lingo">repeat with i = 10 down to 0 |
||
put i |
put i |
||
end repeat</ |
end repeat</syntaxhighlight> |
||
=={{header|Lisaac}}== |
=={{header|Lisaac}}== |
||
< |
<syntaxhighlight lang="lisaac">10.downto 0 do { i : INTEGER; |
||
i.println; |
i.println; |
||
};</ |
};</syntaxhighlight> |
||
=={{header|LiveCode}}== |
=={{header|LiveCode}}== |
||
Livecode's repeat "for" variant does not have a "down to" form, in a function you would need to manually decrement a counter |
Livecode's repeat "for" variant does not have a "down to" form, in a function you would need to manually decrement a counter |
||
< |
<syntaxhighlight lang="livecode">local x=10 |
||
repeat for 10 times |
repeat for 10 times |
||
put x & return |
put x & return |
||
add -1 to x |
add -1 to x |
||
end repeat</ |
end repeat</syntaxhighlight> |
||
A more idiomatic approach using "with" variant of repeat which does have a "down to" form |
A more idiomatic approach using "with" variant of repeat which does have a "down to" form |
||
< |
<syntaxhighlight lang="livecode">repeat with n=10 down to 1 |
||
put n |
put n |
||
end repeat</ |
end repeat</syntaxhighlight> |
||
=={{header|Logo}}== |
=={{header|Logo}}== |
||
If the limit is less than the start, then FOR decrements the control variable. Otherwise, a fourth parameter could be given as a custom increment. |
If the limit is less than the start, then FOR decrements the control variable. Otherwise, a fourth parameter could be given as a custom increment. |
||
< |
<syntaxhighlight lang="logo">for [i 10 0] [print :i]</syntaxhighlight> |
||
=={{header|Lua}}== |
=={{header|Lua}}== |
||
< |
<syntaxhighlight lang="lua"> |
||
for i=10,0,-1 do |
for i=10,0,-1 do |
||
print(i) |
print(i) |
||
end |
end |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|M2000 Interpreter}}== |
=={{header|M2000 Interpreter}}== |
||
Line 1,496: | Line 1,496: | ||
There is a slower For, the For Next style: |
There is a slower For, the For Next style: |
||
<syntaxhighlight lang="m2000 interpreter"> |
|||
<lang M2000 Interpreter> |
|||
For i=1 to 10 step 2 : Print i : Next i |
For i=1 to 10 step 2 : Print i : Next i |
||
</syntaxhighlight> |
|||
</lang> |
|||
We have to use Exit For to exit from that type of For. |
We have to use Exit For to exit from that type of For. |
||
Line 1,508: | Line 1,508: | ||
<syntaxhighlight lang="m2000 interpreter"> |
|||
<lang M2000 Interpreter> |
|||
Form 80, 50 |
Form 80, 50 |
||
Module Checkit { |
Module Checkit { |
||
Line 1,543: | Line 1,543: | ||
} |
} |
||
CheckIt |
CheckIt |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|M4}}== |
=={{header|M4}}== |
||
< |
<syntaxhighlight lang="m4">define(`for', |
||
`ifelse($#,0,``$0'', |
`ifelse($#,0,``$0'', |
||
`ifelse(eval($2 $3),1, |
`ifelse(eval($2 $3),1, |
||
Line 1,552: | Line 1,552: | ||
for(`x',`10',`>=0',`-1',`x |
for(`x',`10',`>=0',`-1',`x |
||
')</ |
')</syntaxhighlight> |
||
=={{header|Maple}}== |
=={{header|Maple}}== |
||
Using an explicit loop: |
Using an explicit loop: |
||
< |
<syntaxhighlight lang="maple">for i from 10 to 0 by -1 do print(i) end:</syntaxhighlight> |
||
Pushing the loop into the kernel: |
Pushing the loop into the kernel: |
||
< |
<syntaxhighlight lang="maple">seq(print(i),i=10..0,-1)</syntaxhighlight> |
||
=={{header|Mathematica}}/{{header|Wolfram Language}}== |
=={{header|Mathematica}}/{{header|Wolfram Language}}== |
||
Line 1,566: | Line 1,566: | ||
Using For: |
Using For: |
||
< |
<syntaxhighlight lang="mathematica">For[i = 10, i >= 0, i--, Print[i]]</syntaxhighlight> |
||
Using Do: |
Using Do: |
||
< |
<syntaxhighlight lang="mathematica">Do[Print[i], {i, 10, 0, -1}]</syntaxhighlight> |
||
Using Scan: |
Using Scan: |
||
< |
<syntaxhighlight lang="mathematica">Scan[Print, Range[10, 0, -1]]</syntaxhighlight> |
||
=={{header|MATLAB}} / {{header|Octave}}== |
=={{header|MATLAB}} / {{header|Octave}}== |
||
< |
<syntaxhighlight lang="matlab"> for k = 10:-1:0, |
||
printf('%d\n',k) |
printf('%d\n',k) |
||
end; </ |
end; </syntaxhighlight> |
||
A vectorized version of the code is |
A vectorized version of the code is |
||
< |
<syntaxhighlight lang="matlab"> printf('%d\n',10:-1:0); </syntaxhighlight> |
||
=={{header|Maxima}}== |
=={{header|Maxima}}== |
||
< |
<syntaxhighlight lang="maxima">for i from 10 thru 0 step -1 do print(i);</syntaxhighlight> |
||
=={{header|MAXScript}}== |
=={{header|MAXScript}}== |
||
< |
<syntaxhighlight lang="maxscript">for i in 10 to 0 by -1 do print i</syntaxhighlight> |
||
=={{header|Mercury}}== |
=={{header|Mercury}}== |
||
<lang>:- module loops_downward_for. |
<syntaxhighlight lang="text">:- module loops_downward_for. |
||
:- interface. |
:- interface. |
||
Line 1,602: | Line 1,602: | ||
io.write_int(I, !IO), io.nl(!IO) |
io.write_int(I, !IO), io.nl(!IO) |
||
), |
), |
||
int.fold_down(Print, 1, 10, !IO).</ |
int.fold_down(Print, 1, 10, !IO).</syntaxhighlight> |
||
=={{header|Metafont}}== |
=={{header|Metafont}}== |
||
< |
<syntaxhighlight lang="metafont">for i = 10 step -1 until 0: show i; endfor |
||
end</ |
end</syntaxhighlight> |
||
The basic set of macros for Metafont defines <tt>downto</tt>, so that we can write |
The basic set of macros for Metafont defines <tt>downto</tt>, so that we can write |
||
< |
<syntaxhighlight lang="metafont">for i = 10 downto 0: show i; endfor end</syntaxhighlight> |
||
=={{header|min}}== |
=={{header|min}}== |
||
{{works with|min|0.19.6}} |
{{works with|min|0.19.6}} |
||
< |
<syntaxhighlight lang="min">10 :n (n 0 >=) (n puts! n pred @n) while</syntaxhighlight> |
||
Or |
Or |
||
< |
<syntaxhighlight lang="min">10 (dup 0 <) 'pop (puts pred) () linrec</syntaxhighlight> |
||
=={{header|MiniScript}}== |
=={{header|MiniScript}}== |
||
< |
<syntaxhighlight lang="miniscript">for i in range(10, 0) |
||
print i |
print i |
||
end for</ |
end for</syntaxhighlight> |
||
=={{header|МК-61/52}}== |
=={{header|МК-61/52}}== |
||
<lang>1 0 П0 ИП0 L0 03 С/П</ |
<syntaxhighlight lang="text">1 0 П0 ИП0 L0 03 С/П</syntaxhighlight> |
||
=={{header|Modula-2}}== |
=={{header|Modula-2}}== |
||
< |
<syntaxhighlight lang="modula2">MODULE Downward; |
||
IMPORT InOut; |
IMPORT InOut; |
||
Line 1,639: | Line 1,639: | ||
InOut.WriteLn |
InOut.WriteLn |
||
END |
END |
||
END Downward.</ |
END Downward.</syntaxhighlight> |
||
=={{header|Modula-3}}== |
=={{header|Modula-3}}== |
||
< |
<syntaxhighlight lang="modula3">FOR i := 10 TO 0 BY -1 DO |
||
IO.PutInt(i); |
IO.PutInt(i); |
||
END;</ |
END;</syntaxhighlight> |
||
=={{header|MUMPS}}== |
=={{header|MUMPS}}== |
||
< |
<syntaxhighlight lang="mumps">LOOPDOWN |
||
NEW I FOR I=10:-1:1 WRITE I WRITE:I'=1 ", " |
NEW I FOR I=10:-1:1 WRITE I WRITE:I'=1 ", " |
||
KILL I QUIT</ |
KILL I QUIT</syntaxhighlight> |
||
=={{header|Nemerle}}== |
=={{header|Nemerle}}== |
||
< |
<syntaxhighlight lang="nemerle">for (i = 10; i >= 0; i--) {WriteLine($"$i")}</syntaxhighlight> |
||
< |
<syntaxhighlight lang="nemerle">foreach (i in [10, 9 .. 0]) {WriteLine($"$i")}</syntaxhighlight> |
||
=={{header|NetRexx}}== |
=={{header|NetRexx}}== |
||
< |
<syntaxhighlight lang="netrexx">/* NetRexx */ |
||
options replace format comments java crossref savelog symbols nobinary |
options replace format comments java crossref savelog symbols nobinary |
||
Line 1,665: | Line 1,665: | ||
say i_.right(2) |
say i_.right(2) |
||
end i_ |
end i_ |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|NewLISP}}== |
=={{header|NewLISP}}== |
||
< |
<syntaxhighlight lang="newlisp">(for (i 10 0) |
||
(println i))</ |
(println i))</syntaxhighlight> |
||
=={{header|Nim}}== |
=={{header|Nim}}== |
||
< |
<syntaxhighlight lang="nim">for x in countdown(10,0): echo(x)</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>10 |
<pre>10 |
||
Line 1,687: | Line 1,687: | ||
=={{header|Oberon-2}}== |
=={{header|Oberon-2}}== |
||
< |
<syntaxhighlight lang="oberon2">FOR i := 10 TO 0 BY -1 DO |
||
Out.Int(i,0); |
Out.Int(i,0); |
||
END;</ |
END;</syntaxhighlight> |
||
=={{header|Objeck}}== |
=={{header|Objeck}}== |
||
< |
<syntaxhighlight lang="objeck"> |
||
for(i := 10; i >= 0; i--;) { |
for(i := 10; i >= 0; i--;) { |
||
i->PrintLine(); |
i->PrintLine(); |
||
}; |
}; |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|OCaml}}== |
=={{header|OCaml}}== |
||
< |
<syntaxhighlight lang="ocaml">for i = 10 downto 0 do |
||
Printf.printf "%d\n" i |
Printf.printf "%d\n" i |
||
done</ |
done</syntaxhighlight> |
||
=={{header|Octave}}== |
=={{header|Octave}}== |
||
< |
<syntaxhighlight lang="octave">for i = 10:-1:0 |
||
% ... |
% ... |
||
endfor</ |
endfor</syntaxhighlight> |
||
=={{header|Oforth}}== |
=={{header|Oforth}}== |
||
< |
<syntaxhighlight lang="oforth">10 0 -1 step: i [ i println ]</syntaxhighlight> |
||
=={{header|Oz}}== |
=={{header|Oz}}== |
||
< |
<syntaxhighlight lang="oz">for I in 10..0;~1 do |
||
{Show I} |
{Show I} |
||
end</ |
end</syntaxhighlight> |
||
=={{header|PARI/GP}}== |
=={{header|PARI/GP}}== |
||
< |
<syntaxhighlight lang="parigp">forstep(n=10,0,-1,print(n))</syntaxhighlight> |
||
=={{header|Pascal}}== |
=={{header|Pascal}}== |
||
< |
<syntaxhighlight lang="pascal">for i := 10 downto 0 do |
||
writeln(i);</ |
writeln(i);</syntaxhighlight> |
||
=={{header|Peloton}}== |
=={{header|Peloton}}== |
||
English fixed-length opcodes |
English fixed-length opcodes |
||
< |
<syntaxhighlight lang="sgml"><@ ITEFORLITLITLITLIT>0|<@ SAYVALFOR>...</@>|10|-1</@></syntaxhighlight> |
||
Simplified Chinese variable-length opcodes |
Simplified Chinese variable-length opcodes |
||
< |
<syntaxhighlight lang="sgml"><# 迭代迭代次数字串字串字串字串>0|<# 显示值迭代次数>...</#>|10|-1</#></syntaxhighlight> |
||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
< |
<syntaxhighlight lang="perl">foreach (reverse 0..10) { |
||
print "$_\n"; |
print "$_\n"; |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
{{libheader|Phix/basics}} |
{{libheader|Phix/basics}} |
||
<!--< |
<!--<syntaxhighlight lang="phix">--> |
||
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">=</span><span style="color: #000000;">10</span> <span style="color: #008080;">to</span> <span style="color: #000000;">0</span> <span style="color: #008080;">by</span> <span style="color: #0000FF;">-</span><span style="color: #000000;">1</span> <span style="color: #008080;">do</span> |
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">=</span><span style="color: #000000;">10</span> <span style="color: #008080;">to</span> <span style="color: #000000;">0</span> <span style="color: #008080;">by</span> <span style="color: #0000FF;">-</span><span style="color: #000000;">1</span> <span style="color: #008080;">do</span> |
||
<span style="color: #0000FF;">?</span><span style="color: #000000;">i</span> |
<span style="color: #0000FF;">?</span><span style="color: #000000;">i</span> |
||
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span> |
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span> |
||
<!--</ |
<!--</syntaxhighlight>--> |
||
=={{header|PHP}}== |
=={{header|PHP}}== |
||
< |
<syntaxhighlight lang="php">for ($i = 10; $i >= 0; $i--) |
||
echo "$i\n";</ |
echo "$i\n";</syntaxhighlight> |
||
or |
or |
||
< |
<syntaxhighlight lang="php">foreach (range(10, 0) as $i) |
||
echo "$i\n";</ |
echo "$i\n";</syntaxhighlight> |
||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |
||
< |
<syntaxhighlight lang="picolisp">(for (I 10 (ge0 I) (dec I)) |
||
(println I) )</ |
(println I) )</syntaxhighlight> |
||
or: |
or: |
||
< |
<syntaxhighlight lang="picolisp">(mapc println (range 10 0))</syntaxhighlight> |
||
=={{header|Pike}}== |
=={{header|Pike}}== |
||
< |
<syntaxhighlight lang="pike">int main(){ |
||
for(int i = 10; i >= 0; i--){ |
for(int i = 10; i >= 0; i--){ |
||
write(i + "\n"); |
write(i + "\n"); |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
=={{header|PL/I}}== |
=={{header|PL/I}}== |
||
<syntaxhighlight lang="pl/i"> |
|||
<lang PL/I> |
|||
do i = 10 to 0 by -1; |
do i = 10 to 0 by -1; |
||
put skip list (i); |
put skip list (i); |
||
end; |
end; |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Plain English}}== |
=={{header|Plain English}}== |
||
One way might be: |
One way might be: |
||
< |
<syntaxhighlight lang="plainenglish">To run: |
||
Start up. |
Start up. |
||
Put 11 into a counter. |
Put 11 into a counter. |
||
Line 1,788: | Line 1,788: | ||
Subtract 1 from the counter. |
Subtract 1 from the counter. |
||
If the counter is less than the number, say yes. |
If the counter is less than the number, say yes. |
||
Say no.</ |
Say no.</syntaxhighlight> |
||
=={{header|Pop11}}== |
=={{header|Pop11}}== |
||
< |
<syntaxhighlight lang="pop11">lvars i; |
||
for i from 10 by -1 to 0 do |
for i from 10 by -1 to 0 do |
||
printf(i, '%p\n'); |
printf(i, '%p\n'); |
||
endfor;</ |
endfor;</syntaxhighlight> |
||
=={{header|PowerShell}}== |
=={{header|PowerShell}}== |
||
< |
<syntaxhighlight lang="powershell">for ($i = 10; $i -ge 0; $i--) { |
||
$i |
$i |
||
}</ |
}</syntaxhighlight> |
||
Alternatively, the range operator might be used as well which simply returns a contiguous range of integers: |
Alternatively, the range operator might be used as well which simply returns a contiguous range of integers: |
||
<lang |
<syntaxhighlight lang="powershell">10..0</syntaxhighlight> |
||
=={{header|Prolog}}== |
=={{header|Prolog}}== |
||
Although Prolog has a between(Lo,Hi,Value) iterator, there is no built in equivalent for iterating descending values. This is not a show stopper, as it's easy enough to write one. |
Although Prolog has a between(Lo,Hi,Value) iterator, there is no built in equivalent for iterating descending values. This is not a show stopper, as it's easy enough to write one. |
||
< |
<syntaxhighlight lang="prolog">rfor(Hi,Lo,Hi) :- Hi >= Lo. |
||
rfor(Hi,Lo,Val) :- Hi > Lo, H is Hi - 1, !, rfor(H,Lo,Val). |
rfor(Hi,Lo,Val) :- Hi > Lo, H is Hi - 1, !, rfor(H,Lo,Val). |
||
reverse_iter :- |
reverse_iter :- |
||
rfor(10,0,Val), write(Val), nl, fail. |
rfor(10,0,Val), write(Val), nl, fail. |
||
reverse_iter.</ |
reverse_iter.</syntaxhighlight> |
||
<pre>?- reverse_iter. |
<pre>?- reverse_iter. |
||
10 |
10 |
||
Line 1,827: | Line 1,827: | ||
=={{header|Python}}== |
=={{header|Python}}== |
||
< |
<syntaxhighlight lang="python">for i in xrange(10, -1, -1): |
||
print i</ |
print i</syntaxhighlight> |
||
=== List comprehension === |
=== List comprehension === |
||
< |
<syntaxhighlight lang="python">[i for i in xrange(10, -1, -1)]</syntaxhighlight> |
||
< |
<syntaxhighlight lang="python">import pprint |
||
pprint.pprint([i for i in xrange(10, -1, -1)]) |
pprint.pprint([i for i in xrange(10, -1, -1)]) |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Quackery}}== |
=={{header|Quackery}}== |
||
< |
<syntaxhighlight lang="quackery">11 times [ i echo sp ]</syntaxhighlight> |
||
{{Out}} |
{{Out}} |
||
Line 1,846: | Line 1,846: | ||
=={{header|R}}== |
=={{header|R}}== |
||
< |
<syntaxhighlight lang="r">for(i in 10:0) {print(i)}</syntaxhighlight> |
||
=={{header|Racket}}== |
=={{header|Racket}}== |
||
< |
<syntaxhighlight lang="racket"> |
||
#lang racket |
#lang racket |
||
(for ([i (in-range 10 -1 -1)]) |
(for ([i (in-range 10 -1 -1)]) |
||
(displayln i)) |
(displayln i)) |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Raku}}== |
=={{header|Raku}}== |
||
Line 1,860: | Line 1,860: | ||
{{works with|Rakudo Star|2010.08}} |
{{works with|Rakudo Star|2010.08}} |
||
<lang |
<syntaxhighlight lang="raku" line>for 10 ... 0 { |
||
.say; |
.say; |
||
}</ |
}</syntaxhighlight> |
||
=={{header|REBOL}}== |
=={{header|REBOL}}== |
||
< |
<syntaxhighlight lang="rebol">for i 10 0 -1 [print i]</syntaxhighlight> |
||
=={{header|Retro}}== |
=={{header|Retro}}== |
||
<lang |
<syntaxhighlight lang="retro">11 [ putn space ] iterd</syntaxhighlight> |
||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
===version 1=== |
===version 1=== |
||
(equivalent to version 2 and version 3) |
(equivalent to version 2 and version 3) |
||
< |
<syntaxhighlight lang="rexx"> do j=10 to 0 by -1 |
||
say j |
say j |
||
end</ |
end</syntaxhighlight> |
||
===version 2=== |
===version 2=== |
||
(equivalent to version 1 and version 3) |
(equivalent to version 1 and version 3) |
||
< |
<syntaxhighlight lang="rexx"> do j=10 by -1 to 0 |
||
say j |
say j |
||
end</ |
end</syntaxhighlight> |
||
===version 3=== |
===version 3=== |
||
Line 1,887: | Line 1,887: | ||
<br><br>Anybody who programs like this should be hunted down and shot like dogs! |
<br><br>Anybody who programs like this should be hunted down and shot like dogs! |
||
<br><br>Hurrumph! Hurrumph! |
<br><br>Hurrumph! Hurrumph! |
||
< |
<syntaxhighlight lang="rexx"> do j=10 by -2 to 0 |
||
say j |
say j |
||
j=j+1 /*this increments the DO index. Do NOT program like this! */ |
j=j+1 /*this increments the DO index. Do NOT program like this! */ |
||
end</ |
end</syntaxhighlight> |
||
===version 4=== |
===version 4=== |
||
This example isn't compliant to the task, |
This example isn't compliant to the task, |
||
but it shows that the increment/decrement can be a non-integer: |
but it shows that the increment/decrement can be a non-integer: |
||
< |
<syntaxhighlight lang="rexx"> do j=30 to 1 by -.25 |
||
say j |
say j |
||
end</ |
end</syntaxhighlight> |
||
=={{header|Ring}}== |
=={{header|Ring}}== |
||
count from 10 to 0 by -1 step: |
count from 10 to 0 by -1 step: |
||
< |
<syntaxhighlight lang="ring"> |
||
for i = 10 to 0 step -1 see i + nl next |
for i = 10 to 0 step -1 see i + nl next |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
< |
<syntaxhighlight lang="ruby">10.downto(0) do |i| |
||
puts i |
puts i |
||
end</ |
end</syntaxhighlight> |
||
=={{header|Rust}}== |
=={{header|Rust}}== |
||
< |
<syntaxhighlight lang="rust">fn main() { |
||
for i in (0..=10).rev() { |
for i in (0..=10).rev() { |
||
println!("{}", i); |
println!("{}", i); |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Salmon}}== |
=={{header|Salmon}}== |
||
< |
<syntaxhighlight lang="salmon">for (x; 10; x >= 0; -1) |
||
x!;</ |
x!;</syntaxhighlight> |
||
=={{header|Sather}}== |
=={{header|Sather}}== |
||
< |
<syntaxhighlight lang="sather">class MAIN is |
||
main is |
main is |
||
i:INT; |
i:INT; |
||
Line 1,929: | Line 1,929: | ||
end; |
end; |
||
end; |
end; |
||
end;</ |
end;</syntaxhighlight> |
||
=={{header|Scala}}== |
=={{header|Scala}}== |
||
< |
<syntaxhighlight lang="scala">for(i <- 10 to 0 by -1) println(i) |
||
//or |
//or |
||
10 to 0 by -1 foreach println</ |
10 to 0 by -1 foreach println</syntaxhighlight> |
||
=={{header|Scheme}}== |
=={{header|Scheme}}== |
||
< |
<syntaxhighlight lang="scheme">(do ((i 10 (- i 1))) |
||
((< i 0)) |
((< i 0)) |
||
(display i) |
(display i) |
||
(newline))</ |
(newline))</syntaxhighlight> |
||
=={{header|Scilab}}== |
=={{header|Scilab}}== |
||
{{works with|Scilab|5.5.1}} |
{{works with|Scilab|5.5.1}} |
||
<lang>for i=10:-1:0 |
<syntaxhighlight lang="text">for i=10:-1:0 |
||
printf("%d\n",i) |
printf("%d\n",i) |
||
end</ |
end</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre style="height:20ex"> |
<pre style="height:20ex"> |
||
Line 1,963: | Line 1,963: | ||
=={{header|Seed7}}== |
=={{header|Seed7}}== |
||
< |
<syntaxhighlight lang="seed7">for i range 10 downto 0 do |
||
writeln(i); |
writeln(i); |
||
end for;</ |
end for;</syntaxhighlight> |
||
=={{header|Sidef}}== |
=={{header|Sidef}}== |
||
'''for(;;)''' loop: |
'''for(;;)''' loop: |
||
< |
<syntaxhighlight lang="ruby">for (var i = 10; i >= 0; i--) { |
||
say i |
say i |
||
}</ |
}</syntaxhighlight> |
||
'''for-in''' loop: |
'''for-in''' loop: |
||
< |
<syntaxhighlight lang="ruby">for i in (11 ^.. 0) { |
||
say i |
say i |
||
}</ |
}</syntaxhighlight> |
||
'''.each''' method: |
'''.each''' method: |
||
< |
<syntaxhighlight lang="ruby">10.downto(0).each { |i| |
||
say i |
say i |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Simula}}== |
=={{header|Simula}}== |
||
< |
<syntaxhighlight lang="simula">BEGIN |
||
Integer i; |
Integer i; |
||
for i := 10 step -1 until 0 do |
for i := 10 step -1 until 0 do |
||
Line 1,991: | Line 1,991: | ||
OutImage |
OutImage |
||
END |
END |
||
END</ |
END</syntaxhighlight> |
||
=={{header|Slate}}== |
=={{header|Slate}}== |
||
< |
<syntaxhighlight lang="slate">10 downTo: 0 do: [| :n | print: n]</syntaxhighlight> |
||
=={{header|Smalltalk}}== |
=={{header|Smalltalk}}== |
||
< |
<syntaxhighlight lang="smalltalk">10 to: 0 by: -1 do:[:aNumber | |
||
aNumber displayNl. |
aNumber displayNl. |
||
]. |
]. |
||
Line 2,003: | Line 2,003: | ||
10 downTo: 0 do:[:eachNumber | |
10 downTo: 0 do:[:eachNumber | |
||
eachNumber displayNl. |
eachNumber displayNl. |
||
]</ |
]</syntaxhighlight> |
||
Both enumerate 10 to 0 inclusive. |
Both enumerate 10 to 0 inclusive. |
||
Non-Smalltalkers might be confused when seeing: |
Non-Smalltalkers might be confused when seeing: |
||
< |
<syntaxhighlight lang="smalltalk">(10 to: 0 by: -1) do:[:eachNumber | |
||
eachNumber displayNl. |
eachNumber displayNl. |
||
]</ |
]</syntaxhighlight> |
||
which has the same effect, but a slightly different mechanism. |
which has the same effect, but a slightly different mechanism. |
||
Line 2,019: | Line 2,019: | ||
The nice thing with Intervals is that they can be concatenated with a <tt>","</tt> operator (like all collections); thus, I could also write: |
The nice thing with Intervals is that they can be concatenated with a <tt>","</tt> operator (like all collections); thus, I could also write: |
||
< |
<syntaxhighlight lang="smalltalk">(10 to: 5 by: -1),(0 to: 4) do:[:eachNumber | |
||
eachNumber displayNl. |
eachNumber displayNl. |
||
]</ |
]</syntaxhighlight> |
||
to enumerate in a different order, |
to enumerate in a different order, |
||
<br>or combine ranges with a constant array: |
<br>or combine ranges with a constant array: |
||
< |
<syntaxhighlight lang="smalltalk">(10 to: 0 by: -2),#(99 999),(1 to: 9 by: 2) do:[:each | |
||
each displayNl. |
each displayNl. |
||
]</ |
]</syntaxhighlight> |
||
or with a computed array: |
or with a computed array: |
||
< |
<syntaxhighlight lang="smalltalk">(10 to: 0 by: -2),{ 10 factorial . 11 factorial},(1 to: 9 by: 2) do:[:each | |
||
each displayNl. |
each displayNl. |
||
]</ |
]</syntaxhighlight> |
||
PS: there is also a reverse do, as in: |
PS: there is also a reverse do, as in: |
||
< |
<syntaxhighlight lang="smalltalk">(0 to:10) reverseDo:[:each | |
||
each displayNl. |
each displayNl. |
||
]</ |
]</syntaxhighlight> |
||
=={{header|SNOBOL4}}== |
=={{header|SNOBOL4}}== |
||
< |
<syntaxhighlight lang="snobol4"> COUNT = 10 |
||
LOOP OUTPUT = COUNT |
LOOP OUTPUT = COUNT |
||
COUNT = COUNT - 1 |
COUNT = COUNT - 1 |
||
GE(COUNT, 0) :S(LOOP) |
GE(COUNT, 0) :S(LOOP) |
||
END</ |
END</syntaxhighlight> |
||
=={{header|SNUSP}}== |
=={{header|SNUSP}}== |
||
< |
<syntaxhighlight lang="snusp">++++++++++>++++++++++!/- @!\=@\.@@@-@-----# atoi |
||
\n counter #\?>.</ \ @@@+@+++++# itoa |
\n counter #\?>.</ \ @@@+@+++++# itoa |
||
loop</ |
loop</syntaxhighlight> |
||
=={{header|Sparkling}}== |
=={{header|Sparkling}}== |
||
< |
<syntaxhighlight lang="sparkling">for var i = 10; i >= 0; i-- { |
||
print(i); |
print(i); |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Spin}}== |
=={{header|Spin}}== |
||
Line 2,059: | Line 2,059: | ||
{{works with|HomeSpun}} |
{{works with|HomeSpun}} |
||
{{works with|OpenSpin}} |
{{works with|OpenSpin}} |
||
< |
<syntaxhighlight lang="spin">con |
||
_clkmode = xtal1 + pll16x |
_clkmode = xtal1 + pll16x |
||
_clkfreq = 80_000_000 |
_clkfreq = 80_000_000 |
||
Line 2,075: | Line 2,075: | ||
waitcnt(_clkfreq + cnt) |
waitcnt(_clkfreq + cnt) |
||
ser.stop |
ser.stop |
||
cogstop(0)</ |
cogstop(0)</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>10 9 8 7 6 5 4 3 2 1 0</pre> |
<pre>10 9 8 7 6 5 4 3 2 1 0</pre> |
||
=={{header|SPL}}== |
=={{header|SPL}}== |
||
< |
<syntaxhighlight lang="spl">> i, 10..0,-1 |
||
#.output(i) |
#.output(i) |
||
<</ |
<</syntaxhighlight> |
||
=={{header|SSEM}}== |
=={{header|SSEM}}== |
||
The SSEM can't print, so the results are stored in an array at addresses 22 to 31. Array access is done using self-modifying code: on each iteration we subtract the current value of <tt>n</tt> (stored at address 18) from the illegal instruction <tt>c to 32</tt>, yielding the actual instruction we use to store <tt>n</tt> into the array. |
The SSEM can't print, so the results are stored in an array at addresses 22 to 31. Array access is done using self-modifying code: on each iteration we subtract the current value of <tt>n</tt> (stored at address 18) from the illegal instruction <tt>c to 32</tt>, yielding the actual instruction we use to store <tt>n</tt> into the array. |
||
< |
<syntaxhighlight lang="ssem">10001000000000100000000000000000 0. -17 to c |
||
11001000000001100000000000000000 1. c to 19 |
11001000000001100000000000000000 1. c to 19 |
||
11001000000000100000000000000000 2. -19 to c |
11001000000000100000000000000000 2. -19 to c |
||
Line 2,104: | Line 2,104: | ||
11111111111111111111111111111111 16. -1 |
11111111111111111111111111111111 16. -1 |
||
00000100000001100000000000000000 17. c to 32 |
00000100000001100000000000000000 17. c to 32 |
||
01010000000000000000000000000000 18. 10</ |
01010000000000000000000000000000 18. 10</syntaxhighlight> |
||
=={{header|Stata}}== |
=={{header|Stata}}== |
||
See '''[https://www.stata.com/help.cgi?forvalues forvalues]''' and '''[https://www.stata.com/help.cgi?foreach foreach]''' in Stata help. |
See '''[https://www.stata.com/help.cgi?forvalues forvalues]''' and '''[https://www.stata.com/help.cgi?foreach foreach]''' in Stata help. |
||
< |
<syntaxhighlight lang="stata">forvalues n=10(-1)0 { |
||
display `n' |
display `n' |
||
} |
} |
||
Line 2,119: | Line 2,119: | ||
foreach n of numlist 10/0 { |
foreach n of numlist 10/0 { |
||
display `n' |
display `n' |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Swift}}== |
=={{header|Swift}}== |
||
< |
<syntaxhighlight lang="swift">for i in stride(from: 10, through: 0, by: -1) { |
||
println(i) |
println(i) |
||
}</ |
}</syntaxhighlight> |
||
Alternately: |
Alternately: |
||
< |
<syntaxhighlight lang="swift">for i in lazy(0...10).reverse() { |
||
println(i) |
println(i) |
||
}</ |
}</syntaxhighlight> |
||
In Swift 1.2 Alternately: |
In Swift 1.2 Alternately: |
||
< |
<syntaxhighlight lang="swift">for i in reverse(0 ... 10) { |
||
println(i) |
println(i) |
||
}</ |
}</syntaxhighlight> |
||
Alternately (removed in Swift 3): |
Alternately (removed in Swift 3): |
||
< |
<syntaxhighlight lang="swift">for var i = 10; i >= 0; i-- { |
||
println(i) |
println(i) |
||
}</ |
}</syntaxhighlight> |
||
Swift 3: |
Swift 3: |
||
< |
<syntaxhighlight lang="swift">for i in (0...10).reversed() { |
||
print(i) |
print(i) |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Tailspin}}== |
=={{header|Tailspin}}== |
||
Not really a for-loop, but it sends a stream of values where each gets treated the same way. |
Not really a for-loop, but it sends a stream of values where each gets treated the same way. |
||
< |
<syntaxhighlight lang="tailspin"> |
||
10..0:-1 -> '$; |
10..0:-1 -> '$; |
||
' -> !OUT::write |
' -> !OUT::write |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Tcl}}== |
=={{header|Tcl}}== |
||
< |
<syntaxhighlight lang="tcl">for {set i 10} {$i >= 0} {incr i -1} { |
||
puts $i |
puts $i |
||
} |
} |
||
# puts "We have liftoff!"</ |
# puts "We have liftoff!"</syntaxhighlight> |
||
=={{header|Trith}}== |
=={{header|Trith}}== |
||
< |
<syntaxhighlight lang="trith">10 inc iota reverse [print] each</syntaxhighlight> |
||
< |
<syntaxhighlight lang="trith">10 [dup print dec] [dup 0 >=] while drop</syntaxhighlight> |
||
=={{header|TUSCRIPT}}== |
=={{header|TUSCRIPT}}== |
||
< |
<syntaxhighlight lang="tuscript"> |
||
$$ MODE TUSCRIPT |
$$ MODE TUSCRIPT |
||
LOOP n=10,0,-1 |
LOOP n=10,0,-1 |
||
PRINT n |
PRINT n |
||
ENDLOOP |
ENDLOOP |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|UNIX Shell}}== |
=={{header|UNIX Shell}}== |
||
{{works with|Bourne Shell}} |
{{works with|Bourne Shell}} |
||
< |
<syntaxhighlight lang="bash">i=10 |
||
while test $i -ge 0; do |
while test $i -ge 0; do |
||
echo $i |
echo $i |
||
Line 2,181: | Line 2,181: | ||
# or |
# or |
||
seq 10 -1 0</ |
seq 10 -1 0</syntaxhighlight> |
||
---- |
---- |
||
{{works with|bash}} |
{{works with|bash}} |
||
< |
<syntaxhighlight lang="bash">for(( Z=10; Z>=0; Z-- )); do |
||
echo $Z |
echo $Z |
||
done |
done |
||
Line 2,194: | Line 2,194: | ||
echo $Z |
echo $Z |
||
done |
done |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|UnixPipes}}== |
=={{header|UnixPipes}}== |
||
{{works with|OpenBSD|4.9}} |
{{works with|OpenBSD|4.9}} |
||
< |
<syntaxhighlight lang="bash">yes '' | cat -n | head -n 11 | while read n; do |
||
expr $n - 1 |
expr $n - 1 |
||
done | tail -r</ |
done | tail -r</syntaxhighlight> |
||
This pipe uses several nonstandard commands: <code>cat -n</code> and <code>tail -r</code> might not work with some systems. |
This pipe uses several nonstandard commands: <code>cat -n</code> and <code>tail -r</code> might not work with some systems. |
||
Line 2,206: | Line 2,206: | ||
=={{header|Ursa}}== |
=={{header|Ursa}}== |
||
< |
<syntaxhighlight lang="ursa">decl int i |
||
for (set i 10) (> i -1) (dec i) |
for (set i 10) (> i -1) (dec i) |
||
out i endl console |
out i endl console |
||
end for</ |
end for</syntaxhighlight> |
||
=={{header|V}}== |
=={{header|V}}== |
||
< |
<syntaxhighlight lang="v">10 |
||
[0 >] |
[0 >] |
||
[dup puts pred] |
[dup puts pred] |
||
while</ |
while</syntaxhighlight> |
||
=={{header|Vala}}== |
=={{header|Vala}}== |
||
< |
<syntaxhighlight lang="vala">for (int i = 10; i >= 0; --i) |
||
stdout.printf("%d\n", i);</ |
stdout.printf("%d\n", i);</syntaxhighlight> |
||
=={{header|VBA}}== |
=={{header|VBA}}== |
||
< |
<syntaxhighlight lang="vb">For i = 10 To 0 Step -1 |
||
Debug.Print i |
Debug.Print i |
||
Next i</ |
Next i</syntaxhighlight> |
||
=={{header|Vedit macro language}}== |
=={{header|Vedit macro language}}== |
||
< |
<syntaxhighlight lang="vedit">for (#1 = 10; #1 >= 0; #1--) { |
||
Num_Type(#1) |
Num_Type(#1) |
||
}</ |
}</syntaxhighlight> |
||
=={{header|Verilog}}== |
=={{header|Verilog}}== |
||
<syntaxhighlight lang="verilog"> |
|||
<lang Verilog> |
|||
module main; |
module main; |
||
integer i; |
integer i; |
||
Line 2,242: | Line 2,242: | ||
end |
end |
||
endmodule |
endmodule |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Visual Basic .NET}}== |
=={{header|Visual Basic .NET}}== |
||
< |
<syntaxhighlight lang="vbnet">For i = 10 To 0 Step -1 |
||
Console.WriteLine(i) |
Console.WriteLine(i) |
||
Next</ |
Next</syntaxhighlight> |
||
=={{header|Vlang}}== |
=={{header|Vlang}}== |
||
< |
<syntaxhighlight lang="vlang">fn main() { |
||
for i := 10; i >= 0; i-- { |
for i := 10; i >= 0; i-- { |
||
print('$i ') |
print('$i ') |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 2,262: | Line 2,262: | ||
=={{header|Wart}}== |
=={{header|Wart}}== |
||
<lang>for i 10 (i >= 0) --i |
<syntaxhighlight lang="text">for i 10 (i >= 0) --i |
||
prn i</ |
prn i</syntaxhighlight> |
||
=={{header|Wren}}== |
=={{header|Wren}}== |
||
< |
<syntaxhighlight lang="ecmascript">for (i in 10..0) System.write("%(i) ") |
||
System.print()</ |
System.print()</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 2,275: | Line 2,275: | ||
=={{header|XPL0}}== |
=={{header|XPL0}}== |
||
< |
<syntaxhighlight lang="xpl0">include c:\cxpl\codes; \intrinsic 'code' declarations |
||
int I; |
int I; |
||
for I:= 10 downto 0 do |
for I:= 10 downto 0 do |
||
[IntOut(0, I); CrLf(0)]</ |
[IntOut(0, I); CrLf(0)]</syntaxhighlight> |
||
=={{header|Z80 Assembly}}== |
=={{header|Z80 Assembly}}== |
||
Because of the way looping typically works in hardware, as well as 10 being two digits, it's more efficient to only print numbers 9 through 1 in the loop body, and do the rest outside it. |
Because of the way looping typically works in hardware, as well as 10 being two digits, it's more efficient to only print numbers 9 through 1 in the loop body, and do the rest outside it. |
||
< |
<syntaxhighlight lang="z80">org &1000 |
||
LD A,'1' |
LD A,'1' |
||
Line 2,298: | Line 2,298: | ||
LD A,'0' |
LD A,'0' |
||
JP &BB5A ;its RET returns to BASIC for us.</ |
JP &BB5A ;its RET returns to BASIC for us.</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 2,313: | Line 2,313: | ||
=={{header|zkl}}== |
=={{header|zkl}}== |
||
< |
<syntaxhighlight lang="zkl">foreach n in ([10..0,-1]){ println(n) } |
||
[10..0,-1].apply() //-->L(10,9,8,7,6,5,4,3,2,1,0) |
[10..0,-1].apply() //-->L(10,9,8,7,6,5,4,3,2,1,0) |
||
// tail recursion |
// tail recursion |
||
fcn(n){ n.println(); if(n==0)return(); return(self.fcn(n-1)) }(10)</ |
fcn(n){ n.println(); if(n==0)return(); return(self.fcn(n-1)) }(10)</syntaxhighlight> |
||
=={{header|Zig}}== |
=={{header|Zig}}== |
||
< |
<syntaxhighlight lang="zig">const std = @import("std"); |
||
pub fn main() !void { |
pub fn main() !void { |
||
Line 2,327: | Line 2,327: | ||
try std.io.getStdOut().writer().print("{d}\n", .{i}); |
try std.io.getStdOut().writer().print("{d}\n", .{i}); |
||
} |
} |
||
}</ |
}</syntaxhighlight> |