langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
4
Task/Loops-Foreach/Nemerle/loops-foreach.nemerle
Normal file
4
Task/Loops-Foreach/Nemerle/loops-foreach.nemerle
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
def things = ["Apple", "Banana", "Coconut"];
|
||||
|
||||
foreach (thing in things) WriteLine(thing.ToLower());
|
||||
foreach (i in [5, 10 .. 100]) Write($"$i\t");
|
||||
13
Task/Loops-Foreach/NetRexx/loops-foreach.netrexx
Normal file
13
Task/Loops-Foreach/NetRexx/loops-foreach.netrexx
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref savelog symbols nobinary
|
||||
|
||||
say
|
||||
say 'Loops/Foreach'
|
||||
|
||||
days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
|
||||
daysl = Arrays.asList(days)
|
||||
daysi = daysl.iterator
|
||||
|
||||
loop while daysi.hasNext
|
||||
say daysi.next
|
||||
end
|
||||
6
Task/Loops-Foreach/Nimrod/loops-foreach.nimrod
Normal file
6
Task/Loops-Foreach/Nimrod/loops-foreach.nimrod
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
var list: seq[string] = @[]
|
||||
list.add("lorem")
|
||||
list.add("ipsum")
|
||||
list.add("dolor")
|
||||
for i in items(list):
|
||||
echo(i)
|
||||
3
Task/Loops-Foreach/OCaml/loops-foreach-1.ocaml
Normal file
3
Task/Loops-Foreach/OCaml/loops-foreach-1.ocaml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
List.iter
|
||||
(fun i -> Printf.printf "%d\n" i)
|
||||
collect_list
|
||||
3
Task/Loops-Foreach/OCaml/loops-foreach-2.ocaml
Normal file
3
Task/Loops-Foreach/OCaml/loops-foreach-2.ocaml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Array.iter
|
||||
(fun i -> Printf.printf "%d\n" i)
|
||||
collect_array
|
||||
4
Task/Loops-Foreach/Objeck/loops-foreach.objeck
Normal file
4
Task/Loops-Foreach/Objeck/loops-foreach.objeck
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
fruits := ["Apple", "Banana", "Coconut"];
|
||||
each(i : fruits) {
|
||||
fruits[i]->PrintLine();
|
||||
};
|
||||
5
Task/Loops-Foreach/Objective-C/loops-foreach-1.m
Normal file
5
Task/Loops-Foreach/Objective-C/loops-foreach-1.m
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
NSArray *collect;
|
||||
//...
|
||||
for(Type i in collect){
|
||||
NSLog(@"%@", i);
|
||||
}
|
||||
7
Task/Loops-Foreach/Objective-C/loops-foreach-2.m
Normal file
7
Task/Loops-Foreach/Objective-C/loops-foreach-2.m
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
NSArray *collect;
|
||||
//...
|
||||
NSEnumerator *enm = [collect objectEnumerator];
|
||||
id i;
|
||||
while( (i = [enm nextObject]) ) {
|
||||
// do something with object i
|
||||
}
|
||||
8
Task/Loops-Foreach/Octave/loops-foreach-1.octave
Normal file
8
Task/Loops-Foreach/Octave/loops-foreach-1.octave
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
a = [ 1,4,3,2 ];
|
||||
b = [ 1,2,3,4; 5,6,7,8 ];
|
||||
for v = a
|
||||
disp(v); % output single values: 1,4,3,2
|
||||
endfor
|
||||
for v = b
|
||||
disp(v); % v is the column vector [1;5], then [2;6] ...
|
||||
endfor
|
||||
6
Task/Loops-Foreach/Octave/loops-foreach-2.octave
Normal file
6
Task/Loops-Foreach/Octave/loops-foreach-2.octave
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
x.a = [ 10, 11, 12 ];
|
||||
x.b = { "Cell", "ul", "ar" };
|
||||
for [ val, key ] = x
|
||||
disp(key);
|
||||
disp(val);
|
||||
endfor
|
||||
7
Task/Loops-Foreach/Oz/loops-foreach.oz
Normal file
7
Task/Loops-Foreach/Oz/loops-foreach.oz
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
declare
|
||||
MyList = [1 2 3 4]
|
||||
in
|
||||
{ForAll MyList Show}
|
||||
|
||||
%% or:
|
||||
for E in MyList do {Show E} end
|
||||
1
Task/Loops-Foreach/PARI-GP/loops-foreach-1.pari
Normal file
1
Task/Loops-Foreach/PARI-GP/loops-foreach-1.pari
Normal file
|
|
@ -0,0 +1 @@
|
|||
for(i=1,#v,print(v[i]))
|
||||
1
Task/Loops-Foreach/PARI-GP/loops-foreach-2.pari
Normal file
1
Task/Loops-Foreach/PARI-GP/loops-foreach-2.pari
Normal file
|
|
@ -0,0 +1 @@
|
|||
apply(x->print(x),v)
|
||||
4
Task/Loops-Foreach/PL-I/loops-foreach.pli
Normal file
4
Task/Loops-Foreach/PL-I/loops-foreach.pli
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
declare A(10) fixed binary;
|
||||
do i = lbound(A,1) to hbound(A,1);
|
||||
put skip list (A(i));
|
||||
end;
|
||||
1
Task/Loops-Foreach/Perl-6/loops-foreach-1.pl6
Normal file
1
Task/Loops-Foreach/Perl-6/loops-foreach-1.pl6
Normal file
|
|
@ -0,0 +1 @@
|
|||
say $_ for @collection;
|
||||
1
Task/Loops-Foreach/Perl-6/loops-foreach-2.pl6
Normal file
1
Task/Loops-Foreach/Perl-6/loops-foreach-2.pl6
Normal file
|
|
@ -0,0 +1 @@
|
|||
for @collection -> $currentElement { say $currentElement; }
|
||||
6
Task/Loops-Foreach/Pike/loops-foreach-1.pike
Normal file
6
Task/Loops-Foreach/Pike/loops-foreach-1.pike
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
int main(){
|
||||
array(int|string) collect = ({109, "Hi", "asdf", "qwerty"});
|
||||
foreach(collect, int|string elem){
|
||||
write(elem + "\n");
|
||||
}
|
||||
}
|
||||
6
Task/Loops-Foreach/Pike/loops-foreach-2.pike
Normal file
6
Task/Loops-Foreach/Pike/loops-foreach-2.pike
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
int main(){
|
||||
mapping(string:string) coll = (["foo":"asdf", "bar":"qwer", "quux":"zxcv"]);
|
||||
foreach (coll;string key;string val)
|
||||
write(key+" --> "+val+"\n");
|
||||
}
|
||||
}
|
||||
4
Task/Loops-Foreach/Pop11/loops-foreach.pop11
Normal file
4
Task/Loops-Foreach/Pop11/loops-foreach.pop11
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
lvars el, lst = [1 2 3 4 foo bar];
|
||||
for el in lst do
|
||||
printf(el,'%p\n');
|
||||
endfor;
|
||||
2
Task/Loops-Foreach/PostScript/loops-foreach-1.ps
Normal file
2
Task/Loops-Foreach/PostScript/loops-foreach-1.ps
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
[1 5 3 2] { = } forall
|
||||
(abc) { = } forall
|
||||
6
Task/Loops-Foreach/PostScript/loops-foreach-2.ps
Normal file
6
Task/Loops-Foreach/PostScript/loops-foreach-2.ps
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<</a 25 /b 42>> {
|
||||
exch (Key: ) print
|
||||
=
|
||||
(Value: ) print
|
||||
=
|
||||
} forall
|
||||
3
Task/Loops-Foreach/PowerShell/loops-foreach.psh
Normal file
3
Task/Loops-Foreach/PowerShell/loops-foreach.psh
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
foreach ($x in $collection) {
|
||||
Write-Host $x
|
||||
}
|
||||
3
Task/Loops-Foreach/PureBasic/loops-foreach.purebasic
Normal file
3
Task/Loops-Foreach/PureBasic/loops-foreach.purebasic
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
ForEach element()
|
||||
PrintN(element())
|
||||
Next
|
||||
15
Task/Loops-Foreach/REBOL/loops-foreach.rebol
Normal file
15
Task/Loops-Foreach/REBOL/loops-foreach.rebol
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
REBOL [
|
||||
Title: "Loop/Foreach"
|
||||
Author: oofoe
|
||||
Date: 2009-12-19
|
||||
URL: http://rosettacode.org/wiki/Loop/Foreach
|
||||
]
|
||||
|
||||
x: [Sork Gun Blues Neds Thirst Fright Catur]
|
||||
|
||||
foreach i x [prin rejoin [i "day "]] print ""
|
||||
|
||||
; REBOL also has the 'forall' construct, which provides the rest of
|
||||
; the list from the current position.
|
||||
|
||||
forall x [prin rejoin [x/1 "day "]] print ""
|
||||
15
Task/Loops-Foreach/Retro/loops-foreach.retro
Normal file
15
Task/Loops-Foreach/Retro/loops-foreach.retro
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
( Strings: this will display the ASCII code for each character in a string )
|
||||
"This is a message" [ @ putn space ] ^types'STRING each@
|
||||
|
||||
( Array: display each element )
|
||||
needs array'
|
||||
[ 1 2 3 ] ^array'fromQuote [ @ putn space ] ^types'ARRAY each@
|
||||
|
||||
( Linked List: using the dictionary as an example, display each name )
|
||||
last [ d->name puts space ] ^types'LIST each@
|
||||
|
||||
( Generic Buffers; display each value in a buffer )
|
||||
create foo
|
||||
1 , 3 , 5 ,
|
||||
|
||||
foo 3 [ @ putn space ] ^types'BUFFER each@
|
||||
6
Task/Loops-Foreach/Run-BASIC/loops-foreach.run
Normal file
6
Task/Loops-Foreach/Run-BASIC/loops-foreach.run
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
t$={Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday"
|
||||
|
||||
while word$(t$,i+1,",") <> ""
|
||||
i = i + 1
|
||||
print word$(t$,i,",")
|
||||
wend
|
||||
11
Task/Loops-Foreach/SAS/loops-foreach.sas
Normal file
11
Task/Loops-Foreach/SAS/loops-foreach.sas
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/* Initialize an array with integers 1 to 10, and print their sum */
|
||||
data _null_;
|
||||
array a a1-a10;
|
||||
n=1;
|
||||
do over a;
|
||||
a=n;
|
||||
n=n+1;
|
||||
end;
|
||||
s=sum(of a{*});
|
||||
put s;
|
||||
run;
|
||||
2
Task/Loops-Foreach/Salmon/loops-foreach.salmon
Normal file
2
Task/Loops-Foreach/Salmon/loops-foreach.salmon
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
iterate (x; ["Red", "Green", "Blue"])
|
||||
x!;
|
||||
12
Task/Loops-Foreach/Seed7/loops-foreach.seed7
Normal file
12
Task/Loops-Foreach/Seed7/loops-foreach.seed7
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
$ include "seed7_05.s7i";
|
||||
|
||||
var array string: things is [] ("Apple", "Banana", "Coconut");
|
||||
|
||||
const proc: main is func
|
||||
local
|
||||
var string: thing is "";
|
||||
begin
|
||||
for thing range things do
|
||||
writeln(thing);
|
||||
end for;
|
||||
end func;
|
||||
1
Task/Loops-Foreach/Slate/loops-foreach.slate
Normal file
1
Task/Loops-Foreach/Slate/loops-foreach.slate
Normal file
|
|
@ -0,0 +1 @@
|
|||
c do: [| :obj | print: obj].
|
||||
3
Task/Loops-Foreach/Standard-ML/loops-foreach-1.ml
Normal file
3
Task/Loops-Foreach/Standard-ML/loops-foreach-1.ml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
app
|
||||
(fn i => print (Int.toString i ^ "\n"))
|
||||
collect_list
|
||||
3
Task/Loops-Foreach/Standard-ML/loops-foreach-2.ml
Normal file
3
Task/Loops-Foreach/Standard-ML/loops-foreach-2.ml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Array.app
|
||||
(fn i => print (Int.toString i ^ "\n"))
|
||||
collect_array
|
||||
2
Task/Loops-Foreach/Suneido/loops-foreach.suneido
Normal file
2
Task/Loops-Foreach/Suneido/loops-foreach.suneido
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
for i in #(1, 2, 3)
|
||||
Print(i)
|
||||
10
Task/Loops-Foreach/SystemVerilog/loops-foreach.v
Normal file
10
Task/Loops-Foreach/SystemVerilog/loops-foreach.v
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
program main;
|
||||
int values[$];
|
||||
|
||||
initial begin
|
||||
values = '{ 1, 3, 7, 11 };
|
||||
foreach (values[i]) begin
|
||||
$display( "%0d --> %0d", i, values[i] );
|
||||
end
|
||||
end
|
||||
endprogram
|
||||
5
Task/Loops-Foreach/TI-89-BASIC/loops-foreach.ti-89
Normal file
5
Task/Loops-Foreach/TI-89-BASIC/loops-foreach.ti-89
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
Local i,strs
|
||||
Define strs = {"Lorem","ipsum","dolor"}
|
||||
For i, 1, dim(strs)
|
||||
Disp strs[i]
|
||||
EndFor
|
||||
5
Task/Loops-Foreach/TUSCRIPT/loops-foreach.tuscript
Normal file
5
Task/Loops-Foreach/TUSCRIPT/loops-foreach.tuscript
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
$$ MODE TUSCRIPT
|
||||
week="Monday'Tuesday'Wednesday'Thursday'Friday'Saterday'Sunday"
|
||||
LOOP day=week
|
||||
PRINT day
|
||||
ENDLOOP
|
||||
1
Task/Loops-Foreach/Trith/loops-foreach.trith
Normal file
1
Task/Loops-Foreach/Trith/loops-foreach.trith
Normal file
|
|
@ -0,0 +1 @@
|
|||
[1 2 3 4 5] [print] each
|
||||
3
Task/Loops-Foreach/UNIX-Shell/loops-foreach-1.sh
Normal file
3
Task/Loops-Foreach/UNIX-Shell/loops-foreach-1.sh
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
for file in *.sh; do
|
||||
echo "filename is $file"
|
||||
done
|
||||
8
Task/Loops-Foreach/UNIX-Shell/loops-foreach-2.sh
Normal file
8
Task/Loops-Foreach/UNIX-Shell/loops-foreach-2.sh
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin
|
||||
|
||||
oldifs=$IFS
|
||||
IFS=:
|
||||
for dir in $PATH; do
|
||||
echo search $dir
|
||||
done
|
||||
IFS=$oldifs
|
||||
4
Task/Loops-Foreach/UNIX-Shell/loops-foreach-3.sh
Normal file
4
Task/Loops-Foreach/UNIX-Shell/loops-foreach-3.sh
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
collection=("first" "second" "third" "fourth" "something else")
|
||||
for x in "${collection[@]}"; do
|
||||
echo "$x"
|
||||
done
|
||||
4
Task/Loops-Foreach/UNIX-Shell/loops-foreach-4.sh
Normal file
4
Task/Loops-Foreach/UNIX-Shell/loops-foreach-4.sh
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
set -A collection "first" "second" "third" "fourth" "something else"
|
||||
for x in "${collection[@]}"; do
|
||||
echo "$x"
|
||||
done
|
||||
4
Task/Loops-Foreach/UNIX-Shell/loops-foreach-5.sh
Normal file
4
Task/Loops-Foreach/UNIX-Shell/loops-foreach-5.sh
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
set collection=(first second third fourth "something else")
|
||||
foreach x ($collection:q)
|
||||
echo $x:q
|
||||
end
|
||||
1
Task/Loops-Foreach/V/loops-foreach.v
Normal file
1
Task/Loops-Foreach/V/loops-foreach.v
Normal file
|
|
@ -0,0 +1 @@
|
|||
[1 2 3] [puts] step
|
||||
8
Task/Loops-Foreach/VBScript/loops-foreach.vbscript
Normal file
8
Task/Loops-Foreach/VBScript/loops-foreach.vbscript
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
dim items(2)
|
||||
items(0)="Apple"
|
||||
items(1)="Orange"
|
||||
items(2)="Banana"
|
||||
|
||||
For Each x in items
|
||||
WScript.Echo x
|
||||
Next
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
Dim list As New List(Of String)
|
||||
list.Add("Car")
|
||||
list.Add("Boat")
|
||||
list.Add("Train")
|
||||
|
||||
For Each item In list
|
||||
Console.WriteLine(item)
|
||||
Next
|
||||
6
Task/Loops-Foreach/XPL0/loops-foreach.xpl0
Normal file
6
Task/Loops-Foreach/XPL0/loops-foreach.xpl0
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
include c:\cxpl\codes;
|
||||
int List, I;
|
||||
[List:= ["Red", "Green", "Blue", "Black", "White"];
|
||||
for I:= 0, 5-1 do
|
||||
[Text(0, List(I)); CrLf(0)];
|
||||
]
|
||||
4
Task/Loops-Foreach/XSLT/loops-foreach.xslt
Normal file
4
Task/Loops-Foreach/XSLT/loops-foreach.xslt
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<fo:block font-weight="bold">Adults:</fo:block>
|
||||
<xsl:for-each select="person[@age >= 21]">
|
||||
<fo:block><xsl:value-of select="position()"/>. <xsl:value-of select="@name"/></fo:block>
|
||||
</xsl:for-each>
|
||||
Loading…
Add table
Add a link
Reference in a new issue