Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
5
Task/Loops-Downward-for/00-META.yaml
Normal file
5
Task/Loops-Downward-for/00-META.yaml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
category:
|
||||
- Simple
|
||||
from: http://rosettacode.org/wiki/Loops/Downward_for
|
||||
note: Iteration
|
||||
22
Task/Loops-Downward-for/00-TASK.txt
Normal file
22
Task/Loops-Downward-for/00-TASK.txt
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
;Task:
|
||||
Write a <big><big> ''for'' </big></big> loop which writes a countdown from '''10''' to '''0'''.
|
||||
|
||||
|
||||
;Related tasks:
|
||||
* [[Loop over multiple arrays simultaneously]]
|
||||
* [[Loops/Break]]
|
||||
* [[Loops/Continue]]
|
||||
* [[Loops/Do-while]]
|
||||
* [[Loops/Downward for]]
|
||||
* [[Loops/For]]
|
||||
* [[Loops/For with a specified step]]
|
||||
* [[Loops/Foreach]]
|
||||
* [[Loops/Increment loop index within loop body]]
|
||||
* [[Loops/Infinite]]
|
||||
* [[Loops/N plus one half]]
|
||||
* [[Loops/Nested]]
|
||||
* [[Loops/While]]
|
||||
* [[Loops/with multiple ranges]]
|
||||
* [[Loops/Wrong ranges]]
|
||||
<br><br>
|
||||
|
||||
2
Task/Loops-Downward-for/11l/loops-downward-for.11l
Normal file
2
Task/Loops-Downward-for/11l/loops-downward-for.11l
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
L(i) (10..0).step(-1)
|
||||
print(i)
|
||||
26
Task/Loops-Downward-for/360-Assembly/loops-downward-for.360
Normal file
26
Task/Loops-Downward-for/360-Assembly/loops-downward-for.360
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
* Loops/Downward for 27/07/2015
|
||||
LOOPDOWN CSECT
|
||||
USING LOOPDOWN,R12
|
||||
LR R12,R15 set base register
|
||||
BEGIN EQU *
|
||||
* fisrt loop with a BXLE BXLE: Branch on indeX Low or Equal
|
||||
LH R2,=H'11' from 10 (R2=11) index
|
||||
LH R4,=H'-1' step -1 (R4=-1)
|
||||
LH R5,=H'-1' to 0 (R5=-1)
|
||||
LOOPI BXLE R2,R4,ELOOPI R2=R2+R4 if R2<=R5 goto ELOOPI
|
||||
XDECO R2,BUFFER edit R2
|
||||
XPRNT BUFFER,L'BUFFER print
|
||||
B LOOPI
|
||||
ELOOPI EQU *
|
||||
* second loop with a BCT BCT: Branch on CounT
|
||||
LA R2,10 index R2=10
|
||||
LA R3,11 counter R3=11
|
||||
LOOPJ XDECO R2,BUFFER edit R2
|
||||
XPRNT BUFFER,L'BUFFER print
|
||||
BCTR R2,0 R2=R2-1
|
||||
ELOOPJ BCT R3,LOOPJ R3=R3-1 if R3<>0 goto LOOPI
|
||||
RETURN XR R15,R15 set return code
|
||||
BR R14 return to caller
|
||||
BUFFER DC CL80' '
|
||||
YREGS
|
||||
END LOOPDOWN
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
;An OS/hardware specific routine that is setup to display the Ascii character
|
||||
;value contained in the Accumulator
|
||||
Send = $9000 ;routine not implemented here
|
||||
PrintNewLine = $9050 ;routine not implemented here
|
||||
|
||||
*= $8000 ;set base address
|
||||
Start PHA ;push Accumulator and Y register onto stack
|
||||
TYA
|
||||
PHA
|
||||
LDY #10 ;set Y register to loop start value
|
||||
TYA ;place loop value in the Accumulator
|
||||
Loop JSR PrintTwoDigits
|
||||
JSR PrintNewLine
|
||||
DEY ;decrement loop value
|
||||
BPL Loop ;continue loop if sign flag is clear
|
||||
PLA ;pop Y register and Accumulator off of stack
|
||||
TAY
|
||||
PLA
|
||||
RTS ;exit
|
||||
|
||||
;Print value in Accumulator as two hex digits
|
||||
PrintTwoDigits
|
||||
PHA
|
||||
LSR
|
||||
LSR
|
||||
LSR
|
||||
LSR
|
||||
JSR PrintDigit
|
||||
PLA
|
||||
AND #$0F
|
||||
JSR PrintDigit
|
||||
RTS
|
||||
|
||||
;Convert value in Accumulator to an Ascii hex digit
|
||||
PrintDigit
|
||||
ORA #$30
|
||||
JSR Send ;routine not implemented here
|
||||
RTS
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
ForLoop:
|
||||
MOVE.W #10,D0
|
||||
loop:
|
||||
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
|
||||
rts
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
;-------------------------------------------------------
|
||||
; some useful equates
|
||||
;-------------------------------------------------------
|
||||
bdos equ 5h ; location ofjump to BDOS entry point
|
||||
wboot equ 0 ; BDOS warm boot function
|
||||
conout equ 2 ; write character to console
|
||||
;-------------------------------------------------------
|
||||
; main code
|
||||
;-------------------------------------------------------
|
||||
org 100h
|
||||
lxi sp,stack ; set up a stack
|
||||
;
|
||||
lxi h,10 ; starting value for countdown
|
||||
loop: call putdec ; print it
|
||||
mvi a,' ' ; space between numbers
|
||||
call putchr
|
||||
dcx h ; decrease count by 1
|
||||
mov a,h ; are we done (HL = 0)?
|
||||
ora l
|
||||
jnz loop ; no, so continue with next number
|
||||
jmp wboot ; otherwise exit to operating system
|
||||
;-------------------------------------------------------
|
||||
; console output of char in A register
|
||||
; preserves BC, DE, HL
|
||||
;-------------------------------------------------------
|
||||
putchr: push h
|
||||
push d
|
||||
push b
|
||||
mov e,a
|
||||
mvi c,conout
|
||||
call bdos
|
||||
pop b
|
||||
pop d
|
||||
pop h
|
||||
ret
|
||||
;---------------------------------------------------------
|
||||
; Decimal output to console routine
|
||||
; HL holds 16-bit unsigned binary number to print
|
||||
; Preserves BC, DE, HL
|
||||
;---------------------------------------------------------
|
||||
putdec: push b
|
||||
push d
|
||||
push h
|
||||
lxi b,-10
|
||||
lxi d,-1
|
||||
putdec2:
|
||||
dad b
|
||||
inx d
|
||||
jc putdec2
|
||||
lxi b,10
|
||||
dad b
|
||||
xchg
|
||||
mov a,h
|
||||
ora l
|
||||
cnz putdec ; recursive call!
|
||||
mov a,e
|
||||
adi '0' ; make printable
|
||||
call putchr
|
||||
pop h
|
||||
pop d
|
||||
pop b
|
||||
ret
|
||||
;----------------------------------------------------------
|
||||
; data area
|
||||
;----------------------------------------------------------
|
||||
stack equ $+128 ; 64-level stack to support recursion
|
||||
;
|
||||
end
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
.model small ;.exe file, max 128 KB
|
||||
.stack 1024 ;reserve 1 KB for the stack pointer.
|
||||
|
||||
.data
|
||||
|
||||
;no data needed
|
||||
|
||||
.code
|
||||
start:
|
||||
|
||||
mov ax,0100h ;UNPACKED BCD "10"
|
||||
mov cx,0Bh ;loop counter
|
||||
|
||||
repeat_countdown:
|
||||
call PrintBCD_IgnoreLeadingZeroes
|
||||
sub ax,1
|
||||
aas
|
||||
;ascii adjust for subtraction, normally 0100h - 1 = 0FFh but this corrects it to 0009h
|
||||
push ax
|
||||
mov dl,13
|
||||
mov ah,02h
|
||||
int 21h
|
||||
|
||||
mov dl,10
|
||||
mov ah,02h
|
||||
int 21h
|
||||
;these 6 lines of code are the "new line" function
|
||||
pop ax
|
||||
loop repeat_countdown ;decrement CX and jump back to the label "repeat_countdown" if CX != 0
|
||||
|
||||
|
||||
|
||||
mov ax,4C00h
|
||||
int 21h ;return to DOS
|
||||
|
||||
PrintBCD_IgnoreLeadingZeroes:
|
||||
push ax
|
||||
cmp ah,0
|
||||
jz skipLeadingZero
|
||||
or ah,30h ;convert a binary-coded decimal quantity to an ASCII numeral
|
||||
push dx
|
||||
push ax
|
||||
mov al,ah
|
||||
mov ah,0Eh
|
||||
int 10h ;prints AL to screen
|
||||
pop ax
|
||||
pop dx
|
||||
skipLeadingZero:
|
||||
or al,30h
|
||||
push dx
|
||||
push ax
|
||||
mov ah,0Eh
|
||||
int 10h
|
||||
pop ax
|
||||
pop dx
|
||||
pop ax
|
||||
ret
|
||||
|
||||
end start ;EOF
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
/* ARM assembly AARCH64 Raspberry PI 3B */
|
||||
/* program loopdownward64.s */
|
||||
|
||||
/*******************************************/
|
||||
/* Constantes file */
|
||||
/*******************************************/
|
||||
/* for this file see task include a file in language AArch64 assembly*/
|
||||
.include "../includeConstantesARM64.inc"
|
||||
|
||||
/*********************************/
|
||||
/* Initialized data */
|
||||
/*********************************/
|
||||
.data
|
||||
szMessResult: .asciz "Counter = @ \n" // message result
|
||||
|
||||
/*********************************/
|
||||
/* UnInitialized data */
|
||||
/*********************************/
|
||||
.bss
|
||||
sZoneConv: .skip 24
|
||||
/*********************************/
|
||||
/* code section */
|
||||
/*********************************/
|
||||
.text
|
||||
.global main
|
||||
main: // entry of program
|
||||
mov x4,#10
|
||||
1: // begin loop
|
||||
mov x0,x4
|
||||
ldr x1,qAdrsZoneConv // display value
|
||||
bl conversion10 // call decimal conversion
|
||||
ldr x0,qAdrszMessResult
|
||||
ldr x1,qAdrsZoneConv // display value
|
||||
bl strInsertAtCharInc // insert result at @ character
|
||||
bl affichageMess // display message
|
||||
subs x4,x4,1 // decrement counter
|
||||
bge 1b // loop if greather
|
||||
|
||||
100: // standard end of the program
|
||||
mov x0,0 // return code
|
||||
mov x8,EXIT // request to exit program
|
||||
svc 0 // perform the system call
|
||||
|
||||
qAdrsZoneConv: .quad sZoneConv
|
||||
qAdrszMessResult: .quad szMessResult
|
||||
/********************************************************/
|
||||
/* File Include fonctions */
|
||||
/********************************************************/
|
||||
/* for this file see task include a file in language AArch64 assembly */
|
||||
.include "../includeARM64.inc"
|
||||
5
Task/Loops-Downward-for/ALGOL-60/loops-downward-for.alg
Normal file
5
Task/Loops-Downward-for/ALGOL-60/loops-downward-for.alg
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
'BEGIN' 'COMMENT' Loops/Downward for - Algol60 - 23/06/2018;
|
||||
'INTEGER' I;
|
||||
'FOR' I := 10 'STEP' -1 'UNTIL' 0 'DO'
|
||||
OUTINTEGER(1,I)
|
||||
'END'
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
FOR i FROM 10 BY -1 TO 0 DO
|
||||
print((i,new line))
|
||||
OD
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
FOR i FROM 10 DOWNTO 0 DO
|
||||
print((i,new line))
|
||||
OD
|
||||
12
Task/Loops-Downward-for/ALGOL-M/loops-downward-for.alg
Normal file
12
Task/Loops-Downward-for/ALGOL-M/loops-downward-for.alg
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
begin
|
||||
|
||||
integer i;
|
||||
|
||||
i := 10;
|
||||
while (i > 0) do
|
||||
begin
|
||||
writeon(i);
|
||||
i := i - 1;
|
||||
end;
|
||||
|
||||
end
|
||||
6
Task/Loops-Downward-for/ALGOL-W/loops-downward-for.alg
Normal file
6
Task/Loops-Downward-for/ALGOL-W/loops-downward-for.alg
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
begin
|
||||
for i := 10 step -1 until 0 do
|
||||
begin
|
||||
write( i )
|
||||
end
|
||||
end.
|
||||
111
Task/Loops-Downward-for/ARM-Assembly/loops-downward-for.arm
Normal file
111
Task/Loops-Downward-for/ARM-Assembly/loops-downward-for.arm
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
/* ARM assembly Raspberry PI */
|
||||
/* program loopdownward.s */
|
||||
|
||||
/* Constantes */
|
||||
.equ STDOUT, 1 @ Linux output console
|
||||
.equ EXIT, 1 @ Linux syscall
|
||||
.equ WRITE, 4 @ Linux syscall
|
||||
|
||||
/*********************************/
|
||||
/* Initialized data */
|
||||
/*********************************/
|
||||
.data
|
||||
szMessResult: .ascii "Counter = " @ message result
|
||||
sMessValeur: .fill 12, 1, ' '
|
||||
.asciz "\n"
|
||||
/*********************************/
|
||||
/* UnInitialized data */
|
||||
/*********************************/
|
||||
.bss
|
||||
/*********************************/
|
||||
/* code section */
|
||||
/*********************************/
|
||||
.text
|
||||
.global main
|
||||
main: @ entry of program
|
||||
push {fp,lr} @ saves 2 registers
|
||||
mov r4,#10
|
||||
1: @ begin loop
|
||||
mov r0,r4
|
||||
ldr r1,iAdrsMessValeur @ display value
|
||||
bl conversion10 @ call function with 2 parameter (r0,r1)
|
||||
ldr r0,iAdrszMessResult
|
||||
bl affichageMess @ display message
|
||||
subs r4,#1 @ decrement counter
|
||||
bge 1b @ loop if greather
|
||||
|
||||
100: @ standard end of the program
|
||||
mov r0, #0 @ return code
|
||||
pop {fp,lr} @restaur 2 registers
|
||||
mov r7, #EXIT @ request to exit program
|
||||
svc #0 @ perform the system call
|
||||
|
||||
iAdrsMessValeur: .int sMessValeur
|
||||
iAdrszMessResult: .int szMessResult
|
||||
/******************************************************************/
|
||||
/* display text with size calculation */
|
||||
/******************************************************************/
|
||||
/* r0 contains the address of the message */
|
||||
affichageMess:
|
||||
push {r0,r1,r2,r7,lr} @ save registres
|
||||
mov r2,#0 @ counter length
|
||||
1: @ loop length calculation
|
||||
ldrb r1,[r0,r2] @ read octet start position + index
|
||||
cmp r1,#0 @ if 0 its over
|
||||
addne r2,r2,#1 @ else add 1 in the length
|
||||
bne 1b @ and loop
|
||||
@ so here r2 contains the length of the message
|
||||
mov r1,r0 @ address message in r1
|
||||
mov r0,#STDOUT @ code to write to the standard output Linux
|
||||
mov r7, #WRITE @ code call system "write"
|
||||
svc #0 @ call systeme
|
||||
pop {r0,r1,r2,r7,lr} @ restaur des 2 registres */
|
||||
bx lr @ return
|
||||
/******************************************************************/
|
||||
/* Converting a register to a decimal */
|
||||
/******************************************************************/
|
||||
/* r0 contains value and r1 address area */
|
||||
conversion10:
|
||||
push {r1-r4,lr} @ save registers
|
||||
mov r3,r1
|
||||
mov r2,#10
|
||||
|
||||
1: @ start loop
|
||||
bl divisionpar10 @ r0 <- dividende. quotient ->r0 reste -> r1
|
||||
add r1,#48 @ digit
|
||||
strb r1,[r3,r2] @ store digit on area
|
||||
sub r2,#1 @ previous position
|
||||
cmp r0,#0 @ stop if quotient = 0 */
|
||||
bne 1b @ else loop
|
||||
@ and move spaces in first on area
|
||||
mov r1,#' ' @ space
|
||||
2:
|
||||
strb r1,[r3,r2] @ store space in area
|
||||
subs r2,#1 @ @ previous position
|
||||
bge 2b @ loop if r2 >= zéro
|
||||
|
||||
100:
|
||||
pop {r1-r4,lr} @ restaur registres
|
||||
bx lr @return
|
||||
/***************************************************/
|
||||
/* division par 10 signé */
|
||||
/* Thanks to http://thinkingeek.com/arm-assembler-raspberry-pi/*
|
||||
/* and http://www.hackersdelight.org/ */
|
||||
/***************************************************/
|
||||
/* r0 dividende */
|
||||
/* r0 quotient */
|
||||
/* r1 remainder */
|
||||
divisionpar10:
|
||||
/* r0 contains the argument to be divided by 10 */
|
||||
push {r2-r4} /* save registers */
|
||||
mov r4,r0
|
||||
mov r3,#0x6667 @ r3 <- magic_number lower
|
||||
movt r3,#0x6666 @ r3 <- magic_number upper
|
||||
smull r1, r2, r3, r0 @ r1 <- Lower32Bits(r1*r0). r2 <- Upper32Bits(r1*r0)
|
||||
mov r2, r2, ASR #2 /* r2 <- r2 >> 2 */
|
||||
mov r1, r0, LSR #31 /* r1 <- r0 >> 31 */
|
||||
add r0, r2, r1 /* r0 <- r2 + r1 */
|
||||
add r2,r0,r0, lsl #2 /* r2 <- r0 * 5 */
|
||||
sub r1,r4,r2, lsl #1 /* r1 <- r4 - (r2 * 2) = r4 - (r0 * 10) */
|
||||
pop {r2-r4}
|
||||
bx lr /* leave function */
|
||||
5
Task/Loops-Downward-for/AWK/loops-downward-for.awk
Normal file
5
Task/Loops-Downward-for/AWK/loops-downward-for.awk
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
BEGIN {
|
||||
for(i=10; i>=0; i--) {
|
||||
print i
|
||||
}
|
||||
}
|
||||
3
Task/Loops-Downward-for/Ada/loops-downward-for.ada
Normal file
3
Task/Loops-Downward-for/Ada/loops-downward-for.ada
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
for I in reverse 0..10 loop
|
||||
Put_Line(Integer'Image(I));
|
||||
end loop;
|
||||
3
Task/Loops-Downward-for/Agena/loops-downward-for.agena
Normal file
3
Task/Loops-Downward-for/Agena/loops-downward-for.agena
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
for i from 10 downto 0 do
|
||||
print( i )
|
||||
od
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#include <flow.h>
|
||||
|
||||
DEF-MAIN
|
||||
CLR-SCR
|
||||
SET(i, 10)
|
||||
LOOP(ciclo abajo)
|
||||
PRNL(i)
|
||||
BACK-IF-NOT-ZERO(i--, ciclo abajo)
|
||||
END
|
||||
6
Task/Loops-Downward-for/AmigaE/loops-downward-for.amiga
Normal file
6
Task/Loops-Downward-for/AmigaE/loops-downward-for.amiga
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
PROC main()
|
||||
DEF i
|
||||
FOR i := 10 TO 0 STEP -1
|
||||
WriteF('\d\n', i)
|
||||
ENDFOR
|
||||
ENDPROC
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
repeat with i from 10 to 0 by -1
|
||||
log i
|
||||
end repeat
|
||||
|
|
@ -0,0 +1 @@
|
|||
FOR I = 10 TO 0 STEP -1 : PRINT I : NEXT I
|
||||
3
Task/Loops-Downward-for/Arturo/loops-downward-for.arturo
Normal file
3
Task/Loops-Downward-for/Arturo/loops-downward-for.arturo
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
loop 10..0 'i [
|
||||
print i
|
||||
]
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
for(int i = 10; i >=0; --i) {
|
||||
write(i);
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
x := 10
|
||||
While (x >= 0)
|
||||
{
|
||||
output .= "`n" . x
|
||||
x--
|
||||
}
|
||||
MsgBox % output
|
||||
1
Task/Loops-Downward-for/Avail/loops-downward-for.avail
Normal file
1
Task/Loops-Downward-for/Avail/loops-downward-for.avail
Normal file
|
|
@ -0,0 +1 @@
|
|||
For each i from 10 to 0 by -1 do [Print: “i” ++ "\n";];
|
||||
3
Task/Loops-Downward-for/Axe/loops-downward-for.axe
Normal file
3
Task/Loops-Downward-for/Axe/loops-downward-for.axe
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
For(I,0,10)
|
||||
Disp 10-I▶Dec,i
|
||||
End
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
for i = 10 to 0 step -1
|
||||
print i; " ";
|
||||
next i
|
||||
print
|
||||
end
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
FOR i% = 10 TO 0 STEP -1
|
||||
PRINT i%
|
||||
NEXT
|
||||
1
Task/Loops-Downward-for/BQN/loops-downward-for.bqn
Normal file
1
Task/Loops-Downward-for/BQN/loops-downward-for.bqn
Normal file
|
|
@ -0,0 +1 @@
|
|||
•Show¨⌽↕11
|
||||
2
Task/Loops-Downward-for/BaCon/loops-downward-for.bacon
Normal file
2
Task/Loops-Downward-for/BaCon/loops-downward-for.bacon
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
' Downward for
|
||||
FOR i = 10 DOWNTO 0 : PRINT i : NEXT
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
@echo off
|
||||
for /l %%D in (10,-1,0) do echo %%D
|
||||
2
Task/Loops-Downward-for/Bc/loops-downward-for.bc
Normal file
2
Task/Loops-Downward-for/Bc/loops-downward-for.bc
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
for (i = 10; i >= 0; i--) i
|
||||
quit
|
||||
2
Task/Loops-Downward-for/Befunge/loops-downward-for.bf
Normal file
2
Task/Loops-Downward-for/Befunge/loops-downward-for.bf
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
55+>:.:v
|
||||
@ ^ -1_
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
10:?i
|
||||
& whl'(out$!i&!i+-1:~<0:?i)
|
||||
7
Task/Loops-Downward-for/Brainf---/loops-downward-for.bf
Normal file
7
Task/Loops-Downward-for/Brainf---/loops-downward-for.bf
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
>++++++++[-<++++++>] //cell 0 now contains 48 the ASCII code for "0"
|
||||
<+.-. //print the digits 1 and 0
|
||||
>++++++++++. //cell 1 now contains the carriage return; print it!
|
||||
>+++++++++ //cell 2 now contains the number 9; this is our counter
|
||||
<<+++++++++>> //cell 0 now contains 57 the ASCII code for "9"
|
||||
[<<.->.>-] //print and decrement the display digit; print a newline; decrement the loop variable
|
||||
<<.>. //print the final 0 and a final newline
|
||||
1
Task/Loops-Downward-for/Brat/loops-downward-for.brat
Normal file
1
Task/Loops-Downward-for/Brat/loops-downward-for.brat
Normal file
|
|
@ -0,0 +1 @@
|
|||
10.to 0 { n | p n }
|
||||
2
Task/Loops-Downward-for/C++/loops-downward-for.cpp
Normal file
2
Task/Loops-Downward-for/C++/loops-downward-for.cpp
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
for(int i = 10; i >= 0; --i)
|
||||
std::cout << i << "\n";
|
||||
4
Task/Loops-Downward-for/C-sharp/loops-downward-for.cs
Normal file
4
Task/Loops-Downward-for/C-sharp/loops-downward-for.cs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
for (int i = 10; i >= 0; i--)
|
||||
{
|
||||
Console.WriteLine(i);
|
||||
}
|
||||
3
Task/Loops-Downward-for/C/loops-downward-for.c
Normal file
3
Task/Loops-Downward-for/C/loops-downward-for.c
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
int i;
|
||||
for(i = 10; i >= 0; --i)
|
||||
printf("%d\n",i);
|
||||
14
Task/Loops-Downward-for/COBOL/loops-downward-for.cobol
Normal file
14
Task/Loops-Downward-for/COBOL/loops-downward-for.cobol
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
identification division.
|
||||
program-id. countdown.
|
||||
environment division.
|
||||
data division.
|
||||
working-storage section.
|
||||
01 counter pic 99.
|
||||
88 counter-done value 0.
|
||||
01 counter-disp pic Z9.
|
||||
procedure division.
|
||||
perform with test after varying counter from 10 by -1 until counter-done
|
||||
move counter to counter-disp
|
||||
display counter-disp
|
||||
end-perform
|
||||
stop run.
|
||||
3
Task/Loops-Downward-for/Ceylon/loops-downward-for.ceylon
Normal file
3
Task/Loops-Downward-for/Ceylon/loops-downward-for.ceylon
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
for (i in 10..0) {
|
||||
print(i);
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
for i in 1..10 by -1 do
|
||||
writeln(i);
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
var r = 1..10;
|
||||
for i in r by -1 do { ... }
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
FOR i := 10 TO 0 STEP -1
|
||||
? i
|
||||
NEXT
|
||||
1
Task/Loops-Downward-for/Clojure/loops-downward-for.clj
Normal file
1
Task/Loops-Downward-for/Clojure/loops-downward-for.clj
Normal file
|
|
@ -0,0 +1 @@
|
|||
(doseq [x (range 10 -1 -1)] (println x))
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
# The more compact "array comprehension" style
|
||||
console.log i for i in [10..0]
|
||||
|
||||
# The "regular" for loop style.
|
||||
for i in [10..0]
|
||||
console.log i
|
||||
|
||||
# More compact version of the above
|
||||
for i in [10..0] then console.log i
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
<cfloop index = "i" from = "10" to = "0" step = "-1">
|
||||
#i#
|
||||
</cfloop>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<cfscript>
|
||||
for( i = 10; i <= 0; i-- )
|
||||
{
|
||||
writeOutput( i );
|
||||
}
|
||||
</cfscript>
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
10 FOR I = 10 TO 0 STEP -1
|
||||
20 PRINT I
|
||||
30 NEXT
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
(loop for i from 10 downto 1 do
|
||||
(print i))
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(do ((n 10 (decf n))) ; Initialize to 0 and downward in every loop
|
||||
((< n 0)) ; Break condition when negative
|
||||
(print n)) ; On every loop print value
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
(let ((count 10)) ; Create local variable count = 10
|
||||
(tagbody
|
||||
dec ; Create tag dec
|
||||
(print count) ; Prints count
|
||||
(decf count) ; Decreases count
|
||||
(if (not (< count 0)) ; Ends loop when negative
|
||||
(go dec)))) ; Loops back to tag dec
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
(defun down-to-0 (count)
|
||||
(print count)
|
||||
(if (not (zerop count))
|
||||
(down-to-0 (1- count))))
|
||||
(down-to-0 10)
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
LDA 28
|
||||
SUB 29
|
||||
STA 31
|
||||
STA 28
|
||||
BRZ 6 ;branch on zero to STP
|
||||
JMP 0
|
||||
STP
|
||||
...
|
||||
org 28
|
||||
byte 11
|
||||
byte 1
|
||||
byte 0
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
10.step(to: 0, by: -1).each { |i|
|
||||
puts i
|
||||
}
|
||||
10
Task/Loops-Downward-for/D/loops-downward-for.d
Normal file
10
Task/Loops-Downward-for/D/loops-downward-for.d
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import std.stdio: writeln;
|
||||
|
||||
void main() {
|
||||
for (int i = 10; i >= 0; --i)
|
||||
writeln(i);
|
||||
writeln();
|
||||
|
||||
foreach_reverse (i ; 0 .. 10 + 1)
|
||||
writeln(i);
|
||||
}
|
||||
2
Task/Loops-Downward-for/DWScript/loops-downward-for.dw
Normal file
2
Task/Loops-Downward-for/DWScript/loops-downward-for.dw
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
for i := 10 downto 0 do
|
||||
PrintLn(i);
|
||||
5
Task/Loops-Downward-for/Dart/loops-downward-for.dart
Normal file
5
Task/Loops-Downward-for/Dart/loops-downward-for.dart
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
void main() {
|
||||
for (var i = 10; i >= 0; --i) {
|
||||
print(i);
|
||||
}
|
||||
}
|
||||
13
Task/Loops-Downward-for/Dc/loops-downward-for-1.dc
Normal file
13
Task/Loops-Downward-for/Dc/loops-downward-for-1.dc
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
c
|
||||
|
||||
[macro s(swap) - (a b : b a)]s.
|
||||
[Sa Sb La Lb] ss
|
||||
|
||||
[macro d(2dup) - (a b : a b a b)]s.
|
||||
[Sa d Sb La d Lb lsx] sd
|
||||
|
||||
[macro m(for) - ]s.
|
||||
[lfx 1 - ldx !<m ] sm
|
||||
|
||||
0 10 ldx [p] sf !<m
|
||||
q
|
||||
5
Task/Loops-Downward-for/Dc/loops-downward-for-2.dc
Normal file
5
Task/Loops-Downward-for/Dc/loops-downward-for-2.dc
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
|dc < ./for.dc
|
||||
10
|
||||
9
|
||||
...
|
||||
0
|
||||
6
Task/Loops-Downward-for/Draco/loops-downward-for.draco
Normal file
6
Task/Loops-Downward-for/Draco/loops-downward-for.draco
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
proc nonrec main() void:
|
||||
byte i;
|
||||
for i from 10 downto 0 do
|
||||
write(i," ")
|
||||
od
|
||||
corp
|
||||
1
Task/Loops-Downward-for/E/loops-downward-for.e
Normal file
1
Task/Loops-Downward-for/E/loops-downward-for.e
Normal file
|
|
@ -0,0 +1 @@
|
|||
for i in (0..10).descending() { println(i) }
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
[ Loop with downward counter
|
||||
==========================
|
||||
|
||||
A program for the EDSAC
|
||||
|
||||
Prints the integers 10 down to 0
|
||||
|
||||
The counter is stored at address 20@
|
||||
|
||||
Its initial value is 9 * 2^12
|
||||
(9 in the high 5 bits, representing
|
||||
the character '9') and it counts
|
||||
down in steps of 2^12
|
||||
|
||||
Works with Initial Orders 2 ]
|
||||
|
||||
T56K [ set load point ]
|
||||
GK [ set base address ]
|
||||
|
||||
[ orders ]
|
||||
|
||||
O14@ [ print figure shift ]
|
||||
O15@ [ print '1' ]
|
||||
O16@ [ print '0' ]
|
||||
O17@ [ print CR ]
|
||||
O18@ [ print LF ]
|
||||
|
||||
[ 5 ] O20@ [ print c ]
|
||||
O17@ [ print CR ]
|
||||
O18@ [ print LF ]
|
||||
|
||||
T19@ [ acc := 0 ]
|
||||
A20@ [ acc += c ]
|
||||
S15@ [ acc -:= character '1' ]
|
||||
U20@ [ c := acc ]
|
||||
|
||||
E5@ [ branch on non-negative ]
|
||||
|
||||
ZF [ stop ]
|
||||
|
||||
[ constants ]
|
||||
|
||||
[ 14 ] #F [ πF -- figure shift ]
|
||||
[ 15 ] QF [ character '1' ]
|
||||
[ 16 ] PF [ character '0' ]
|
||||
[ 17 ] @F [ θF -- CR ]
|
||||
[ 18 ] &F [ ΔF -- LF ]
|
||||
|
||||
[ variables ]
|
||||
|
||||
[ 19 ] P0F [ used to clear acc ]
|
||||
[ 20 ] OF [ character c = '9' ]
|
||||
|
||||
EZPF [ start when loaded ]
|
||||
3
Task/Loops-Downward-for/EGL/loops-downward-for.egl
Normal file
3
Task/Loops-Downward-for/EGL/loops-downward-for.egl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
for ( i int from 10 to 0 decrement by 1 )
|
||||
SysLib.writeStdout( i );
|
||||
end
|
||||
3
Task/Loops-Downward-for/ERRE/loops-downward-for.erre
Normal file
3
Task/Loops-Downward-for/ERRE/loops-downward-for.erre
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
FOR I%=10 TO 0 STEP -1 DO
|
||||
PRINT(I%)
|
||||
END FOR
|
||||
3
Task/Loops-Downward-for/EasyLang/loops-downward-for.easy
Normal file
3
Task/Loops-Downward-for/EasyLang/loops-downward-for.easy
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
for i = 10 downto 0
|
||||
print i
|
||||
.
|
||||
3
Task/Loops-Downward-for/EchoLisp/loops-downward-for.l
Normal file
3
Task/Loops-Downward-for/EchoLisp/loops-downward-for.l
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(for ((longtemps-je-me-suis-couché-de-bonne-heure (in-range 10 -1 -1)))
|
||||
(write longtemps-je-me-suis-couché-de-bonne-heure))
|
||||
→ 10 9 8 7 6 5 4 3 2 1 0
|
||||
8
Task/Loops-Downward-for/Ela/loops-downward-for-1.ela
Normal file
8
Task/Loops-Downward-for/Ela/loops-downward-for-1.ela
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
open monad io
|
||||
|
||||
each [] = do return ()
|
||||
each (x::xs) = do
|
||||
putStrLn $ show x
|
||||
each xs
|
||||
|
||||
each [10,9..0] ::: IO
|
||||
8
Task/Loops-Downward-for/Ela/loops-downward-for-2.ela
Normal file
8
Task/Loops-Downward-for/Ela/loops-downward-for-2.ela
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
open monad io
|
||||
|
||||
countDown m n | n < m = do return ()
|
||||
| else = do
|
||||
putStrLn $ show n
|
||||
countDown m (n - 1)
|
||||
|
||||
_ = countDown 0 10 ::: IO
|
||||
13
Task/Loops-Downward-for/Elixir/loops-downward-for.elixir
Normal file
13
Task/Loops-Downward-for/Elixir/loops-downward-for.elixir
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
iex(1)> Enum.each(10..0, fn i -> IO.puts i end)
|
||||
10
|
||||
9
|
||||
8
|
||||
7
|
||||
6
|
||||
5
|
||||
4
|
||||
3
|
||||
2
|
||||
1
|
||||
0
|
||||
:ok
|
||||
14
Task/Loops-Downward-for/Erlang/loops-downward-for.erl
Normal file
14
Task/Loops-Downward-for/Erlang/loops-downward-for.erl
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
%% Implemented by Arjun Sunel
|
||||
-module(downward_loop).
|
||||
-export([main/0]).
|
||||
|
||||
main() ->
|
||||
for_loop(10).
|
||||
|
||||
for_loop(N) ->
|
||||
if N > 0 ->
|
||||
io:format("~p~n",[N] ),
|
||||
for_loop(N-1);
|
||||
true ->
|
||||
io:format("~p~n",[N])
|
||||
end.
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
for i = 10 to 0 by -1 do
|
||||
? i
|
||||
end for
|
||||
2
Task/Loops-Downward-for/F-Sharp/loops-downward-for-1.fs
Normal file
2
Task/Loops-Downward-for/F-Sharp/loops-downward-for-1.fs
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
for i in 10..-1..0 do
|
||||
printfn "%d" i
|
||||
2
Task/Loops-Downward-for/F-Sharp/loops-downward-for-2.fs
Normal file
2
Task/Loops-Downward-for/F-Sharp/loops-downward-for-2.fs
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
for i = 10 downto 0 do
|
||||
printfn "%d" i
|
||||
1
Task/Loops-Downward-for/FALSE/loops-downward-for.false
Normal file
1
Task/Loops-Downward-for/FALSE/loops-downward-for.false
Normal file
|
|
@ -0,0 +1 @@
|
|||
10[$0>][$." "1-]#.
|
||||
7
Task/Loops-Downward-for/FBSL/loops-downward-for.fbsl
Normal file
7
Task/Loops-Downward-for/FBSL/loops-downward-for.fbsl
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#APPTYPE CONSOLE
|
||||
|
||||
FOR DIM i = 10 DOWNTO 0
|
||||
PRINT i
|
||||
NEXT
|
||||
|
||||
PAUSE
|
||||
1
Task/Loops-Downward-for/Factor/loops-downward-for.factor
Normal file
1
Task/Loops-Downward-for/Factor/loops-downward-for.factor
Normal file
|
|
@ -0,0 +1 @@
|
|||
11 <iota> <reversed> [ . ] each
|
||||
10
Task/Loops-Downward-for/Fantom/loops-downward-for.fantom
Normal file
10
Task/Loops-Downward-for/Fantom/loops-downward-for.fantom
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
class DownwardFor
|
||||
{
|
||||
public static Void main ()
|
||||
{
|
||||
for (Int i := 10; i >= 0; i--)
|
||||
{
|
||||
echo (i)
|
||||
}
|
||||
}
|
||||
}
|
||||
1
Task/Loops-Downward-for/Fermat/loops-downward-for.fermat
Normal file
1
Task/Loops-Downward-for/Fermat/loops-downward-for.fermat
Normal file
|
|
@ -0,0 +1 @@
|
|||
for i = 10 to 0 by -1 do !!i; od
|
||||
1
Task/Loops-Downward-for/Forth/loops-downward-for.fth
Normal file
1
Task/Loops-Downward-for/Forth/loops-downward-for.fth
Normal file
|
|
@ -0,0 +1 @@
|
|||
: loop-down 0 10 do i . -1 +loop ;
|
||||
3
Task/Loops-Downward-for/Fortran/loops-downward-for-1.f
Normal file
3
Task/Loops-Downward-for/Fortran/loops-downward-for-1.f
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
DO i = 10, 0, -1
|
||||
WRITE(*, *) i
|
||||
END DO
|
||||
12
Task/Loops-Downward-for/Fortran/loops-downward-for-2.f
Normal file
12
Task/Loops-Downward-for/Fortran/loops-downward-for-2.f
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
PROGRAM DOWNWARDFOR
|
||||
C Initialize the loop parameters.
|
||||
INTEGER I, START, FINISH, STEP
|
||||
PARAMETER (START = 10, FINISH = 0, STEP = -1)
|
||||
|
||||
C If you were to leave off STEP, it would default to positive one.
|
||||
DO 10 I = START, FINISH, STEP
|
||||
WRITE (*,*) I
|
||||
10 CONTINUE
|
||||
|
||||
STOP
|
||||
END
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
' FB 1.05.0 Win64
|
||||
|
||||
For i As Integer = 10 To 0 Step -1
|
||||
Print i; " ";
|
||||
Next
|
||||
Print
|
||||
Sleep
|
||||
2
Task/Loops-Downward-for/Frink/loops-downward-for.frink
Normal file
2
Task/Loops-Downward-for/Frink/loops-downward-for.frink
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
for i = 10 to 0 step -1
|
||||
println[i]
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
window 1, @"Countdown", ( 0, 0, 400, 300 )
|
||||
|
||||
NSInteger i
|
||||
|
||||
for i = 10 to 0 step -1
|
||||
print i
|
||||
next
|
||||
|
||||
HandleEvents
|
||||
3
Task/Loops-Downward-for/GAP/loops-downward-for.gap
Normal file
3
Task/Loops-Downward-for/GAP/loops-downward-for.gap
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
for i in [10, 9 .. 0] do
|
||||
Print(i, "\n");
|
||||
od;
|
||||
2
Task/Loops-Downward-for/GML/loops-downward-for.gml
Normal file
2
Task/Loops-Downward-for/GML/loops-downward-for.gml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
for(i = 10; i >= 0; i -= 1)
|
||||
show_message(string(i))
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
10 FOR I% = 10 TO 0 STEP -1
|
||||
20 PRINT I%
|
||||
30 NEXT I%
|
||||
8
Task/Loops-Downward-for/Gambas/loops-downward-for.gambas
Normal file
8
Task/Loops-Downward-for/Gambas/loops-downward-for.gambas
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
Public Sub Main()
|
||||
Dim siCount As Short
|
||||
|
||||
For siCount = 10 DownTo 0
|
||||
Print siCount;;
|
||||
Next
|
||||
|
||||
End
|
||||
3
Task/Loops-Downward-for/Go/loops-downward-for-1.go
Normal file
3
Task/Loops-Downward-for/Go/loops-downward-for-1.go
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
for i := 10; i >= 0; i-- {
|
||||
fmt.Println(i)
|
||||
}
|
||||
14
Task/Loops-Downward-for/Go/loops-downward-for-2.go
Normal file
14
Task/Loops-Downward-for/Go/loops-downward-for-2.go
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
import "time"
|
||||
|
||||
func main() {
|
||||
i := 10
|
||||
for i > 0 {
|
||||
fmt.Println(i)
|
||||
time.Sleep(time.Second)
|
||||
i = i - 1
|
||||
}
|
||||
fmt.Println("blast off")
|
||||
}
|
||||
3
Task/Loops-Downward-for/Groovy/loops-downward-for.groovy
Normal file
3
Task/Loops-Downward-for/Groovy/loops-downward-for.groovy
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
for (i in (10..0)) {
|
||||
println i
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
FOR i := 10 TO 0 STEP -1
|
||||
? i
|
||||
NEXT
|
||||
4
Task/Loops-Downward-for/Haskell/loops-downward-for.hs
Normal file
4
Task/Loops-Downward-for/Haskell/loops-downward-for.hs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import Control.Monad
|
||||
|
||||
main :: IO ()
|
||||
main = forM_ [10,9 .. 0] print
|
||||
22
Task/Loops-Downward-for/Haxe/loops-downward-for.haxe
Normal file
22
Task/Loops-Downward-for/Haxe/loops-downward-for.haxe
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
class Step {
|
||||
var end:Int;
|
||||
var step:Int;
|
||||
var index:Int;
|
||||
|
||||
public inline function new(start:Int, end:Int, step:Int) {
|
||||
this.index = start;
|
||||
this.end = end;
|
||||
this.step = step;
|
||||
}
|
||||
|
||||
public inline function hasNext() return step > 0 ? end >= index : index >= end;
|
||||
public inline function next() return (index += step) - step;
|
||||
}
|
||||
|
||||
class Main {
|
||||
static function main() {
|
||||
for (i in new Step(10, 0, -1)) {
|
||||
Sys.print('$i ');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
for let i 10; i >= 0; i--
|
||||
println i
|
||||
endfor
|
||||
3
Task/Loops-Downward-for/HicEst/loops-downward-for.hicest
Normal file
3
Task/Loops-Downward-for/HicEst/loops-downward-for.hicest
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
DO i = 10, 0, -1
|
||||
WRITE() i
|
||||
ENDDO
|
||||
3
Task/Loops-Downward-for/HolyC/loops-downward-for.holyc
Normal file
3
Task/Loops-Downward-for/HolyC/loops-downward-for.holyc
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
I8 i;
|
||||
for (i = 10; i >= 0; --i)
|
||||
Print("%d\n", i);
|
||||
1
Task/Loops-Downward-for/IDL/loops-downward-for-1.idl
Normal file
1
Task/Loops-Downward-for/IDL/loops-downward-for-1.idl
Normal file
|
|
@ -0,0 +1 @@
|
|||
for i=10,0,-1 do print,i
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue