Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
category:
- Simple
from: http://rosettacode.org/wiki/Loops/For
note: Iteration

View 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:
* &nbsp; [[Loop over multiple arrays simultaneously]]
* &nbsp; [[Loops/Break]]
* &nbsp; [[Loops/Continue]]
* &nbsp; [[Loops/Do-while]]
* &nbsp; [[Loops/Downward for]]
* &nbsp; [[Loops/For]]
* &nbsp; [[Loops/For with a specified step]]
* &nbsp; [[Loops/Foreach]]
* &nbsp; [[Loops/Increment loop index within loop body]]
* &nbsp; [[Loops/Infinite]]
* &nbsp; [[Loops/N plus one half]]
* &nbsp; [[Loops/Nested]]
* &nbsp; [[Loops/While]]
* &nbsp; [[Loops/with multiple ranges]]
* &nbsp; [[Loops/Wrong ranges]]
<br><br>
;Reference:
* [[wp:For loop|For loop]] Wikipedia.
<br><br>

View file

@ -0,0 +1,4 @@
L(i) 1..5
L 1..i
print(*, end' )
print()

View file

@ -0,0 +1,2 @@
L(i) 1..5
print(* * i)

View 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

View 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

View 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

View 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

View file

@ -0,0 +1 @@
( ( '* putc ) swap times cr ) 1 5 loop

View 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"

View 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

View file

@ -0,0 +1,6 @@
FOR i TO 5 DO
TO i DO
print("*")
OD;
print(new line)
OD

View 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

View 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.

View file

@ -0,0 +1 @@
stars { 1 {/'*'}¨ }

View file

@ -0,0 +1 @@
stars { 1 { {1'*',} ¨ } ¨ }

View 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

View 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 */

View file

@ -0,0 +1,8 @@
BEGIN {
for(i=1; i < 6; i++) {
for(j=1; j <= i; j++ ) {
printf "*"
}
print
}
}

View 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

View 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 = "";
}

View file

@ -0,0 +1,6 @@
for I in 1..5 loop
for J in 1..I loop
Put("*");
end loop;
New_Line;
end loop;

View file

@ -0,0 +1,6 @@
for i to 5 do
for j to i do
write( "*" )
od;
print()
od

View file

@ -0,0 +1,6 @@
for i in 0 to 6
for j in 0 to i
Write('*')
end
WriteLn()
end

View 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

View 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);
}

View 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

View file

@ -0,0 +1 @@
FOR I = 1 TO 5 : FOR J = 1 TO I : PRINT "*"; : NEXT J : PRINT : NEXT

View file

@ -0,0 +1,6 @@
loop 0..5 'x [
loop 0..x 'y [
prints "*"
]
print ""
]

View file

@ -0,0 +1,6 @@
for(int i = 0; i < 6; ++i) {
for(int j = 0; j < i; ++j) {
write("*", suffix=none);
}
write("");
}

View 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

View file

@ -0,0 +1,5 @@
For each row from 1 to 5 do
[
For each length from 1 to row do [Print: "*";];
Print: "\n";
];

View file

@ -0,0 +1,5 @@
For each row from 1 to 5 do
[
From 1 to row do [Print: "*";];
Print: "\n";
];

View file

@ -0,0 +1,6 @@
ClrHome
For(I,1,5)
For(J,1,I)
Output(J,I,"*")
End
End

View file

@ -0,0 +1,6 @@
for i = 1 to 5
for j = 1 to i
print "*";
next j
print
next i

View file

@ -0,0 +1,7 @@
for i = 1 to 5
for j = 1 to i
print "*";
next j
print
next i
end

View file

@ -0,0 +1,6 @@
FOR I% = 1 TO 5
FOR J% = 1 TO I%
PRINT"*";
NEXT
PRINT
NEXT

View file

@ -0,0 +1,7 @@
get "libhdr"
let start() be
for i = 1 to 5
$( for j = 1 to i do wrch('**')
wrch('*N')
$)

View file

@ -0,0 +1,6 @@
FOR i = 1 TO 5
FOR j = 1 TO i
PRINT "*"
NEXT
PRINT
NEXT

View file

@ -0,0 +1,11 @@
((main { 10 star_triangle ! })
(star_triangle {
dup
<-
{ dup { "*" << } <->
iter - 1 +
times
"\n" << }
->
times }))

View 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

View file

@ -0,0 +1,6 @@
for (i = 1; i <= 5; i++) {
for (j = 1; j <= i; j++) "*"
"
"
}
quit

View file

