A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
8
Task/Loops-For/0DESCRIPTION
Normal file
8
Task/Loops-For/0DESCRIPTION
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
“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.
|
||||
|
||||
For this 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>
|
||||
2
Task/Loops-For/1META.yaml
Normal file
2
Task/Loops-For/1META.yaml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
note: Iteration
|
||||
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
|
||||
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
|
||||
}
|
||||
}
|
||||
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/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
|
||||
8
Task/Loops-For/AppleScript/loops-for-1.applescript
Normal file
8
Task/Loops-For/AppleScript/loops-for-1.applescript
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
set x to return
|
||||
repeat with i from 1 to 5
|
||||
repeat with j from 1 to i
|
||||
set x to x & "*"
|
||||
end repeat
|
||||
set x to x & return
|
||||
end repeat
|
||||
return x
|
||||
7
Task/Loops-For/AppleScript/loops-for-2.applescript
Normal file
7
Task/Loops-For/AppleScript/loops-for-2.applescript
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
"
|
||||
*
|
||||
**
|
||||
***
|
||||
****
|
||||
*****
|
||||
"
|
||||
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
|
||||
6
Task/Loops-For/BASIC/loops-for-1.bas
Normal file
6
Task/Loops-For/BASIC/loops-for-1.bas
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
for i = 1 to 5
|
||||
for j = 1 to i
|
||||
print "*";
|
||||
next j
|
||||
print
|
||||
next i
|
||||
6
Task/Loops-For/BASIC/loops-for-2.bas
Normal file
6
Task/Loops-For/BASIC/loops-for-2.bas
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
|
||||
6
Task/Loops-For/BBC-BASIC/loops-for.bbc
Normal file
6
Task/Loops-For/BBC-BASIC/loops-for.bbc
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 @@
|
|||
star_triangle: { <- { { "*" << } iter times "\n" << } -> times }
|
||||
main: { 10 star_triangle }
|
||||
*
|
||||
**
|
||||
***
|
||||
****
|
||||
*****
|
||||
******
|
||||
*******
|
||||
********
|
||||
*********
|
||||
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
|
||||
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<
|
||||
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"
|
||||
}
|
||||
5
Task/Loops-For/C++/loops-for.cpp
Normal file
5
Task/Loops-For/C++/loops-for.cpp
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
for(int i = 1; i <= 5; ++i) {
|
||||
for(int j = 1; j <= i; j++)
|
||||
std::cout << "*";
|
||||
std::cout << std::endl;
|
||||
}
|
||||
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("");
|
||||
}
|
||||
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.
|
||||
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>
|
||||
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 #\*))
|
||||
(write-line ""))
|
||||
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))
|
||||
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.dwscript
Normal file
7
Task/Loops-For/DWScript/loops-for.dwscript
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()
|
||||
}
|
||||
4
Task/Loops-For/Dart/loops-for.dart
Normal file
4
Task/Loops-For/Dart/loops-for.dart
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
main() {
|
||||
for (var i = 0; i < 5; i++)
|
||||
print(i);
|
||||
}
|
||||
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.
|
||||
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()
|
||||
}
|
||||
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/Ela/loops-for.ela
Normal file
6
Task/Loops-For/Ela/loops-for.ela
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
open console
|
||||
|
||||
loop m n | n < m = loop' n 0 $ writen "" $ loop m (n+1)
|
||||
| else = ()
|
||||
where loop' m n | n <= m = write "*" $ loop' m (n+1)
|
||||
| else = ()
|
||||
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
|
||||
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+]#%
|
||||
1
Task/Loops-For/Factor/loops-for.factor
Normal file
1
Task/Loops-For/Factor/loops-for.factor
Normal file
|
|
@ -0,0 +1 @@
|
|||
5 [1,b] [ [ "*" write ] times nl ] each
|
||||
14
Task/Loops-For/Fantom/loops-for-1.fantom
Normal file
14
Task/Loops-For/Fantom/loops-for-1.fantom
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
class ForLoops
|
||||
{
|
||||
public static Void main ()
|
||||
{
|
||||
for (Int i := 1; i <= 5; ++i)
|
||||
{
|
||||
for (Int j := 1; j <= i; ++j)
|
||||
{
|
||||
Env.cur.out.print ("*")
|
||||
}
|
||||
Env.cur.out.printLine ("")
|
||||
}
|
||||
}
|
||||
}
|
||||
14
Task/Loops-For/Fantom/loops-for-2.fantom
Normal file
14
Task/Loops-For/Fantom/loops-for-2.fantom
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
class ForLoops
|
||||
{
|
||||
public static Void main ()
|
||||
{
|
||||
(1..5).each |i|
|
||||
{
|
||||
(1..i).each |j|
|
||||
{
|
||||
Env.cur.out.print ("*")
|
||||
}
|
||||
Env.cur.out.printLine ("")
|
||||
}
|
||||
}
|
||||
}
|
||||
5
Task/Loops-For/Forth/loops-for-1.fth
Normal file
5
Task/Loops-For/Forth/loops-for-1.fth
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
: triangle ( n -- )
|
||||
1+ 1 do
|
||||
cr i 0 do [char] * emit loop
|
||||
loop ;
|
||||
5 triangle
|
||||
5
Task/Loops-For/Forth/loops-for-2.fth
Normal file
5
Task/Loops-For/Forth/loops-for-2.fth
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
: limit_example
|
||||
15 1 do r> r@ dup rot >r drop \ Bring limit on stack
|
||||
. \ And print it
|
||||
loop ;
|
||||
\ Gforth and JSForth all work, SP-Forth brakes (different 'for' implementation?)
|
||||
33
Task/Loops-For/Fortran/loops-for-1.f
Normal file
33
Task/Loops-For/Fortran/loops-for-1.f
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
C WARNING: This program is not valid ANSI FORTRAN 77 code. It uses
|
||||
C one nonstandard character on the line labelled 5001. Many F77
|
||||
C compilers should be okay with it, but it is *not* standard.
|
||||
PROGRAM FORLOOP
|
||||
INTEGER I, J
|
||||
|
||||
DO 20 I = 1, 5
|
||||
DO 10 J = 1, I
|
||||
C Print the asterisk.
|
||||
WRITE (*,5001) '*'
|
||||
10 CONTINUE
|
||||
C Print a newline.
|
||||
WRITE (*,5000) ''
|
||||
20 CONTINUE
|
||||
|
||||
STOP
|
||||
|
||||
5000 FORMAT (A)
|
||||
C Standard FORTRAN 77 is completely incapable of completing a
|
||||
C WRITE statement without printing a newline. If you wanted to
|
||||
C write this program in valid F77, you would have to come up with
|
||||
C a creative way of printing varying numbers of asterisks in a
|
||||
C single write statement.
|
||||
C
|
||||
C The dollar sign at the end of the format is a nonstandard
|
||||
C character. It tells the compiler not to print a newline. If you
|
||||
C are actually using FORTRAN 77, you should figure out what your
|
||||
C particular compiler accepts. If you are actually using Fortran
|
||||
C 90 or later, you should replace this line with the commented
|
||||
C line that follows it.
|
||||
5001 FORMAT (A, $)
|
||||
C5001 FORMAT (A, ADVANCE='NO')
|
||||
END
|
||||
6
Task/Loops-For/Fortran/loops-for-2.f
Normal file
6
Task/Loops-For/Fortran/loops-for-2.f
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
DO i = 1, 5
|
||||
DO j = 1, i
|
||||
WRITE(*, "(A)", ADVANCE="NO") "*"
|
||||
END DO
|
||||
WRITE(*,*)
|
||||
END DO
|
||||
4
Task/Loops-For/Fortran/loops-for-3.f
Normal file
4
Task/Loops-For/Fortran/loops-for-3.f
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
integer :: i
|
||||
integer, dimension(10) :: v
|
||||
|
||||
forall (i=1:size(v)) v(i) = i
|
||||
12
Task/Loops-For/GAP/loops-for.gap
Normal file
12
Task/Loops-For/GAP/loops-for.gap
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
for i in [1 .. 5] do
|
||||
for j in [1 .. i] do
|
||||
Print("*");
|
||||
od;
|
||||
Print("\n");
|
||||
od;
|
||||
|
||||
# *
|
||||
# **
|
||||
# ***
|
||||
# ****
|
||||
# *****
|
||||
10
Task/Loops-For/GML/loops-for.gml
Normal file
10
Task/Loops-For/GML/loops-for.gml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
pattern = ""
|
||||
for(i = 1; i <= 5; i += 1)
|
||||
{
|
||||
for(j = 1; j <= i; j += 1)
|
||||
{
|
||||
pattern += "*"
|
||||
}
|
||||
pattern += "#"
|
||||
}
|
||||
show_message(pattern)
|
||||
6
Task/Loops-For/GW-BASIC/loops-for.bas
Normal file
6
Task/Loops-For/GW-BASIC/loops-for.bas
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
|
||||
6
Task/Loops-For/Gambas/loops-for.gambas
Normal file
6
Task/Loops-For/Gambas/loops-for.gambas
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
for i = 1 to 5
|
||||
for j = 1 to i
|
||||
print "*";
|
||||
next
|
||||
print
|
||||
next
|
||||
12
Task/Loops-For/Go/loops-for.go
Normal file
12
Task/Loops-For/Go/loops-for.go
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
for i := 1; i <= 5; i++ {
|
||||
for j := 1; j <= i; j++ {
|
||||
fmt.Printf("*")
|
||||
}
|
||||
fmt.Printf("\n")
|
||||
}
|
||||
}
|
||||
6
Task/Loops-For/Groovy/loops-for.groovy
Normal file
6
Task/Loops-For/Groovy/loops-for.groovy
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
for(i in (1..6)) {
|
||||
for(j in (1..i)) {
|
||||
print '*'
|
||||
}
|
||||
println ()
|
||||
}
|
||||
7
Task/Loops-For/Haskell/loops-for-1.hs
Normal file
7
Task/Loops-For/Haskell/loops-for-1.hs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import Control.Monad
|
||||
|
||||
main = do
|
||||
forM_ [1..5] $ \i -> do
|
||||
forM_ [1..i] $ \j -> do
|
||||
putChar '*'
|
||||
putChar '\n'
|
||||
3
Task/Loops-For/Haskell/loops-for-2.hs
Normal file
3
Task/Loops-For/Haskell/loops-for-2.hs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import Data.List (inits)
|
||||
|
||||
main = mapM_ putStrLn $ tail $ inits $ replicate 5 '*'
|
||||
6
Task/Loops-For/Haxe/loops-for.haxe
Normal file
6
Task/Loops-For/Haxe/loops-for.haxe
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
for (i in 1...6) {
|
||||
for(j in 0...i) {
|
||||
Sys.print('*');
|
||||
}
|
||||
Sys.println('');
|
||||
}
|
||||
6
Task/Loops-For/HicEst/loops-for-1.hicest
Normal file
6
Task/Loops-For/HicEst/loops-for-1.hicest
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
DO i = 1, 5
|
||||
DO j = 1, i
|
||||
WRITE(APPend) "*"
|
||||
ENDDO
|
||||
WRITE() ' '
|
||||
ENDDO
|
||||
7
Task/Loops-For/HicEst/loops-for-2.hicest
Normal file
7
Task/Loops-For/HicEst/loops-for-2.hicest
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
procedure main()
|
||||
every i := 1 to 5 do {
|
||||
every 1 to i do
|
||||
writes("*")
|
||||
write()
|
||||
}
|
||||
end
|
||||
4
Task/Loops-For/Inform-7/loops-for.inf
Normal file
4
Task/Loops-For/Inform-7/loops-for.inf
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
repeat with length running from 1 to 5:
|
||||
repeat with N running from 1 to length:
|
||||
say "*";
|
||||
say line break;
|
||||
13
Task/Loops-For/J/loops-for.j
Normal file
13
Task/Loops-For/J/loops-for.j
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
3 : 0
|
||||
for_i. 1 + i. y do.
|
||||
z =. ''
|
||||
|
||||
for. 1 + i. i do.
|
||||
z=. z,'*'
|
||||
end.
|
||||
|
||||
z 1!:2 ] 2
|
||||
end.
|
||||
|
||||
i.0 0
|
||||
)
|
||||
6
Task/Loops-For/Java/loops-for.java
Normal file
6
Task/Loops-For/Java/loops-for.java
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
for (int i = 0; i < 5; i++) {
|
||||
for (int j = 0; j <= i; j++) {
|
||||
System.out.print("*");
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
7
Task/Loops-For/JavaScript/loops-for.js
Normal file
7
Task/Loops-For/JavaScript/loops-for.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
var i, j;
|
||||
for (i = 1; i <= 5; i += 1) {
|
||||
s = '';
|
||||
for (j = 0; j < i; j += 1)
|
||||
s += '*';
|
||||
document.write(s + '<br>');
|
||||
}
|
||||
9
Task/Loops-For/Lang5/loops-for.lang5
Normal file
9
Task/Loops-For/Lang5/loops-for.lang5
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
: cr "\n" . ; : dip swap '_ set execute _ ;
|
||||
: nip swap drop ; : last -1 extract nip ;
|
||||
: times
|
||||
swap iota '_ set
|
||||
do dup 'execute dip _ last 0 == if break then
|
||||
loop drop ;
|
||||
|
||||
: concat "" join ;
|
||||
'* 1 5 "2dup reshape concat . cr 1 +" times
|
||||
6
Task/Loops-For/Liberty-BASIC/loops-for.liberty
Normal file
6
Task/Loops-For/Liberty-BASIC/loops-for.liberty
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
for i = 1 to 5
|
||||
for j = 1 to i
|
||||
print "*";
|
||||
next
|
||||
print
|
||||
next
|
||||
6
Task/Loops-For/Lisaac/loops-for.lisaac
Normal file
6
Task/Loops-For/Lisaac/loops-for.lisaac
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
1.to 5 do { i : INTEGER;
|
||||
1.to i do { dummy : INTEGER;
|
||||
'*'.print;
|
||||
};
|
||||
'\n'.print;
|
||||
};
|
||||
2
Task/Loops-For/Logo/loops-for.logo
Normal file
2
Task/Loops-For/Logo/loops-for.logo
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
for [i 1 5] [repeat :i [type "*] (print)]
|
||||
repeat 5 [repeat repcount [type "*] (print)]
|
||||
6
Task/Loops-For/Lua/loops-for.lua
Normal file
6
Task/Loops-For/Lua/loops-for.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
for i=1,5 do
|
||||
for j=1,i do
|
||||
io.write("*")
|
||||
end
|
||||
io.write("\n")
|
||||
end
|
||||
9
Task/Loops-For/M4/loops-for.m4
Normal file
9
Task/Loops-For/M4/loops-for.m4
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
define(`for',
|
||||
`ifelse($#,0,``$0'',
|
||||
`ifelse(eval($2<=$3),1,
|
||||
`pushdef(`$1',$2)$5`'popdef(`$1')$0(`$1',eval($2+$4),$3,$4,`$5')')')')dnl
|
||||
|
||||
for(`x',`1',`5',`1',
|
||||
`for(`y',`1',x,`1',
|
||||
`*')
|
||||
')
|
||||
7
Task/Loops-For/MATLAB/loops-for-1.m
Normal file
7
Task/Loops-For/MATLAB/loops-for-1.m
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
for i = (1:5)
|
||||
output = [];
|
||||
for j = (1:i)
|
||||
output = [output '*'];
|
||||
end
|
||||
disp(output);
|
||||
end
|
||||
3
Task/Loops-For/MATLAB/loops-for-2.m
Normal file
3
Task/Loops-For/MATLAB/loops-for-2.m
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
for i = (1:5)
|
||||
disp(repmat('*',1,i));
|
||||
end
|
||||
9
Task/Loops-For/MAXScript/loops-for.max
Normal file
9
Task/Loops-For/MAXScript/loops-for.max
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
for i in 1 to 5 do
|
||||
(
|
||||
line = ""
|
||||
for j in 1 to i do
|
||||
(
|
||||
line += "*"
|
||||
)
|
||||
format "%\n" line
|
||||
)
|
||||
7
Task/Loops-For/MOO/loops-for.moo
Normal file
7
Task/Loops-For/MOO/loops-for.moo
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
for i in [1..5]
|
||||
s = "";
|
||||
for j in [1..i]
|
||||
s += "*";
|
||||
endfor
|
||||
player:tell(s);
|
||||
endfor
|
||||
7
Task/Loops-For/MUMPS/loops-for-1.mumps
Normal file
7
Task/Loops-For/MUMPS/loops-for-1.mumps
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
FORLOOP
|
||||
NEW I,J
|
||||
FOR I=1:1:5 DO
|
||||
.FOR J=1:1:I DO
|
||||
..WRITE "*"
|
||||
.WRITE !
|
||||
QUIT
|
||||
1
Task/Loops-For/MUMPS/loops-for-2.mumps
Normal file
1
Task/Loops-For/MUMPS/loops-for-2.mumps
Normal file
|
|
@ -0,0 +1 @@
|
|||
FOR I=1:1:5 FOR J=1:1:I WRITE "*" IF J=I W !
|
||||
6
Task/Loops-For/Maple/loops-for.maple
Normal file
6
Task/Loops-For/Maple/loops-for.maple
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
> for i to 5 do to i do printf( "*" ) end; printf( "\n" ) end;
|
||||
*
|
||||
**
|
||||
***
|
||||
****
|
||||
*****
|
||||
6
Task/Loops-For/Mathematica/loops-for.mathematica
Normal file
6
Task/Loops-For/Mathematica/loops-for.mathematica
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
n=5;
|
||||
For[i=1,i<=5,i++,
|
||||
string="";
|
||||
For[j=1,j<=i,j++,string=string<>"*"];
|
||||
Print[string]
|
||||
]
|
||||
5
Task/Loops-For/Maxima/loops-for.maxima
Normal file
5
Task/Loops-For/Maxima/loops-for.maxima
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
for i thru 5 do (
|
||||
s: "",
|
||||
thru i do s: sconcat(s, "*"),
|
||||
print(s)
|
||||
);
|
||||
22
Task/Loops-For/Mercury/loops-for.mercury
Normal file
22
Task/Loops-For/Mercury/loops-for.mercury
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
:- module loops_for.
|
||||
:- interface.
|
||||
|
||||
:- import_module io.
|
||||
:- pred main(io::di, io::uo) is det.
|
||||
|
||||
:- implementation.
|
||||
:- import_module int.
|
||||
|
||||
main(!IO) :-
|
||||
int.fold_up(outer_loop_body, 1, 5, !IO).
|
||||
|
||||
:- pred outer_loop_body(int::in, io::di, io::uo) is det.
|
||||
|
||||
outer_loop_body(I, !IO) :-
|
||||
int.fold_up(inner_loop_body, 1, I, !IO),
|
||||
io.nl(!IO).
|
||||
|
||||
:- pred inner_loop_body(int::in, io::di, io::uo) is det.
|
||||
|
||||
inner_loop_body(_, !IO) :-
|
||||
io.write_char('*', !IO).
|
||||
14
Task/Loops-For/Modula-2/loops-for.mod2
Normal file
14
Task/Loops-For/Modula-2/loops-for.mod2
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
MODULE For;
|
||||
IMPORT InOut;
|
||||
|
||||
VAR
|
||||
i, j: INTEGER;
|
||||
|
||||
BEGIN
|
||||
FOR i := 1 TO 5 DO
|
||||
FOR j := 1 TO i DO
|
||||
InOut.Write('*');
|
||||
END;
|
||||
InOut.WriteLn
|
||||
END
|
||||
END For.
|
||||
12
Task/Loops-For/Modula-3/loops-for.mod3
Normal file
12
Task/Loops-For/Modula-3/loops-for.mod3
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
MODULE Stars EXPORTS Main;
|
||||
|
||||
IMPORT IO;
|
||||
|
||||
BEGIN
|
||||
FOR i := 1 TO 5 DO
|
||||
FOR j := 1 TO i DO
|
||||
IO.Put("*");
|
||||
END;
|
||||
IO.Put("\n");
|
||||
END;
|
||||
END Stars.
|
||||
6
Task/Loops-For/PHP/loops-for-1.php
Normal file
6
Task/Loops-For/PHP/loops-for-1.php
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
for ($i = 1; $i <= 5; $i++) {
|
||||
for ($j = 1; $j <= $i; $j++) {
|
||||
echo '*';
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
6
Task/Loops-For/PHP/loops-for-2.php
Normal file
6
Task/Loops-For/PHP/loops-for-2.php
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
foreach (range(1, 5) as $i) {
|
||||
foreach (range(1, $i) as $j) {
|
||||
echo '*';
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
6
Task/Loops-For/Perl/loops-for-1.pl
Normal file
6
Task/Loops-For/Perl/loops-for-1.pl
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
for ($x = 1; $x <= 5; $x++) {
|
||||
for ($y = 1; $y <= $x; $y++) {
|
||||
print "*";
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
6
Task/Loops-For/Perl/loops-for-2.pl
Normal file
6
Task/Loops-For/Perl/loops-for-2.pl
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
foreach (1..5) {
|
||||
foreach (1..$_) {
|
||||
print '*';
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
1
Task/Loops-For/Perl/loops-for-3.pl
Normal file
1
Task/Loops-For/Perl/loops-for-3.pl
Normal file
|
|
@ -0,0 +1 @@
|
|||
print ('*' x $_ . "\n") for 1..5
|
||||
3
Task/Loops-For/PicoLisp/loops-for.l
Normal file
3
Task/Loops-For/PicoLisp/loops-for.l
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(for N 5
|
||||
(do N (prin "*"))
|
||||
(prinl) )
|
||||
5
Task/Loops-For/Python/loops-for-1.py
Normal file
5
Task/Loops-For/Python/loops-for-1.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import sys
|
||||
for i in xrange(5):
|
||||
for j in xrange(i+1):
|
||||
sys.stdout.write("*")
|
||||
print
|
||||
2
Task/Loops-For/Python/loops-for-2.py
Normal file
2
Task/Loops-For/Python/loops-for-2.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
for i in range(1,6):
|
||||
print '*' * i
|
||||
7
Task/Loops-For/R/loops-for.r
Normal file
7
Task/Loops-For/R/loops-for.r
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
for(i in 0:4) {
|
||||
s <- ""
|
||||
for(j in 0:i) {
|
||||
s <- paste(s, "*", sep="")
|
||||
}
|
||||
print(s)
|
||||
}
|
||||
7
Task/Loops-For/REXX/loops-for-1.rexx
Normal file
7
Task/Loops-For/REXX/loops-for-1.rexx
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
do i=1 to 5
|
||||
s=''
|
||||
do j=1 to i
|
||||
s=s || '*'
|
||||
end
|
||||
say s
|
||||
end
|
||||
7
Task/Loops-For/REXX/loops-for-2.rexx
Normal file
7
Task/Loops-For/REXX/loops-for-2.rexx
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
do i=1 for 5
|
||||
s=''
|
||||
do i
|
||||
s=s'*'
|
||||
end
|
||||
say s
|
||||
end
|
||||
4
Task/Loops-For/Racket/loops-for.rkt
Normal file
4
Task/Loops-For/Racket/loops-for.rkt
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(for ([i (in-range 1 6)])
|
||||
(for ([j i])
|
||||
(display "*"))
|
||||
(newline))
|
||||
6
Task/Loops-For/Ruby/loops-for-1.rb
Normal file
6
Task/Loops-For/Ruby/loops-for-1.rb
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
for i in 1..5
|
||||
for j in 1..i
|
||||
print "*"
|
||||
end
|
||||
puts
|
||||
end
|
||||
6
Task/Loops-For/Ruby/loops-for-2.rb
Normal file
6
Task/Loops-For/Ruby/loops-for-2.rb
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
1.upto(5) do |i|
|
||||
1.upto(i) do |j|
|
||||
print "*"
|
||||
end
|
||||
puts
|
||||
end
|
||||
7
Task/Loops-For/Ruby/loops-for-3.rb
Normal file
7
Task/Loops-For/Ruby/loops-for-3.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
5.times do |i|
|
||||
# i goes from 0 to 4
|
||||
(i+1).times do
|
||||
print "*"
|
||||
end
|
||||
puts
|
||||
end
|
||||
10
Task/Loops-For/Ruby/loops-for-4.rb
Normal file
10
Task/Loops-For/Ruby/loops-for-4.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
i = 1
|
||||
loop do
|
||||
j = 1
|
||||
loop do
|
||||
print "*"
|
||||
break if (j += 1) > i
|
||||
end
|
||||
puts
|
||||
break if (i += 1) > 5
|
||||
end
|
||||
1
Task/Loops-For/Ruby/loops-for-5.rb
Normal file
1
Task/Loops-For/Ruby/loops-for-5.rb
Normal file
|
|
@ -0,0 +1 @@
|
|||
puts (1..5).map { |i| "*" * i }
|
||||
20
Task/Loops-For/Sather/loops-for.sa
Normal file
20
Task/Loops-For/Sather/loops-for.sa
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
class MAIN is
|
||||
-- from, to, step
|
||||
for!(once init:INT, once to:INT, once inc:INT):INT is
|
||||
i ::= init;
|
||||
loop while!( i <= to );
|
||||
yield i;
|
||||
i := i + inc;
|
||||
end;
|
||||
end;
|
||||
|
||||
main is
|
||||
i, j :INT;
|
||||
loop i := for!(1, 5, 1); -- 1.upto!(5)
|
||||
loop j := for!(1, i, 1); -- 1.upto!(i)
|
||||
#OUT + "*";
|
||||
end;
|
||||
#OUT + "\n";
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
5
Task/Loops-For/Scala/loops-for.scala
Normal file
5
Task/Loops-For/Scala/loops-for.scala
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
for (i <- 1 to 5) {
|
||||
for (j <- 1 to i)
|
||||
print("*")
|
||||
println
|
||||
}
|
||||
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