Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
5
Task/Loops-For/00-META.yaml
Normal file
5
Task/Loops-For/00-META.yaml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
category:
|
||||
- Simple
|
||||
from: http://rosettacode.org/wiki/Loops/For
|
||||
note: Iteration
|
||||
39
Task/Loops-For/00-TASK.txt
Normal file
39
Task/Loops-For/00-TASK.txt
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
“'''For'''” loops are used to make some block of code be iterated a number of times, setting a variable or parameter to a monotonically increasing integer value for each execution of the block of code.
|
||||
|
||||
Common extensions of this allow other counting patterns or iterating over abstract structures other than the integers.
|
||||
|
||||
|
||||
;Task:
|
||||
Show how two loops may be nested within each other, with the number of iterations performed by the inner for loop being controlled by the outer for loop.
|
||||
|
||||
Specifically print out the following pattern by using one for loop nested in another:
|
||||
<pre>*
|
||||
**
|
||||
***
|
||||
****
|
||||
*****</pre>
|
||||
|
||||
|
||||
;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>
|
||||
|
||||
|
||||
;Reference:
|
||||
* [[wp:For loop|For loop]] Wikipedia.
|
||||
<br><br>
|
||||
|
||||
4
Task/Loops-For/11l/loops-for-1.11l
Normal file
4
Task/Loops-For/11l/loops-for-1.11l
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
L(i) 1..5
|
||||
L 1..i
|
||||
print(‘*’, end' ‘’)
|
||||
print()
|
||||
2
Task/Loops-For/11l/loops-for-2.11l
Normal file
2
Task/Loops-For/11l/loops-for-2.11l
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
L(i) 1..5
|
||||
print(‘*’ * i)
|
||||
22
Task/Loops-For/360-Assembly/loops-for-1.360
Normal file
22
Task/Loops-For/360-Assembly/loops-for-1.360
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
* Loops/For - BXH Algol 27/07/2015
|
||||
LOOPFOR CSECT
|
||||
USING LOOPFORC,R12
|
||||
LR R12,R15 set base register
|
||||
BEGIN LA R2,0 from 1 (from-step=0)
|
||||
LA R4,1 step 1
|
||||
LA R5,5 to 5
|
||||
LOOPI BXH R2,R4,ELOOPI for i=1 to 5 (R2=i)
|
||||
LA R8,BUFFER-1 ipx=-1
|
||||
LA R3,0 from 1 (from-step=0)
|
||||
LA R6,1 step 1
|
||||
LR R7,R2 to i
|
||||
LOOPJ BXH R3,R6,ELOOPJ for j:=1 to i (R3=j)
|
||||
LA R8,1(R8) ipx=ipx+1
|
||||
MVI 0(R8),C'*' buffer(ipx)='*'
|
||||
B LOOPJ next j
|
||||
ELOOPJ XPRNT BUFFER,L'BUFFER print buffer
|
||||
B LOOPI next i
|
||||
ELOOPI BR R14 return to caller
|
||||
BUFFER DC CL80' ' buffer
|
||||
YREGS
|
||||
END LOOPFOR
|
||||
20
Task/Loops-For/360-Assembly/loops-for-2.360
Normal file
20
Task/Loops-For/360-Assembly/loops-for-2.360
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
* Loops/For - struct 29/06/2016
|
||||
LOOPFOR CSECT
|
||||
USING LOOPFORC,R12
|
||||
LR R12,R15 set base register
|
||||
LA R2,1 from 1
|
||||
DO WHILE=(CH,R2,LE,=H'5') for i=1 to 5 (R2=i)
|
||||
LA R8,BUFFER-1 ipx=-1
|
||||
LA R3,1 from 1
|
||||
DO WHILE=(CR,R3,LE,R2) for j:=1 to i (R3=j)
|
||||
LA R8,1(R8) ipx=ipx+1
|
||||
MVI 0(R8),C'*' buffer(ipx)='*'
|
||||
LA R3,1(R3) j=j+1 (step)
|
||||
ENDDO , next j
|
||||
XPRNT BUFFER,L'BUFFER print buffer
|
||||
LA R2,1(R2) i=i+1 (step)
|
||||
ENDDO , next i
|
||||
BR R14 return to caller
|
||||
BUFFER DC CL80' ' buffer
|
||||
YREGS
|
||||
END LOOPFOR
|
||||
14
Task/Loops-For/68000-Assembly/loops-for.68000
Normal file
14
Task/Loops-For/68000-Assembly/loops-for.68000
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
main:
|
||||
MOVEQ #1,D1 ;counter for how many times to print *, this is also the loop counter
|
||||
.outerloop:
|
||||
MOVE.W D1,D2
|
||||
SUBQ.W #1,D2
|
||||
.innerloop:
|
||||
MOVE.B #'*',D0
|
||||
JSR PrintChar ;hardware-dependent printing routine
|
||||
DBRA D2,.innerloop ;DBRA loops until wraparound to $FFFF, which is why we subtracted 1 from D2 earlier.
|
||||
JSR NewLine ;hardware-dependent newline routine
|
||||
ADDQ.W #1,D1
|
||||
CMP.W #6,D1 ;are we done yet?
|
||||
BCS .outerloop ;if not, go back to the top
|
||||
RTS
|
||||
24
Task/Loops-For/8086-Assembly/loops-for.8086
Normal file
24
Task/Loops-For/8086-Assembly/loops-for.8086
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
StarSub:
|
||||
|
||||
mov ah,02h ;needed to prime the interrupt command for printing to screen
|
||||
mov ch,1 ;outer loop counter
|
||||
|
||||
outer_loop:
|
||||
mov cl,ch ;refresh the inner loop counter, by copying the value of the outer loop counter to it.
|
||||
;each time the inner loop finishes, it will last one iteration longer the next time.
|
||||
|
||||
inner_loop:
|
||||
mov dl,02Ah ;ascii for *
|
||||
int 21h ;tells DOS to print the contents of dl to the screen
|
||||
dec cl
|
||||
jnz inner_loop
|
||||
mov dl,13 ;Carriage Return
|
||||
int 21h
|
||||
mov dl,10 ;New Line
|
||||
int 21h
|
||||
|
||||
inc ch ;make the outer loop counter bigger for next time.
|
||||
cmp ch,5
|
||||
jnz outer_loop
|
||||
|
||||
ret
|
||||
1
Task/Loops-For/8th/loops-for.8th
Normal file
1
Task/Loops-For/8th/loops-for.8th
Normal file
|
|
@ -0,0 +1 @@
|
|||
( ( '* putc ) swap times cr ) 1 5 loop
|
||||
53
Task/Loops-For/AArch64-Assembly/loops-for.aarch64
Normal file
53
Task/Loops-For/AArch64-Assembly/loops-for.aarch64
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/* ARM assembly AARCH64 Raspberry PI 3B */
|
||||
/* program loop64.s */
|
||||
|
||||
/*******************************************/
|
||||
/* Constantes file */
|
||||
/*******************************************/
|
||||
/* for this file see task include a file in language AArch64 assembly*/
|
||||
.include "../includeConstantesARM64.inc"
|
||||
/*******************************************/
|
||||
/* Initialized data */
|
||||
/*******************************************/
|
||||
.data
|
||||
szMessX: .asciz "X"
|
||||
szCarriageReturn: .asciz "\n"
|
||||
/*******************************************/
|
||||
/* UnInitialized data */
|
||||
/*******************************************/
|
||||
.bss
|
||||
/*******************************************/
|
||||
/* code section */
|
||||
/*******************************************/
|
||||
.text
|
||||
.global main
|
||||
main: // entry of program
|
||||
|
||||
mov x2,0 // counter loop 1
|
||||
1: // loop start 1
|
||||
mov x1,0 // counter loop 2
|
||||
2: // loop start 2
|
||||
ldr x0,qAdrszMessX
|
||||
bl affichageMess
|
||||
add x1,x1,1 // x1 + 1
|
||||
cmp x1,x2 // compare x1 x2
|
||||
ble 2b // loop label 2 before
|
||||
ldr x0,qAdrszCarriageReturn
|
||||
bl affichageMess
|
||||
add x2,x2,1 // x2 + 1
|
||||
cmp x2,#5 // for five loop
|
||||
blt 1b // loop label 1 before
|
||||
|
||||
|
||||
100: // standard end of the program */
|
||||
mov x0,0 // return code
|
||||
mov x8,EXIT // request to exit program
|
||||
svc 0 // perform the system call
|
||||
|
||||
qAdrszMessX: .quad szMessX
|
||||
qAdrszCarriageReturn: .quad szCarriageReturn
|
||||
/********************************************************/
|
||||
/* File Include fonctions */
|
||||
/********************************************************/
|
||||
/* for this file see task include a file in language AArch64 assembly */
|
||||
.include "../includeARM64.inc"
|
||||
7
Task/Loops-For/ALGOL-60/loops-for.alg
Normal file
7
Task/Loops-For/ALGOL-60/loops-for.alg
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
INTEGER I,J;
|
||||
FOR I:=1 STEP 1 UNTIL 5 DO
|
||||
BEGIN
|
||||
FOR J:=1 STEP 1 UNTIL I DO
|
||||
OUTTEXT("*");
|
||||
OUTLINE
|
||||
END
|
||||
6
Task/Loops-For/ALGOL-68/loops-for.alg
Normal file
6
Task/Loops-For/ALGOL-68/loops-for.alg
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
FOR i TO 5 DO
|
||||
TO i DO
|
||||
print("*")
|
||||
OD;
|
||||
print(new line)
|
||||
OD
|
||||
9
Task/Loops-For/ALGOL-M/loops-for.alg
Normal file
9
Task/Loops-For/ALGOL-M/loops-for.alg
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
BEGIN
|
||||
INTEGER I, J;
|
||||
FOR I := 1 STEP 1 UNTIL 5 DO
|
||||
BEGIN
|
||||
WRITE( "" );
|
||||
FOR J := 1 STEP 1 UNTIL I DO
|
||||
WRITEON( "*" );
|
||||
END;
|
||||
END
|
||||
10
Task/Loops-For/ALGOL-W/loops-for.alg
Normal file
10
Task/Loops-For/ALGOL-W/loops-for.alg
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
begin
|
||||
for i := 1 until 5 do
|
||||
begin
|
||||
write( "*" );
|
||||
for j := 2 until i do
|
||||
begin
|
||||
writeon( "*" )
|
||||
end j
|
||||
end i
|
||||
end.
|
||||
1
Task/Loops-For/APL/loops-for-1.apl
Normal file
1
Task/Loops-For/APL/loops-for-1.apl
Normal file
|
|
@ -0,0 +1 @@
|
|||
stars ← { ⍵ 1 ⍴ {⍵/'*'}¨⍳⍵ }
|
||||
1
Task/Loops-For/APL/loops-for-2.apl
Normal file
1
Task/Loops-For/APL/loops-for-2.apl
Normal file
|
|
@ -0,0 +1 @@
|
|||
stars ← { ⍵ 1 ⍴ { {1⌷'*',⍵} ¨ ⍳⍵ } ¨ ⍳⍵ }
|
||||
10
Task/Loops-For/APL/loops-for-3.apl
Normal file
10
Task/Loops-For/APL/loops-for-3.apl
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
∇result ← stars count; i; j; vec
|
||||
vec ← ⍬
|
||||
:for i :in ⍳ count
|
||||
vec ,← ⊂''
|
||||
:for j :in ⍳ i
|
||||
vec[i],←'*'
|
||||
:endfor
|
||||
:endfor
|
||||
result ← count 1 ⍴ vec
|
||||
∇
|
||||
66
Task/Loops-For/ARM-Assembly/loops-for.arm
Normal file
66
Task/Loops-For/ARM-Assembly/loops-for.arm
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
/* ARM assembly Raspberry PI */
|
||||
/* program loop1.s */
|
||||
|
||||
/* Constantes */
|
||||
.equ STDOUT, 1 @ Linux output console
|
||||
.equ EXIT, 1 @ Linux syscall
|
||||
.equ WRITE, 4 @ Linux syscall
|
||||
/* Initialized data */
|
||||
.data
|
||||
szMessX: .asciz "X"
|
||||
szCarriageReturn: .asciz "\n"
|
||||
|
||||
/* UnInitialized data */
|
||||
.bss
|
||||
|
||||
/* code section */
|
||||
.text
|
||||
.global main
|
||||
main: /* entry of program */
|
||||
push {fp,lr} /* saves 2 registers */
|
||||
|
||||
mov r2,#0 @ counter loop 1
|
||||
1: @ loop start 1
|
||||
mov r1,#0 @ counter loop 2
|
||||
2: @ loop start 2
|
||||
ldr r0,iAdrszMessX
|
||||
bl affichageMess
|
||||
add r1,#1 @ r1 + 1
|
||||
cmp r1,r2 @ compare r1 r2
|
||||
ble 2b @ loop label 2 before
|
||||
ldr r0,iAdrszCarriageReturn
|
||||
bl affichageMess
|
||||
add r2,#1 @ r2 + 1
|
||||
cmp r2,#5 @ for five loop
|
||||
blt 1b @ loop label 1 before
|
||||
|
||||
|
||||
100: /* standard end of the program */
|
||||
mov r0, #0 @ return code
|
||||
pop {fp,lr} @restaur 2 registers
|
||||
mov r7, #EXIT @ request to exit program
|
||||
swi 0 @ perform the system call
|
||||
|
||||
iAdrszMessX: .int szMessX
|
||||
iAdrszCarriageReturn: .int szCarriageReturn
|
||||
/******************************************************************/
|
||||
/* display text with size calculation */
|
||||
/******************************************************************/
|
||||
/* r0 contains the address of the message */
|
||||
affichageMess:
|
||||
push {fp,lr} /* save registres */
|
||||
push {r0,r1,r2,r7} /* save others registers */
|
||||
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" */
|
||||
swi #0 /* call systeme */
|
||||
pop {r0,r1,r2,r7} /* restaur others registers */
|
||||
pop {fp,lr} /* restaur des 2 registres */
|
||||
bx lr /* return */
|
||||
8
Task/Loops-For/AWK/loops-for.awk
Normal file
8
Task/Loops-For/AWK/loops-for.awk
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
BEGIN {
|
||||
for(i=1; i < 6; i++) {
|
||||
for(j=1; j <= i; j++ ) {
|
||||
printf "*"
|
||||
}
|
||||
print
|
||||
}
|
||||
}
|
||||
13
Task/Loops-For/Action-/loops-for.action
Normal file
13
Task/Loops-For/Action-/loops-for.action
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
Proc Main()
|
||||
byte I,J
|
||||
|
||||
For I=1 to 5
|
||||
Do
|
||||
For J=1 to I
|
||||
Do
|
||||
Print("*")
|
||||
Od
|
||||
PrintE("")
|
||||
Od
|
||||
|
||||
Return
|
||||
7
Task/Loops-For/ActionScript/loops-for.as
Normal file
7
Task/Loops-For/ActionScript/loops-for.as
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
var str:String = "";
|
||||
for (var i:int = 1; i <= 5; i++) {
|
||||
for (var j:int = 1; j <= i; j++)
|
||||
str += "*";
|
||||
trace(str);
|
||||
str = "";
|
||||
}
|
||||
6
Task/Loops-For/Ada/loops-for.ada
Normal file
6
Task/Loops-For/Ada/loops-for.ada
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
for I in 1..5 loop
|
||||
for J in 1..I loop
|
||||
Put("*");
|
||||
end loop;
|
||||
New_Line;
|
||||
end loop;
|
||||
6
Task/Loops-For/Agena/loops-for.agena
Normal file
6
Task/Loops-For/Agena/loops-for.agena
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
for i to 5 do
|
||||
for j to i do
|
||||
write( "*" )
|
||||
od;
|
||||
print()
|
||||
od
|
||||
6
Task/Loops-For/Alore/loops-for.alore
Normal file
6
Task/Loops-For/Alore/loops-for.alore
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
for i in 0 to 6
|
||||
for j in 0 to i
|
||||
Write('*')
|
||||
end
|
||||
WriteLn()
|
||||
end
|
||||
7
Task/Loops-For/AmigaE/loops-for.amiga
Normal file
7
Task/Loops-For/AmigaE/loops-for.amiga
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
PROC main()
|
||||
DEF i, j
|
||||
FOR i := 1 TO 5
|
||||
FOR j := 1 TO i DO WriteF('*')
|
||||
WriteF('\n')
|
||||
ENDFOR
|
||||
ENDPROC
|
||||
21
Task/Loops-For/Apex/loops-for.apex
Normal file
21
Task/Loops-For/Apex/loops-for.apex
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
for (Integer i = 0; i < 5; i++) {
|
||||
String line = '';
|
||||
|
||||
for (Integer j = 0; j < i; j++) {
|
||||
line += '*';
|
||||
}
|
||||
|
||||
System.debug(line);
|
||||
}
|
||||
|
||||
List<String> lines = new List<String> {
|
||||
'*',
|
||||
'**',
|
||||
'***',
|
||||
'****',
|
||||
'*****'
|
||||
};
|
||||
|
||||
for (String line : lines) {
|
||||
System.debug(line);
|
||||
}
|
||||
8
Task/Loops-For/AppleScript/loops-for.applescript
Normal file
8
Task/Loops-For/AppleScript/loops-for.applescript
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
set x to linefeed
|
||||
repeat with i from 1 to 5
|
||||
repeat with j from 1 to i
|
||||
set x to x & "*"
|
||||
end repeat
|
||||
set x to x & linefeed
|
||||
end repeat
|
||||
return x
|
||||
1
Task/Loops-For/Applesoft-BASIC/loops-for.basic
Normal file
1
Task/Loops-For/Applesoft-BASIC/loops-for.basic
Normal file
|
|
@ -0,0 +1 @@
|
|||
FOR I = 1 TO 5 : FOR J = 1 TO I : PRINT "*"; : NEXT J : PRINT : NEXT
|
||||
6
Task/Loops-For/Arturo/loops-for.arturo
Normal file
6
Task/Loops-For/Arturo/loops-for.arturo
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
loop 0..5 'x [
|
||||
loop 0..x 'y [
|
||||
prints "*"
|
||||
]
|
||||
print ""
|
||||
]
|
||||
6
Task/Loops-For/Asymptote/loops-for.asymptote
Normal file
6
Task/Loops-For/Asymptote/loops-for.asymptote
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
for(int i = 0; i < 6; ++i) {
|
||||
for(int j = 0; j < i; ++j) {
|
||||
write("*", suffix=none);
|
||||
}
|
||||
write("");
|
||||
}
|
||||
13
Task/Loops-For/AutoHotkey/loops-for.ahk
Normal file
13
Task/Loops-For/AutoHotkey/loops-for.ahk
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
Gui, Add, Edit, vOutput r5 w100 -VScroll ; Create an Edit-Control
|
||||
Gui, Show ; Show the window
|
||||
Loop, 5 ; loop 5 times
|
||||
{
|
||||
Loop, %A_Index% ; A_Index contains the Index of the current loop
|
||||
{
|
||||
output .= "*" ; append an "*" to the output var
|
||||
GuiControl, , Output, %Output% ; update the Edit-Control with the new content
|
||||
Sleep, 500 ; wait some(500ms) time, [just to show off]
|
||||
}
|
||||
Output .= (A_Index = 5) ? "" : "`n" ; append a new line to the output if A_Index is not "5"
|
||||
}
|
||||
Return ; End of auto-execution section
|
||||
5
Task/Loops-For/Avail/loops-for-1.avail
Normal file
5
Task/Loops-For/Avail/loops-for-1.avail
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
For each row from 1 to 5 do
|
||||
[
|
||||
For each length from 1 to row do [Print: "*";];
|
||||
Print: "\n";
|
||||
];
|
||||
5
Task/Loops-For/Avail/loops-for-2.avail
Normal file
5
Task/Loops-For/Avail/loops-for-2.avail
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
For each row from 1 to 5 do
|
||||
[
|
||||
From 1 to row do [Print: "*";];
|
||||
Print: "\n";
|
||||
];
|
||||
6
Task/Loops-For/Axe/loops-for.axe
Normal file
6
Task/Loops-For/Axe/loops-for.axe
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
ClrHome
|
||||
For(I,1,5)
|
||||
For(J,1,I)
|
||||
Output(J,I,"*")
|
||||
End
|
||||
End
|
||||
6
Task/Loops-For/BASIC/loops-for.basic
Normal file
6
Task/Loops-For/BASIC/loops-for.basic
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
for i = 1 to 5
|
||||
for j = 1 to i
|
||||
print "*";
|
||||
next j
|
||||
print
|
||||
next i
|
||||
7
Task/Loops-For/BASIC256/loops-for.basic
Normal file
7
Task/Loops-For/BASIC256/loops-for.basic
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
for i = 1 to 5
|
||||
for j = 1 to i
|
||||
print "*";
|
||||
next j
|
||||
print
|
||||
next i
|
||||
end
|
||||
6
Task/Loops-For/BBC-BASIC/loops-for.basic
Normal file
6
Task/Loops-For/BBC-BASIC/loops-for.basic
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
FOR I% = 1 TO 5
|
||||
FOR J% = 1 TO I%
|
||||
PRINT"*";
|
||||
NEXT
|
||||
PRINT
|
||||
NEXT
|
||||
7
Task/Loops-For/BCPL/loops-for.bcpl
Normal file
7
Task/Loops-For/BCPL/loops-for.bcpl
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
get "libhdr"
|
||||
|
||||
let start() be
|
||||
for i = 1 to 5
|
||||
$( for j = 1 to i do wrch('**')
|
||||
wrch('*N')
|
||||
$)
|
||||
6
Task/Loops-For/BaCon/loops-for.bacon
Normal file
6
Task/Loops-For/BaCon/loops-for.bacon
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
FOR i = 1 TO 5
|
||||
FOR j = 1 TO i
|
||||
PRINT "*"
|
||||
NEXT
|
||||
PRINT
|
||||
NEXT
|
||||
11
Task/Loops-For/Babel/loops-for.pb
Normal file
11
Task/Loops-For/Babel/loops-for.pb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
((main { 10 star_triangle ! })
|
||||
|
||||
(star_triangle {
|
||||
dup
|
||||
<-
|
||||
{ dup { "*" << } <->
|
||||
iter - 1 +
|
||||
times
|
||||
"\n" << }
|
||||
->
|
||||
times }))
|
||||
12
Task/Loops-For/Batch-File/loops-for.bat
Normal file
12
Task/Loops-For/Batch-File/loops-for.bat
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
@ECHO OFF
|
||||
SETLOCAL ENABLEDELAYEDEXPANSION
|
||||
|
||||
for /l %%i in (1,1,5) do (
|
||||
SET line=
|
||||
for /l %%j in (1,1,%%i) do (
|
||||
SET line=!line!*
|
||||
)
|
||||
ECHO !line!
|
||||
)
|
||||
|
||||
ENDLOCAL
|
||||
6
Task/Loops-For/Bc/loops-for.bc
Normal file
6
Task/Loops-For/Bc/loops-for.bc
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
for (i = 1; i <= 5; i++) {
|
||||
for (j = 1; j <= i; j++) "*"
|
||||
"
|
||||
"
|
||||
}
|
||||
quit
|
||||
3
Task/Loops-For/Befunge/loops-for.bf
Normal file
3
Task/Loops-For/Befunge/loops-for.bf
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
1>:5`#@_:>"*",v
|
||||
| :-1<
|
||||
^+1,+5+5<
|
||||
7
Task/Loops-For/Blz/loops-for.blz
Normal file
7
Task/Loops-For/Blz/loops-for.blz
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
for i = 1; i <= 5; i++
|
||||
line = ""
|
||||
for (j = 1; j <= i; j++)
|
||||
line = line + "*"
|
||||
end
|
||||
print(line)
|
||||
end
|
||||
9
Task/Loops-For/Bracmat/loops-for.bracmat
Normal file
9
Task/Loops-For/Bracmat/loops-for.bracmat
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
0:?i
|
||||
& whl
|
||||
' ( !i+1:~>5:?i
|
||||
& 0:?k
|
||||
& whl'(!k+1:~>!i:?k&put$"*")
|
||||
& put$\n
|
||||
)
|
||||
&
|
||||
);
|
||||
8
Task/Loops-For/Brainf---/loops-for.bf
Normal file
8
Task/Loops-For/Brainf---/loops-for.bf
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
>>+++++++[>++++++[>+<-]<-] place * in cell 3
|
||||
+++++[>++[>>+<<-]<-]<< place \n in cell 4
|
||||
+++++[ set outer loop count
|
||||
[>+ increment inner counter
|
||||
>[-]>[-]<<[->+>+<<]>>[-<<+>>]<< copy inner counter
|
||||
>[>>.<<-]>>>.<<< print line
|
||||
<<-] end inner loop
|
||||
] end outer loop
|
||||
6
Task/Loops-For/Brat/loops-for.brat
Normal file
6
Task/Loops-For/Brat/loops-for.brat
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
1.to 5, { i |
|
||||
1.to i, { j |
|
||||
print "*"
|
||||
}
|
||||
print "\n"
|
||||
}
|
||||
6
Task/Loops-For/C++/loops-for.cpp
Normal file
6
Task/Loops-For/C++/loops-for.cpp
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
for(int i = 0; i < 5; ++i) {
|
||||
for(int j = 0; j < i; ++j)
|
||||
std::cout.put('*');
|
||||
|
||||
std::cout.put('\n');
|
||||
}
|
||||
6
Task/Loops-For/C-Shell/loops-for.csh
Normal file
6
Task/Loops-For/C-Shell/loops-for.csh
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
foreach i (`jot 5`)
|
||||
foreach j (`jot $i`)
|
||||
echo -n \*
|
||||
end
|
||||
echo ""
|
||||
end
|
||||
15
Task/Loops-For/C-sharp/loops-for.cs
Normal file
15
Task/Loops-For/C-sharp/loops-for.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
|
||||
class Program {
|
||||
static void Main(string[] args)
|
||||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
for (int j = 0; j <= i; j++)
|
||||
{
|
||||
Console.Write("*");
|
||||
}
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
6
Task/Loops-For/C/loops-for.c
Normal file
6
Task/Loops-For/C/loops-for.c
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
int i, j;
|
||||
for (i = 1; i <= 5; i++) {
|
||||
for (j = 1; j <= i; j++)
|
||||
putchar('*');
|
||||
puts("");
|
||||
}
|
||||
10
Task/Loops-For/CLU/loops-for.clu
Normal file
10
Task/Loops-For/CLU/loops-for.clu
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
start_up = proc ()
|
||||
po: stream := stream$primary_output()
|
||||
|
||||
for i: int in int$from_to(1, 5) do
|
||||
for j: int in int$from_to(1, i) do
|
||||
stream$putc(po, '*')
|
||||
end
|
||||
stream$putl(po, "")
|
||||
end
|
||||
end start_up
|
||||
21
Task/Loops-For/COBOL/loops-for.cobol
Normal file
21
Task/Loops-For/COBOL/loops-for.cobol
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. Display-Triangle.
|
||||
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
01 Outer-Counter PIC 9.
|
||||
01 Inner-Counter PIC 9.
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
PERFORM VARYING Outer-Counter FROM 1 BY 1 UNTIL 5 < Outer-Counter
|
||||
|
||||
PERFORM VARYING Inner-Counter FROM 1 BY 1
|
||||
UNTIL Outer-Counter < Inner-Counter
|
||||
DISPLAY "*" NO ADVANCING
|
||||
END-PERFORM
|
||||
|
||||
DISPLAY "" *> Output a newline
|
||||
END-PERFORM
|
||||
|
||||
GOBACK
|
||||
.
|
||||
9
Task/Loops-For/Ceylon/loops-for.ceylon
Normal file
9
Task/Loops-For/Ceylon/loops-for.ceylon
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
shared void run() {
|
||||
|
||||
for(i in 1..5) {
|
||||
for(j in 1..i) {
|
||||
process.write("*");
|
||||
}
|
||||
print("");
|
||||
}
|
||||
}
|
||||
4
Task/Loops-For/Chapel/loops-for.chapel
Normal file
4
Task/Loops-For/Chapel/loops-for.chapel
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
for i in 1..5 {
|
||||
for 1..i do write('*');
|
||||
writeln();
|
||||
}
|
||||
29
Task/Loops-For/Chef/loops-for.chef
Normal file
29
Task/Loops-For/Chef/loops-for.chef
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
Asterisks Omelette.
|
||||
|
||||
This recipe prints a triangle of asterisks.
|
||||
|
||||
Ingredients.
|
||||
5 eggs
|
||||
1 onion
|
||||
1 potato
|
||||
42 ml water
|
||||
10 ml olive oil
|
||||
1 garlic
|
||||
|
||||
Method.
|
||||
Put eggs into the mixing bowl.
|
||||
Fold onion into the mixing bowl.
|
||||
Put eggs into the mixing bowl.
|
||||
Add garlic into the mixing bowl.
|
||||
Fold eggs into the mixing bowl.
|
||||
Chop onion.
|
||||
Put onion into the mixing bowl.
|
||||
Fold potato into the mixing bowl.
|
||||
Put olive oil into the mixing bowl.
|
||||
Mash potato.
|
||||
Put water into the mixing bowl.
|
||||
Mash potato until mashed.
|
||||
Chop onion until choped.
|
||||
Pour contents of the mixing bowl into the baking dish.
|
||||
|
||||
Serves 1.
|
||||
6
Task/Loops-For/Chipmunk-Basic/loops-for.basic
Normal file
6
Task/Loops-For/Chipmunk-Basic/loops-for.basic
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
10 for i = 1 to 5
|
||||
20 for j = 1 to i
|
||||
30 print "*";
|
||||
40 next j
|
||||
50 print
|
||||
60 next i
|
||||
3
Task/Loops-For/Clojure/loops-for.clj
Normal file
3
Task/Loops-For/Clojure/loops-for.clj
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(doseq [i (range 5), j (range (inc i))]
|
||||
(print "*")
|
||||
(if (= i j) (println)))
|
||||
6
Task/Loops-For/ColdFusion/loops-for-1.cfm
Normal file
6
Task/Loops-For/ColdFusion/loops-for-1.cfm
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<cfloop index = "i" from = "1" to = "5">
|
||||
<cfloop index = "j" from = "1" to = "#i#">
|
||||
*
|
||||
</cfloop>
|
||||
< br />
|
||||
</cfloop>
|
||||
10
Task/Loops-For/ColdFusion/loops-for-2.cfm
Normal file
10
Task/Loops-For/ColdFusion/loops-for-2.cfm
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<cfscript>
|
||||
for( i = 1; i <= 5; i++ )
|
||||
{
|
||||
for( j = 1; j <= i; j++ )
|
||||
{
|
||||
writeOutput( "*" );
|
||||
}
|
||||
writeOutput( "< br />" );
|
||||
}
|
||||
</cfscript>
|
||||
6
Task/Loops-For/Commodore-BASIC/loops-for.basic
Normal file
6
Task/Loops-For/Commodore-BASIC/loops-for.basic
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
10 FOR I = 1 TO 5
|
||||
20 : FOR J = 1 TO I
|
||||
30 : PRINT "*";
|
||||
40 : NEXT J
|
||||
50 : PRINT
|
||||
60 NEXT I
|
||||
4
Task/Loops-For/Common-Lisp/loops-for-1.lisp
Normal file
4
Task/Loops-For/Common-Lisp/loops-for-1.lisp
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(loop for i from 1 upto 5 do
|
||||
(loop for j from 1 upto i do
|
||||
(write-char #\*))
|
||||
(terpri))
|
||||
4
Task/Loops-For/Common-Lisp/loops-for-2.lisp
Normal file
4
Task/Loops-For/Common-Lisp/loops-for-2.lisp
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(dotimes (i 5)
|
||||
(dotimes (j (+ i 1))
|
||||
(write-char #\*))
|
||||
(terpri))
|
||||
6
Task/Loops-For/Common-Lisp/loops-for-3.lisp
Normal file
6
Task/Loops-For/Common-Lisp/loops-for-3.lisp
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(do ((i 1 (+ i 1)))
|
||||
((> i 5))
|
||||
(do ((j 1 (+ j 1)))
|
||||
((> j i))
|
||||
(write-char #\*))
|
||||
(terpri))
|
||||
7
Task/Loops-For/Common-Lisp/loops-for-4.lisp
Normal file
7
Task/Loops-For/Common-Lisp/loops-for-4.lisp
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
(use-package :iterate)
|
||||
(iter
|
||||
(for i from 1 to 5)
|
||||
(iter
|
||||
(for j from 1 to i)
|
||||
(princ #\*))
|
||||
(terpri))
|
||||
23
Task/Loops-For/Coq/loops-for.coq
Normal file
23
Task/Loops-For/Coq/loops-for.coq
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
Section FOR.
|
||||
Variable T : Type.
|
||||
Variable body : nat -> T -> T.
|
||||
Variable start : nat.
|
||||
|
||||
Fixpoint for_loop n : T -> T :=
|
||||
match n with
|
||||
| O => fun s => s
|
||||
| S n' => fun s => for_loop n' (body (start + n') s)
|
||||
end.
|
||||
|
||||
End FOR.
|
||||
|
||||
Eval vm_compute in
|
||||
for_loop _
|
||||
(fun i =>
|
||||
cons
|
||||
(for_loop _
|
||||
(fun j => cons tt)
|
||||
0 (S i) nil
|
||||
)
|
||||
)
|
||||
0 5 nil.
|
||||
12
Task/Loops-For/Cowgol/loops-for.cowgol
Normal file
12
Task/Loops-For/Cowgol/loops-for.cowgol
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
include "cowgol.coh";
|
||||
|
||||
var i: uint8 := 1;
|
||||
while i <= 5 loop
|
||||
var j: uint8 := 1;
|
||||
while j <= i loop
|
||||
print_char('*');
|
||||
j := j + 1;
|
||||
end loop;
|
||||
print_nl();
|
||||
i := i + 1;
|
||||
end loop;
|
||||
21
Task/Loops-For/Creative-Basic/loops-for.basic
Normal file
21
Task/Loops-For/Creative-Basic/loops-for.basic
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
OPENCONSOLE
|
||||
|
||||
FOR X=1 TO 5
|
||||
|
||||
FOR Y=1 TO X
|
||||
|
||||
PRINT"*",:'No line feed or carriage return after printing.
|
||||
|
||||
NEXT Y
|
||||
|
||||
PRINT
|
||||
|
||||
NEXT X
|
||||
|
||||
PRINT:PRINT"Press any key to end."
|
||||
|
||||
DO:UNTIL INKEY$<>""
|
||||
|
||||
CLOSECONSOLE
|
||||
|
||||
END
|
||||
6
Task/Loops-For/Crystal/loops-for-1.crystal
Normal file
6
Task/Loops-For/Crystal/loops-for-1.crystal
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
1.upto(5) do |i|
|
||||
1.upto(i) do |j|
|
||||
print "*"
|
||||
end
|
||||
puts
|
||||
end
|
||||
1
Task/Loops-For/Crystal/loops-for-2.crystal
Normal file
1
Task/Loops-For/Crystal/loops-for-2.crystal
Normal file
|
|
@ -0,0 +1 @@
|
|||
puts (1..5).map { |i| "*" * i }.join("\n")
|
||||
16
Task/Loops-For/D/loops-for.d
Normal file
16
Task/Loops-For/D/loops-for.d
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import std.stdio: write, writeln;
|
||||
|
||||
void main() {
|
||||
for (int i; i < 5; i++) {
|
||||
for (int j; j <= i; j++)
|
||||
write("*");
|
||||
writeln();
|
||||
}
|
||||
writeln();
|
||||
|
||||
foreach (i; 0 .. 5) {
|
||||
foreach (j; 0 .. i + 1)
|
||||
write("*");
|
||||
writeln();
|
||||
}
|
||||
}
|
||||
9
Task/Loops-For/DMS/loops-for.dms
Normal file
9
Task/Loops-For/DMS/loops-for.dms
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
number i, j
|
||||
for (i = 1; i <= 5; i++)
|
||||
{
|
||||
for (j = 1; j <= i; j++)
|
||||
{
|
||||
Result( "*" )
|
||||
}
|
||||
Result( "\n" )
|
||||
}
|
||||
7
Task/Loops-For/DWScript/loops-for.dw
Normal file
7
Task/Loops-For/DWScript/loops-for.dw
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
var i, j : Integer;
|
||||
|
||||
for i := 1 to 5 do begin
|
||||
for j := 1 to i do
|
||||
Print('*');
|
||||
PrintLn('');
|
||||
end;
|
||||
4
Task/Loops-For/Dao/loops-for.dao
Normal file
4
Task/Loops-For/Dao/loops-for.dao
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
for( i = 1 : 5 ){
|
||||
for( j = 1 : i ) io.write( '*' )
|
||||
io.writeln()
|
||||
}
|
||||
6
Task/Loops-For/Dart/loops-for.dart
Normal file
6
Task/Loops-For/Dart/loops-for.dart
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
main() {
|
||||
for (var i = 0; i < 5; i++)
|
||||
for (var j = 0; j < i + 1; j++)
|
||||
print("*");
|
||||
print("\n");
|
||||
}
|
||||
15
Task/Loops-For/Dc/loops-for.dc
Normal file
15
Task/Loops-For/Dc/loops-for.dc
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
[
|
||||
[*]P [print asterisk]sz
|
||||
lj 1 + d sj [increment j, leave it on stack]sz
|
||||
li !<A [continue loop if i >= j]sz
|
||||
]sA
|
||||
[
|
||||
1 d sj [j = 1, leave it on stack]sz
|
||||
li !<A [enter loop A if i >= j]sz
|
||||
[
|
||||
]P [print newline]sz
|
||||
li 1 + d si [increment i, leave it on stack]sz
|
||||
5 !<B [continue loop if 5 >= i]sz
|
||||
]sB
|
||||
1 d si [i = 1, leave it on stack]sz
|
||||
5 !<B [enter loop B if 5 >= i]sz
|
||||
14
Task/Loops-For/Delphi/loops-for.delphi
Normal file
14
Task/Loops-For/Delphi/loops-for.delphi
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
program LoopFor;
|
||||
|
||||
{$APPTYPE CONSOLE}
|
||||
|
||||
var
|
||||
i, j: Integer;
|
||||
begin
|
||||
for i := 1 to 5 do
|
||||
begin
|
||||
for j := 1 to i do
|
||||
Write('*');
|
||||
Writeln;
|
||||
end;
|
||||
end.
|
||||
16
Task/Loops-For/Diego/loops-for.diego
Normal file
16
Task/Loops-For/Diego/loops-for.diego
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
set_ns(rosettacode);
|
||||
|
||||
add_var({str},s)_value();
|
||||
add_var({str},output);
|
||||
|
||||
add_for({int},i)_from(1)_uptoand(5)_inc()
|
||||
with_var(s)_v();
|
||||
add_for({int},j)_from(0)_upto([i])_inc()
|
||||
with_var(s)_calc([s]&="*");
|
||||
;
|
||||
with_var(output)_calc(&=[s]&\n);
|
||||
;
|
||||
|
||||
me_msg([output]);
|
||||
|
||||
reset_ns[];
|
||||
34
Task/Loops-For/Dodo0/loops-for.dodo0
Normal file
34
Task/Loops-For/Dodo0/loops-for.dodo0
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
fun for -> var, test, body, return # define a for loop using recursion
|
||||
(
|
||||
test(var) -> continue
|
||||
if (continue) ->
|
||||
(
|
||||
body(var) -> var
|
||||
for (var, test, body, return)
|
||||
)
|
||||
|
|
||||
return(var)
|
||||
)
|
||||
| for
|
||||
|
||||
fun upToFive (-> index, return) '<='(index, 5, return) | upToFive
|
||||
|
||||
for (1, upToFive) -> index, return
|
||||
(
|
||||
fun countTheStars -> stars, return
|
||||
(
|
||||
'count'(stars) -> n
|
||||
'<'(n, index, return) # continue until n = index
|
||||
)
|
||||
| countTheStars
|
||||
|
||||
for ("*", countTheStars) -> prefix, return
|
||||
'str'(prefix, "*", return)
|
||||
| stars
|
||||
|
||||
println(stars) ->
|
||||
|
||||
'inc'(index, return)
|
||||
)
|
||||
| result
|
||||
exit()
|
||||
9
Task/Loops-For/Draco/loops-for.draco
Normal file
9
Task/Loops-For/Draco/loops-for.draco
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
proc nonrec main() void:
|
||||
byte i,j;
|
||||
for i from 1 upto 5 do
|
||||
for j from 1 upto i do
|
||||
write("*")
|
||||
od;
|
||||
writeln()
|
||||
od
|
||||
corp
|
||||
6
Task/Loops-For/Dragon/loops-for.dragon
Normal file
6
Task/Loops-For/Dragon/loops-for.dragon
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
for (i = 0, i < 5, i++) {
|
||||
for (j = 0, j <= i, j++) {
|
||||
show "*"
|
||||
}
|
||||
showln ""
|
||||
}
|
||||
6
Task/Loops-For/Dyalect/loops-for.dyalect
Normal file
6
Task/Loops-For/Dyalect/loops-for.dyalect
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
for i in 1..5 {
|
||||
for _ in 1..i {
|
||||
print("*", terminator: "")
|
||||
}
|
||||
print()
|
||||
}
|
||||
6
Task/Loops-For/E/loops-for.e
Normal file
6
Task/Loops-For/E/loops-for.e
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
for width in 1..5 {
|
||||
for _ in 1..width {
|
||||
print("*")
|
||||
}
|
||||
println()
|
||||
}
|
||||
50
Task/Loops-For/EDSAC-order-code/loops-for.edsac
Normal file
50
Task/Loops-For/EDSAC-order-code/loops-for.edsac
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
[ Loops
|
||||
=====
|
||||
|
||||
A program for the EDSAC
|
||||
|
||||
Demonstrates nested loops
|
||||
and printer output
|
||||
|
||||
Works with Initial Orders 2 ]
|
||||
|
||||
|
||||
|
||||
T56K [ set load point ]
|
||||
GK [ set theta ]
|
||||
|
||||
O21@ [ figure shift ]
|
||||
|
||||
[ 1 ] T24@ [ a = 0 ]
|
||||
A19@ [ a = i ]
|
||||
|
||||
[ 3 ] T20@ [ j = a; a = 0 ]
|
||||
O22@ [ write character ]
|
||||
A20@ [ a = j ]
|
||||
S17@ [ a -= 1 ]
|
||||
U20@ [ j = a ]
|
||||
E3@ [ if a>=0 go to 3 ]
|
||||
|
||||
O23@ [ write line feed ]
|
||||
T24@ [ a = 0 ]
|
||||
A19@ [ a = i ]
|
||||
A17@ [ a += 1 ]
|
||||
U19@ [ i = a ]
|
||||
S18@ [ a -= 5 ]
|
||||
G1@ [ if a<0 go to 1 ]
|
||||
|
||||
ZF [ halt ]
|
||||
|
||||
[ 17 ] P0D [ const: 1 ]
|
||||
[ 18 ] P2D [ const: 5 ]
|
||||
|
||||
[ 19 ] P0F [ var: i ]
|
||||
[ 20 ] P0F [ var: j ]
|
||||
|
||||
[ 21 ] #F [ figure shift ]
|
||||
[ 22 ] ZF [ '+' character ]
|
||||
[ 23 ] &F [ line feed ]
|
||||
|
||||
[ 24 ] P0F [ used to clear a ]
|
||||
|
||||
EZPF [ begin execution ]
|
||||
8
Task/Loops-For/EGL/loops-for.egl
Normal file
8
Task/Loops-For/EGL/loops-for.egl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
str string;
|
||||
for ( i int to 5 )
|
||||
str = "";
|
||||
for ( j int to i )
|
||||
str += "*";
|
||||
end
|
||||
SysLib.writeStdout(str);
|
||||
end
|
||||
6
Task/Loops-For/ERRE/loops-for.erre
Normal file
6
Task/Loops-For/ERRE/loops-for.erre
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
FOR I=1 TO 5 DO
|
||||
FOR J=1 TO I DO
|
||||
PRINT("*";)
|
||||
END FOR
|
||||
PRINT
|
||||
END FOR
|
||||
6
Task/Loops-For/EasyLang/loops-for.easy
Normal file
6
Task/Loops-For/EasyLang/loops-for.easy
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
for i = 1 to 5
|
||||
for j = 1 to i
|
||||
write "*"
|
||||
.
|
||||
print ""
|
||||
.
|
||||
13
Task/Loops-For/Ela/loops-for-1.ela
Normal file
13
Task/Loops-For/Ela/loops-for-1.ela
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
open monad io
|
||||
|
||||
loop m n | n < m = do
|
||||
loop' n 0
|
||||
putStrLn ""
|
||||
loop m (n + 1)
|
||||
| else = do return ()
|
||||
where loop' m n | n <= m = do
|
||||
putStr "*"
|
||||
loop' m (n + 1)
|
||||
| else = do return ()
|
||||
|
||||
_ = loop 10 1 ::: IO
|
||||
9
Task/Loops-For/Ela/loops-for-2.ela
Normal file
9
Task/Loops-For/Ela/loops-for-2.ela
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
**
|
||||
***
|
||||
****
|
||||
*****
|
||||
******
|
||||
*******
|
||||
********
|
||||
*********
|
||||
**********
|
||||
12
Task/Loops-For/Elena/loops-for.elena
Normal file
12
Task/Loops-For/Elena/loops-for.elena
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import extensions;
|
||||
|
||||
public program()
|
||||
{
|
||||
for(int i := 0, i < 5, i += 1)
|
||||
{
|
||||
for(int j := 0, j <= i, j += 1)
|
||||
{ console.write:"*" };
|
||||
|
||||
console.writeLine()
|
||||
}
|
||||
}
|
||||
10
Task/Loops-For/Elixir/loops-for-1.elixir
Normal file
10
Task/Loops-For/Elixir/loops-for-1.elixir
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
defmodule Loops do
|
||||
def loops_for(n) do
|
||||
Enum.each(1..n, fn i ->
|
||||
Enum.each(1..i, fn _ -> IO.write "*" end)
|
||||
IO.puts ""
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
Loops.loops_for(5)
|
||||
1
Task/Loops-For/Elixir/loops-for-2.elixir
Normal file
1
Task/Loops-For/Elixir/loops-for-2.elixir
Normal file
|
|
@ -0,0 +1 @@
|
|||
for i <- 1..5, do: IO.puts (for j <- 1..i, do: "*")
|
||||
11
Task/Loops-For/Emacs-Lisp/loops-for.l
Normal file
11
Task/Loops-For/Emacs-Lisp/loops-for.l
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
;; Lisp implementation of c-for is like:
|
||||
;; (let ((i nil))
|
||||
;; (while (progn (setq i (if (not i) 0 (1+ i) )) ;; if value of i is nil, initialize its value to 0, if else, add 1
|
||||
;; (< i 10)) ;; end loop when i > 10
|
||||
;; (... body ...) ) ) ;; loop body
|
||||
|
||||
(let ((i nil) (str ""))
|
||||
(while (progn (setq i (if (not i) 0 (1+ i) ))
|
||||
(< i 5))
|
||||
(setq str (concat str "*"))
|
||||
(message str) ) )
|
||||
24
Task/Loops-For/Erlang/loops-for.erl
Normal file
24
Task/Loops-For/Erlang/loops-for.erl
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
%% Implemented by Arjun Sunel
|
||||
-module(nested_loops).
|
||||
-export([main/0, inner_loop/0]).
|
||||
|
||||
main() ->
|
||||
outer_loop(1).
|
||||
|
||||
inner_loop()->
|
||||
inner_loop(1).
|
||||
|
||||
inner_loop(N) when N rem 5 =:= 0 ->
|
||||
io:format("* ");
|
||||
|
||||
inner_loop(N) ->
|
||||
io:fwrite("* "),
|
||||
inner_loop(N+1).
|
||||
|
||||
outer_loop(N) when N rem 5 =:= 0 ->
|
||||
io:format("*");
|
||||
|
||||
outer_loop(N) ->
|
||||
outer_loop(N+1),
|
||||
io:format("~n"),
|
||||
inner_loop(N).
|
||||
6
Task/Loops-For/Euphoria/loops-for.euphoria
Normal file
6
Task/Loops-For/Euphoria/loops-for.euphoria
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
for i = 1 to 5 do
|
||||
for j = 1 to i do
|
||||
puts(1, "*") -- Same as "puts(1, {'*'})"
|
||||
end for
|
||||
puts(1, "\n") -- Same as "puts(1, {'\n'})"
|
||||
end for
|
||||
8
Task/Loops-For/F-Sharp/loops-for.fs
Normal file
8
Task/Loops-For/F-Sharp/loops-for.fs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#light
|
||||
[<EntryPoint>]
|
||||
let main args =
|
||||
for i = 1 to 5 do
|
||||
for j = 1 to i do
|
||||
printf "*"
|
||||
printfn ""
|
||||
0
|
||||
2
Task/Loops-For/FALSE/loops-for.false
Normal file
2
Task/Loops-For/FALSE/loops-for.false
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
1[$6-][$[$]["*"1-]#%"
|
||||
"1+]#%
|
||||
8
Task/Loops-For/FBSL/loops-for.fbsl
Normal file
8
Task/Loops-For/FBSL/loops-for.fbsl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#APPTYPE CONSOLE
|
||||
FOR dim i = 1 TO 5
|
||||
FOR dim j = 1 TO i
|
||||
PRINT "*";
|
||||
NEXT j
|
||||
PRINT
|
||||
NEXT i
|
||||
Pause
|
||||
4
Task/Loops-For/FOCAL/loops-for.focal
Normal file
4
Task/Loops-For/FOCAL/loops-for.focal
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
01.10 FOR I=1,4; DO 2.0
|
||||
|
||||
02.10 FOR J=1,I; TYPE "*"
|
||||
02.20 TYPE !
|
||||
7
Task/Loops-For/FUZE-BASIC/loops-for.basic
Normal file
7
Task/Loops-For/FUZE-BASIC/loops-for.basic
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
FOR n = 1 to 5 CYCLE
|
||||
FOR k = 1 to n CYCLE
|
||||
print "*";
|
||||
REPEAT
|
||||
PRINT
|
||||
REPEAT
|
||||
END
|
||||
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