@ -0,0 +1,3 @@
1>:5`#@_:>"*",v
| :-1<
^+1,+5+5<

View file

@ -0,0 +1,7 @@
for i = 1; i <= 5; i++
line = ""
for (j = 1; j <= i; j++)
line = line + "*"
end
print(line)
end

View file

@ -0,0 +1,9 @@
0:?i
& whl
' ( !i+1:~>5:?i
& 0:?k
& whl'(!k+1:~>!i:?k&put$"*")
& put$\n
)
&
);

View 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

View file

@ -0,0 +1,6 @@
1.to 5, { i |
1.to i, { j |
print "*"
}
print "\n"
}

View 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');
}

View file

@ -0,0 +1,6 @@
foreach i (`jot 5`)
foreach j (`jot $i`)
echo -n \*
end
echo ""
end

View 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();
}
}
}

View file

@ -0,0 +1,6 @@
int i, j;
for (i = 1; i <= 5; i++) {
for (j = 1; j <= i; j++)
putchar('*');
puts("");
}

View 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

View 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
.

View file

@ -0,0 +1,9 @@
shared void run() {
for(i in 1..5) {
for(j in 1..i) {
process.write("*");
}
print("");
}
}

View file

@ -0,0 +1,4 @@
for i in 1..5 {
for 1..i do write('*');
writeln();
}

View 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.

View 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

View file

@ -0,0 +1,3 @@
(doseq [i (range 5), j (range (inc i))]
(print "*")
(if (= i j) (println)))

View file

@ -0,0 +1,6 @@
<cfloop index = "i" from = "1" to = "5">
<cfloop index = "j" from = "1" to = "#i#">
*
</cfloop>
< br />
</cfloop>

View file

@ -0,0 +1,10 @@
<cfscript>
for( i = 1; i <= 5; i++ )
{
for( j = 1; j <= i; j++ )
{
writeOutput( "*" );
}
writeOutput( "< br />" );
}
</cfscript>

View 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

View file

@ -0,0 +1,4 @@
(loop for i from 1 upto 5 do
(loop for j from 1 upto i do
(write-char #\*))
(terpri))

View file

@ -0,0 +1,4 @@
(dotimes (i 5)
(dotimes (j (+ i 1))
(write-char #\*))
(terpri))

View file

@ -0,0 +1,6 @@
(do ((i 1 (+ i 1)))
((> i 5))
(do ((j 1 (+ j 1)))
((> j i))
(write-char #\*))
(terpri))

View file

@ -0,0 +1,7 @@
(use-package :iterate)
(iter
(for i from 1 to 5)
(iter
(for j from 1 to i)
(princ #\*))
(terpri))

View 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.

View 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;

View 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

View file

@ -0,0 +1,6 @@
1.upto(5) do |i|
1.upto(i) do |j|
print "*"
end
puts
end

View file

@ -0,0 +1 @@
puts (1..5).map { |i| "*" * i }.join("\n")

View 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();
}
}

View file

@ -0,0 +1,9 @@
number i, j
for (i = 1; i <= 5; i++)
{
for (j = 1; j <= i; j++)
{
Result( "*" )
}
Result( "\n" )
}

View 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;

View file

@ -0,0 +1,4 @@
for( i = 1 : 5 ){
for( j = 1 : i ) io.write( '*' )
io.writeln()
}

View file

@ -0,0 +1,6 @@
main() {
for (var i = 0; i < 5; i++)
for (var j = 0; j < i + 1; j++)
print("*");
print("\n");
}

View 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

View 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.

View 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[];

View 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()

View 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

View file

@ -0,0 +1,6 @@
for (i = 0, i < 5, i++) {
for (j = 0, j <= i, j++) {
show "*"
}
showln ""
}

View file

@ -0,0 +1,6 @@
for i in 1..5 {
for _ in 1..i {
print("*", terminator: "")
}
print()
}

View file

@ -0,0 +1,6 @@
for width in 1..5 {
for _ in 1..width {
print("*")
}
println()
}

View 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 ]

View file

@ -0,0 +1,8 @@
str string;
for ( i int to 5 )
str = "";
for ( j int to i )
str += "*";
end
SysLib.writeStdout(str);
end

View file

@ -0,0 +1,6 @@
FOR I=1 TO 5 DO
FOR J=1 TO I DO
PRINT("*";)
END FOR
PRINT
END FOR

View file

@ -0,0 +1,6 @@
for i = 1 to 5
for j = 1 to i
write "*"
.
print ""
.

View 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

View file

@ -0,0 +1,9 @@
**
***
****
*****
******
*******
********
*********
**********

View 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()
}
}

View 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)

View file

@ -0,0 +1 @@
for i <- 1..5, do: IO.puts (for j <- 1..i, do: "*")

View 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) ) )

View 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).

View 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

View 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

View file

@ -0,0 +1,2 @@
1[$6-][$[$]["*"1-]#%"
"1+]#%

View 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

View file

@ -0,0 +1,4 @@
01.10 FOR I=1,4; DO 2.0
02.10 FOR J=1,I; TYPE "*"
02.20 TYPE !

View 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