Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
3
Task/Loops-Foreach/00-META.yaml
Normal file
3
Task/Loops-Foreach/00-META.yaml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
from: http://rosettacode.org/wiki/Loops/Foreach
|
||||
note: Iteration
|
||||
23
Task/Loops-Foreach/00-TASK.txt
Normal file
23
Task/Loops-Foreach/00-TASK.txt
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
Loop through and print each element in a collection in order.
|
||||
|
||||
Use your language's "for each" loop if it has one, otherwise iterate through the collection in order with some other loop.
|
||||
|
||||
|
||||
;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>
|
||||
|
||||
4
Task/Loops-Foreach/11l/loops-foreach.11l
Normal file
4
Task/Loops-Foreach/11l/loops-foreach.11l
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
V things = [‘Apple’, ‘Banana’, ‘Coconut’]
|
||||
|
||||
L(thing) things
|
||||
print(thing)
|
||||
5
Task/Loops-Foreach/ACL2/loops-foreach.acl2
Normal file
5
Task/Loops-Foreach/ACL2/loops-foreach.acl2
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(defun print-list (xs)
|
||||
(if (endp xs)
|
||||
nil
|
||||
(prog2$ (cw "~x0~%" (first xs))
|
||||
(print-list (rest xs)))))
|
||||
5
Task/Loops-Foreach/ALGOL-68/loops-foreach-1.alg
Normal file
5
Task/Loops-Foreach/ALGOL-68/loops-foreach-1.alg
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
[]UNION(STRING, INT, PROC(REF FILE)VOID) collection = ("Mary","Had",1,"little","lamb.",new line);
|
||||
|
||||
FOR index FROM LWB collection TO UPB collection DO
|
||||
print((collection[index]," "))
|
||||
OD
|
||||
3
Task/Loops-Foreach/ALGOL-68/loops-foreach-2.alg
Normal file
3
Task/Loops-Foreach/ALGOL-68/loops-foreach-2.alg
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
FORALL index IN collection DO
|
||||
print((collection[index]," "))
|
||||
OD
|
||||
6
Task/Loops-Foreach/AWK/loops-foreach-1.awk
Normal file
6
Task/Loops-Foreach/AWK/loops-foreach-1.awk
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
BEGIN {
|
||||
split("Mary had a little lamb", strs, " ")
|
||||
for(el in strs) {
|
||||
print strs[el]
|
||||
}
|
||||
}
|
||||
6
Task/Loops-Foreach/AWK/loops-foreach-2.awk
Normal file
6
Task/Loops-Foreach/AWK/loops-foreach-2.awk
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
BEGIN {
|
||||
n = split("Mary had a little lamb", strs, " ")
|
||||
for(i=1; i <= n; i++) {
|
||||
print strs[i]
|
||||
}
|
||||
}
|
||||
6
Task/Loops-Foreach/AWK/loops-foreach-3.awk
Normal file
6
Task/Loops-Foreach/AWK/loops-foreach-3.awk
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# This will not work
|
||||
BEGIN {
|
||||
for (el in "apples","bananas","cherries") {
|
||||
print "I like " el
|
||||
}
|
||||
}
|
||||
17
Task/Loops-Foreach/Action-/loops-foreach.action
Normal file
17
Task/Loops-Foreach/Action-/loops-foreach.action
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
PROC Main()
|
||||
DEFINE PTR="CARD"
|
||||
BYTE i
|
||||
PTR ARRAY items(10)
|
||||
items(0)="First" items(1)="Second"
|
||||
items(2)="Third" items(3)="Fourth"
|
||||
items(4)="Fifth" items(5)="Sixth"
|
||||
items(6)="Seventh" items(7)="Eighth"
|
||||
items(8)="Ninth" items(9)="Tenth"
|
||||
|
||||
PrintE("In Action! there is no for-each loop")
|
||||
PutE()
|
||||
FOR i=0 TO 9
|
||||
DO
|
||||
PrintE(items(i))
|
||||
OD
|
||||
RETURN
|
||||
14
Task/Loops-Foreach/Ada/loops-foreach-1.ada
Normal file
14
Task/Loops-Foreach/Ada/loops-foreach-1.ada
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
with Ada.Integer_Text_IO;
|
||||
use Ada.Integer_Text_IO;
|
||||
|
||||
procedure For_Each is
|
||||
|
||||
A : array (1..5) of Integer := (-1, 0, 1, 2, 3);
|
||||
|
||||
begin
|
||||
|
||||
for Num in A'Range loop
|
||||
Put( A (Num) );
|
||||
end loop;
|
||||
|
||||
end For_Each;
|
||||
3
Task/Loops-Foreach/Ada/loops-foreach-2.ada
Normal file
3
Task/Loops-Foreach/Ada/loops-foreach-2.ada
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
for Item of A loop
|
||||
Put( Item );
|
||||
end loop;
|
||||
25
Task/Loops-Foreach/Ada/loops-foreach-3.ada
Normal file
25
Task/Loops-Foreach/Ada/loops-foreach-3.ada
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
with Ada.Integer_Text_IO, Ada.Containers.Doubly_Linked_Lists;
|
||||
use Ada.Integer_Text_IO, Ada.Containers;
|
||||
|
||||
procedure Doubly_Linked_List is
|
||||
|
||||
package DL_List_Pkg is new Doubly_Linked_Lists (Integer);
|
||||
use DL_List_Pkg;
|
||||
|
||||
procedure Print_Node (Position : Cursor) is
|
||||
begin
|
||||
Put (Element (Position));
|
||||
end Print_Node;
|
||||
|
||||
DL_List : List;
|
||||
|
||||
begin
|
||||
|
||||
DL_List.Append (1);
|
||||
DL_List.Append (2);
|
||||
DL_List.Append (3);
|
||||
|
||||
-- Iterates through every node of the list.
|
||||
DL_List.Iterate (Print_Node'Access);
|
||||
|
||||
end Doubly_Linked_List;
|
||||
25
Task/Loops-Foreach/Ada/loops-foreach-4.ada
Normal file
25
Task/Loops-Foreach/Ada/loops-foreach-4.ada
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
with Ada.Integer_Text_IO, Ada.Containers.Vectors;
|
||||
use Ada.Integer_Text_IO, Ada.Containers;
|
||||
|
||||
procedure Vector_Example is
|
||||
|
||||
package Vector_Pkg is new Vectors (Natural, Integer);
|
||||
use Vector_Pkg;
|
||||
|
||||
procedure Print_Element (Position : Cursor) is
|
||||
begin
|
||||
Put (Element (Position));
|
||||
end Print_Element;
|
||||
|
||||
V : Vector;
|
||||
|
||||
begin
|
||||
|
||||
V.Append (1);
|
||||
V.Append (2);
|
||||
V.Append (3);
|
||||
|
||||
-- Iterates through every element of the vector.
|
||||
V.Iterate (Print_Element'Access);
|
||||
|
||||
end Vector_Example;
|
||||
4
Task/Loops-Foreach/Aikido/loops-foreach-1.aikido
Normal file
4
Task/Loops-Foreach/Aikido/loops-foreach-1.aikido
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
var str = "hello world"
|
||||
foreach ch str { // you can also use an optional 'in'
|
||||
println (ch) // one character at a time
|
||||
}
|
||||
4
Task/Loops-Foreach/Aikido/loops-foreach-2.aikido
Normal file
4
Task/Loops-Foreach/Aikido/loops-foreach-2.aikido
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
var vec = [1,2,3,4]
|
||||
foreach v vec { // you can also use an optional 'in'
|
||||
println (v)
|
||||
}
|
||||
4
Task/Loops-Foreach/Aikido/loops-foreach-3.aikido
Normal file
4
Task/Loops-Foreach/Aikido/loops-foreach-3.aikido
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
var cities = {"San Ramon": 50000, "Walnut Creek": 70000, "San Francisco": 700000} // map literal
|
||||
foreach city cities {
|
||||
println (city.first + " has population " + city.second)
|
||||
}
|
||||
13
Task/Loops-Foreach/Aikido/loops-foreach-4.aikido
Normal file
13
Task/Loops-Foreach/Aikido/loops-foreach-4.aikido
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
foreach i 100 {
|
||||
println (i) // prints values 0..99
|
||||
}
|
||||
|
||||
foreach i 10..20 {
|
||||
println (i) // prints values 10..20
|
||||
}
|
||||
|
||||
var a = 20
|
||||
var b = 10
|
||||
foreach i a..b {
|
||||
println (i) // prints values from a to b (20..10)
|
||||
}
|
||||
34
Task/Loops-Foreach/Aikido/loops-foreach-5.aikido
Normal file
34
Task/Loops-Foreach/Aikido/loops-foreach-5.aikido
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
class List {
|
||||
class Element (public data) {
|
||||
public var next = null
|
||||
}
|
||||
var start = null
|
||||
|
||||
public function insert (data) {
|
||||
var element = new Element (data)
|
||||
element.next = start
|
||||
start = element
|
||||
}
|
||||
|
||||
public operator foreach (var iter) {
|
||||
if (typeof(iter) == "none") { // first iteration
|
||||
iter = start
|
||||
return iter.data
|
||||
} elif (iter.next == null) { // check for last iteration
|
||||
iter = none
|
||||
} else {
|
||||
iter = iter.next // somewhere in the middle
|
||||
return iter.data
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var list = new List()
|
||||
list.insert (1)
|
||||
list.insert (2)
|
||||
list.insert (4)
|
||||
|
||||
foreach n list {
|
||||
println (n)
|
||||
}
|
||||
13
Task/Loops-Foreach/Aikido/loops-foreach-6.aikido
Normal file
13
Task/Loops-Foreach/Aikido/loops-foreach-6.aikido
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// coroutine to generate the squares of a sequence of numbers
|
||||
function squares (start, end) {
|
||||
for (var i = start ; i < end ; i++) {
|
||||
yield i*i
|
||||
}
|
||||
}
|
||||
|
||||
var start = 10
|
||||
var end = 20
|
||||
|
||||
foreach s squares (start, end) {
|
||||
println (s)
|
||||
}
|
||||
4
Task/Loops-Foreach/Aikido/loops-foreach-7.aikido
Normal file
4
Task/Loops-Foreach/Aikido/loops-foreach-7.aikido
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
var s = openin ("input.txt")
|
||||
foreach line s {
|
||||
print (line)
|
||||
}
|
||||
7
Task/Loops-Foreach/Aikido/loops-foreach-8.aikido
Normal file
7
Task/Loops-Foreach/Aikido/loops-foreach-8.aikido
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
enum Color {
|
||||
RED, GREEN, BLUE
|
||||
}
|
||||
|
||||
foreach color Color {
|
||||
println (color)
|
||||
}
|
||||
5
Task/Loops-Foreach/Aime/loops-foreach.aime
Normal file
5
Task/Loops-Foreach/Aime/loops-foreach.aime
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# iterate over a list of integers
|
||||
integer i, v;
|
||||
|
||||
for (i, v in list(2, 3, 5, 7, 11, 13, 17, 18)) {
|
||||
}
|
||||
9
Task/Loops-Foreach/AmigaE/loops-foreach.amiga
Normal file
9
Task/Loops-Foreach/AmigaE/loops-foreach.amiga
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
PROC main()
|
||||
DEF a_list : PTR TO LONG, a
|
||||
a_list := [10, 12, 14]
|
||||
FOR a := 0 TO ListLen(a_list)-1
|
||||
WriteF('\d\n', a_list[a])
|
||||
ENDFOR
|
||||
-> if the "action" fits a single statement, we can do instead
|
||||
ForAll({a}, a_list, `WriteF('\d\n', a))
|
||||
ENDPROC
|
||||
5
Task/Loops-Foreach/Apex/loops-foreach.apex
Normal file
5
Task/Loops-Foreach/Apex/loops-foreach.apex
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
Integer[] myInts = new Integer[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||
|
||||
for (Integer i : myInts) {
|
||||
System.debug(i);
|
||||
}
|
||||
3
Task/Loops-Foreach/AppleScript/loops-foreach.applescript
Normal file
3
Task/Loops-Foreach/AppleScript/loops-foreach.applescript
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
repeat with fruit in {"Apple", "Orange", "Banana"}
|
||||
log contents of fruit
|
||||
end repeat
|
||||
13
Task/Loops-Foreach/Arturo/loops-foreach.arturo
Normal file
13
Task/Loops-Foreach/Arturo/loops-foreach.arturo
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
arr: ["one" "two" "three"]
|
||||
|
||||
dict: #[
|
||||
name: "John"
|
||||
surname: "Doe"
|
||||
age: 34
|
||||
]
|
||||
|
||||
loop arr 'item ->
|
||||
print item
|
||||
|
||||
loop dict [key val]->
|
||||
print [key "=>" val]
|
||||
3
Task/Loops-Foreach/AutoHotkey/loops-foreach.ahk
Normal file
3
Task/Loops-Foreach/AutoHotkey/loops-foreach.ahk
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
string = mary,had,a,little,lamb
|
||||
Loop, Parse, string, `,
|
||||
MsgBox %A_LoopField%
|
||||
7
Task/Loops-Foreach/BASIC256/loops-foreach.basic
Normal file
7
Task/Loops-Foreach/BASIC256/loops-foreach.basic
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
DIM collection$(1)
|
||||
collection$ = { "The", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog." }
|
||||
|
||||
FOR i = 0 TO collection$[?]-1
|
||||
PRINT collection$[i]+ " ";
|
||||
NEXT i
|
||||
PRINT
|
||||
8
Task/Loops-Foreach/BBC-BASIC/loops-foreach.basic
Normal file
8
Task/Loops-Foreach/BBC-BASIC/loops-foreach.basic
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
DIM collection$(8)
|
||||
collection$() = "The", "quick", "brown", "fox", "jumps", \
|
||||
\ "over", "the", "lazy", "dog."
|
||||
|
||||
FOR index% = 0 TO DIM(collection$(), 1)
|
||||
PRINT collection$(index%) " ";
|
||||
NEXT
|
||||
PRINT
|
||||
8
Task/Loops-Foreach/BaCon/loops-foreach.bacon
Normal file
8
Task/Loops-Foreach/BaCon/loops-foreach.bacon
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
OPTION COLLAPSE TRUE
|
||||
FOR x$ IN "Hello cruel world"
|
||||
PRINT x$
|
||||
NEXT
|
||||
|
||||
FOR y$ IN "1,2,\"3,4\",5" STEP ","
|
||||
PRINT y$
|
||||
NEXT
|
||||
4
Task/Loops-Foreach/Batch-File/loops-foreach-1.bat
Normal file
4
Task/Loops-Foreach/Batch-File/loops-foreach-1.bat
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
@echo off
|
||||
for %%A in (This is a sample collection) do (
|
||||
echo %%A
|
||||
)
|
||||
5
Task/Loops-Foreach/Batch-File/loops-foreach-2.bat
Normal file
5
Task/Loops-Foreach/Batch-File/loops-foreach-2.bat
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
@echo off
|
||||
set "collection=This is a sample collection"
|
||||
for %%A in (%collection%) do (
|
||||
echo %%A
|
||||
)
|
||||
6
Task/Loops-Foreach/Bc/loops-foreach.bc
Normal file
6
Task/Loops-Foreach/Bc/loops-foreach.bc
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
a[0] = .123
|
||||
a[1] = 234
|
||||
a[3] = 95.6
|
||||
for (i = 0; i < 4; i++) {
|
||||
a[i]
|
||||
}
|
||||
7
Task/Loops-Foreach/Bracmat/loops-foreach-1.bracmat
Normal file
7
Task/Loops-Foreach/Bracmat/loops-foreach-1.bracmat
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
( list
|
||||
= Afrikaans
|
||||
Ελληνικά
|
||||
עברית
|
||||
മലയാളം
|
||||
ئۇيغۇرچە
|
||||
)
|
||||
2
Task/Loops-Foreach/Bracmat/loops-foreach-2.bracmat
Normal file
2
Task/Loops-Foreach/Bracmat/loops-foreach-2.bracmat
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
!list:?L
|
||||
& whl'(!L:%?language ?L&out$!language)
|
||||
7
Task/Loops-Foreach/Bracmat/loops-foreach-3.bracmat
Normal file
7
Task/Loops-Foreach/Bracmat/loops-foreach-3.bracmat
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
!list:?L
|
||||
& ( loop
|
||||
= !L:%?language ?L
|
||||
& out$!language
|
||||
& !loop
|
||||
)
|
||||
& ~!loop
|
||||
4
Task/Loops-Foreach/Bracmat/loops-foreach-4.bracmat
Normal file
4
Task/Loops-Foreach/Bracmat/loops-foreach-4.bracmat
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
( !list
|
||||
: ? (%@?language&out$!language&~) ?
|
||||
|
|
||||
)
|
||||
4
Task/Loops-Foreach/C++/loops-foreach-1.cpp
Normal file
4
Task/Loops-Foreach/C++/loops-foreach-1.cpp
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
for (container_type::iterator i = container.begin(); i != container.end(); ++i)
|
||||
{
|
||||
std::cout << *i << "\n";
|
||||
}
|
||||
2
Task/Loops-Foreach/C++/loops-foreach-2.cpp
Normal file
2
Task/Loops-Foreach/C++/loops-foreach-2.cpp
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
std::copy(container.begin(), container.end(),
|
||||
std::ostream_iterator<container_type::value_type>(std::cout, "\n"));
|
||||
7
Task/Loops-Foreach/C++/loops-foreach-3.cpp
Normal file
7
Task/Loops-Foreach/C++/loops-foreach-3.cpp
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
void print_element(container_type::value_type const& v)
|
||||
{
|
||||
std::cout << v << "\n";
|
||||
}
|
||||
|
||||
...
|
||||
std::for_each(container.begin(), container.end(), print_element);
|
||||
4
Task/Loops-Foreach/C++/loops-foreach-4.cpp
Normal file
4
Task/Loops-Foreach/C++/loops-foreach-4.cpp
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
for (auto element: container)
|
||||
{
|
||||
std::cout << element << "\n";
|
||||
}
|
||||
4
Task/Loops-Foreach/C++/loops-foreach-5.cpp
Normal file
4
Task/Loops-Foreach/C++/loops-foreach-5.cpp
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
for (auto const& element: container)
|
||||
{
|
||||
std::cout << element << "\n";
|
||||
}
|
||||
4
Task/Loops-Foreach/C++/loops-foreach-6.cpp
Normal file
4
Task/Loops-Foreach/C++/loops-foreach-6.cpp
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
for (auto&& element: container) //use a 'universal reference'
|
||||
{
|
||||
element += 42;
|
||||
}
|
||||
4
Task/Loops-Foreach/C-Shell/loops-foreach.csh
Normal file
4
Task/Loops-Foreach/C-Shell/loops-foreach.csh
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
set collection=(first second third fourth "something else")
|
||||
foreach x ($collection:q)
|
||||
echo $x:q
|
||||
end
|
||||
6
Task/Loops-Foreach/C-sharp/loops-foreach.cs
Normal file
6
Task/Loops-Foreach/C-sharp/loops-foreach.cs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
string[] things = {"Apple", "Banana", "Coconut"};
|
||||
|
||||
foreach (string thing in things)
|
||||
{
|
||||
Console.WriteLine(thing);
|
||||
}
|
||||
10
Task/Loops-Foreach/C/loops-foreach-1.c
Normal file
10
Task/Loops-Foreach/C/loops-foreach-1.c
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#include <stdio.h>
|
||||
...
|
||||
|
||||
const char *list[] = {"Red","Green","Blue","Black","White"};
|
||||
#define LIST_SIZE (sizeof(list)/sizeof(list[0]))
|
||||
|
||||
int ix;
|
||||
for(ix=0; ix<LIST_SIZE; ix++) {
|
||||
printf("%s\n", list[ix]);
|
||||
}
|
||||
17
Task/Loops-Foreach/C/loops-foreach-2.c
Normal file
17
Task/Loops-Foreach/C/loops-foreach-2.c
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
/* foreach macro for using a string as a collection of char */
|
||||
#define foreach( ptrvar , strvar ) char* ptrvar; for( ptrvar=strvar ; (*ptrvar) != '\0' ; *ptrvar++)
|
||||
|
||||
int main(int argc,char* argv[]){
|
||||
char* s1="abcdefg";
|
||||
char* s2="123456789";
|
||||
foreach( p1 , s1 ) {
|
||||
printf("loop 1 %c\n",*p1);
|
||||
}
|
||||
foreach( p2 , s2 ){
|
||||
printf("loop 2 %c\n",*p2);
|
||||
}
|
||||
exit(0);
|
||||
return(0);
|
||||
}
|
||||
16
Task/Loops-Foreach/C/loops-foreach-3.c
Normal file
16
Task/Loops-Foreach/C/loops-foreach-3.c
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
int main(int argc,char* argv[]){
|
||||
/* foreach macro viewing an array of int values as a collection of int values */
|
||||
#define foreach( intpvar , intary ) int* intpvar; for( intpvar=intary; intpvar < (intary+(sizeof(intary)/sizeof(intary[0]))) ; intpvar++)
|
||||
int a1[]={ 1 , 1 , 2 , 3 , 5 , 8 };
|
||||
int a2[]={ 3 , 1 , 4 , 1, 5, 9 };
|
||||
foreach( p1 , a1 ) {
|
||||
printf("loop 1 %d\n",*p1);
|
||||
}
|
||||
foreach( p2 , a2 ){
|
||||
printf("loop 2 %d\n",*p2);
|
||||
}
|
||||
exit(0);
|
||||
return(0);
|
||||
}
|
||||
24
Task/Loops-Foreach/C/loops-foreach-4.c
Normal file
24
Task/Loops-Foreach/C/loops-foreach-4.c
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
int main(int argc,char* argv[]){
|
||||
#define foreach( idxtype , idxpvar , col , colsiz ) idxtype* idxpvar; for( idxpvar=col ; idxpvar < (col+(colsiz)) ; idxpvar++)
|
||||
#define arraylen( ary ) ( sizeof(ary)/sizeof(ary[0]) )
|
||||
char* c1="collection";
|
||||
int c2[]={ 3 , 1 , 4 , 1, 5, 9 };
|
||||
double* c3;
|
||||
int c3len=4;
|
||||
c3=(double*)calloc(c3len,sizeof(double));
|
||||
c3[0]=1.2;c3[1]=3.4;c3[2]=5.6;c3[3]=7.8;
|
||||
foreach( char,p1 , c1, strlen(c1) ) {
|
||||
printf("loop 1 : %c\n",*p1);
|
||||
}
|
||||
foreach( int,p2 , c2, arraylen(c2) ){
|
||||
printf("loop 2 : %d\n",*p2);
|
||||
}
|
||||
foreach( double,p3 , c3, c3len ){
|
||||
printf("loop 3 : %3.1lf\n",*p3);
|
||||
}
|
||||
exit(0);
|
||||
return(0);
|
||||
}
|
||||
10
Task/Loops-Foreach/CLU/loops-foreach.clu
Normal file
10
Task/Loops-Foreach/CLU/loops-foreach.clu
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
start_up = proc ()
|
||||
po: stream := stream$primary_output()
|
||||
|
||||
words: array[string] := array[string]$
|
||||
["enemy", "lasagna", "robust", "below", "wax"]
|
||||
|
||||
for word: string in array[string]$elements(words) do
|
||||
stream$putl(po, word)
|
||||
end
|
||||
end start_up
|
||||
5
Task/Loops-Foreach/CMake/loops-foreach.cmake
Normal file
5
Task/Loops-Foreach/CMake/loops-foreach.cmake
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
set(list one.c two.c three.c)
|
||||
|
||||
foreach(file ${list})
|
||||
message(${file})
|
||||
endforeach(file)
|
||||
6
Task/Loops-Foreach/COBOL/loops-foreach.cobol
Normal file
6
Task/Loops-Foreach/COBOL/loops-foreach.cobol
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
01 things occurs 3.
|
||||
...
|
||||
set content of things to ("Apple", "Banana", "Coconut")
|
||||
perform varying thing as string through things
|
||||
display thing
|
||||
end-perform
|
||||
2
Task/Loops-Foreach/Chapel/loops-foreach.chapel
Normal file
2
Task/Loops-Foreach/Chapel/loops-foreach.chapel
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
var food = ["Milk", "Bread", "Butter"];
|
||||
for f in food do writeln(f);
|
||||
1
Task/Loops-Foreach/Clojure/loops-foreach.clj
Normal file
1
Task/Loops-Foreach/Clojure/loops-foreach.clj
Normal file
|
|
@ -0,0 +1 @@
|
|||
(doseq [item collection] (println item))
|
||||
3
Task/Loops-Foreach/ColdFusion/loops-foreach.cfm
Normal file
3
Task/Loops-Foreach/ColdFusion/loops-foreach.cfm
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<Cfloop list="Fee, Fi, Foe, Fum" index="i">
|
||||
<Cfoutput>#i#!</Cfoutput>
|
||||
</Cfloop>
|
||||
11
Task/Loops-Foreach/Commodore-BASIC/loops-foreach.basic
Normal file
11
Task/Loops-Foreach/Commodore-BASIC/loops-foreach.basic
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
10 DIM A$(9) :REM DECLARE STRING ARRAY
|
||||
20 REM *** FILL ARRAY WITH WORDS ***
|
||||
30 FOR I = 0 TO 8
|
||||
40 READ A$(I)
|
||||
50 NEXT
|
||||
60 REM *** PRINT ARRAY CONTENTS ***
|
||||
70 FOR I = 0 TO 8
|
||||
80 PRINT A$(I)" ";
|
||||
90 NEXT
|
||||
100 END
|
||||
1000 DATA THE, QUICK, BROWN, FOX, JUMPS, OVER, THE, LAZY, DOG.
|
||||
1
Task/Loops-Foreach/Common-Lisp/loops-foreach-1.lisp
Normal file
1
Task/Loops-Foreach/Common-Lisp/loops-foreach-1.lisp
Normal file
|
|
@ -0,0 +1 @@
|
|||
(loop for i in list do (print i))
|
||||
1
Task/Loops-Foreach/Common-Lisp/loops-foreach-2.lisp
Normal file
1
Task/Loops-Foreach/Common-Lisp/loops-foreach-2.lisp
Normal file
|
|
@ -0,0 +1 @@
|
|||
(map nil #'print list)
|
||||
1
Task/Loops-Foreach/Common-Lisp/loops-foreach-3.lisp
Normal file
1
Task/Loops-Foreach/Common-Lisp/loops-foreach-3.lisp
Normal file
|
|
@ -0,0 +1 @@
|
|||
(dolist (x the-list) (print x))
|
||||
4
Task/Loops-Foreach/Common-Lisp/loops-foreach-4.lisp
Normal file
4
Task/Loops-Foreach/Common-Lisp/loops-foreach-4.lisp
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(use-package :iterate)
|
||||
(iter
|
||||
(for x in the-list)
|
||||
(print x))
|
||||
4
Task/Loops-Foreach/Common-Lisp/loops-foreach-5.lisp
Normal file
4
Task/Loops-Foreach/Common-Lisp/loops-foreach-5.lisp
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(let ((the-list '(1 7 "foo" 1 4))) ; Set the-list as the list
|
||||
(do ((i the-list (rest i))) ; Initialize to the-list and set to rest on every loop
|
||||
((null i)) ; Break condition
|
||||
(print (first i)))) ; On every loop print list's first element
|
||||
19
Task/Loops-Foreach/Creative-Basic/loops-foreach.basic
Normal file
19
Task/Loops-Foreach/Creative-Basic/loops-foreach.basic
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
DEF AnArray[11]:INT
|
||||
|
||||
AnArray=0,1,2,3,4,5,6,7,8,9,10
|
||||
|
||||
'A console only program will work without OPENCONSOLE and
|
||||
'CLOSECONSOLE; however, it does not hurt to use them.
|
||||
OPENCONSOLE
|
||||
|
||||
FOR X=0 TO 10
|
||||
PRINT AnArray[X]
|
||||
NEXT X
|
||||
|
||||
'keep the console from closing right away.
|
||||
DO:UNTIL INKEY$<>""
|
||||
|
||||
CLOSECONSOLE
|
||||
|
||||
'because this is a console only program.
|
||||
END
|
||||
18
Task/Loops-Foreach/D/loops-foreach.d
Normal file
18
Task/Loops-Foreach/D/loops-foreach.d
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import std.stdio: writeln;
|
||||
|
||||
void main() {
|
||||
auto collection1 = "ABC";
|
||||
foreach (element; collection1)
|
||||
writeln(element);
|
||||
|
||||
auto collection2 = [1, 2, 3];
|
||||
foreach (element; collection1)
|
||||
writeln(element);
|
||||
|
||||
auto collection3 = [1:10, 2:20, 3:30];
|
||||
foreach (element; collection3)
|
||||
writeln(element);
|
||||
|
||||
foreach (key, value; collection3)
|
||||
writeln(key, " ", value);
|
||||
}
|
||||
2
Task/Loops-Foreach/Dao/loops-foreach.dao
Normal file
2
Task/Loops-Foreach/Dao/loops-foreach.dao
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
items = { 1, 2, 3 }
|
||||
for( item in items ) io.writeln( item )
|
||||
10
Task/Loops-Foreach/Delphi/loops-foreach.delphi
Normal file
10
Task/Loops-Foreach/Delphi/loops-foreach.delphi
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
program LoopForEach;
|
||||
|
||||
{$APPTYPE CONSOLE}
|
||||
|
||||
var
|
||||
s: string;
|
||||
begin
|
||||
for s in 'Hello' do
|
||||
Writeln(s);
|
||||
end.
|
||||
3
Task/Loops-Foreach/Dragon/loops-foreach.dragon
Normal file
3
Task/Loops-Foreach/Dragon/loops-foreach.dragon
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
for value : array {
|
||||
showln value
|
||||
}
|
||||
3
Task/Loops-Foreach/Dyalect/loops-foreach-1.dyalect
Normal file
3
Task/Loops-Foreach/Dyalect/loops-foreach-1.dyalect
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
for i in [1,2,3] {
|
||||
print(i)
|
||||
}
|
||||
3
Task/Loops-Foreach/Dyalect/loops-foreach-2.dyalect
Normal file
3
Task/Loops-Foreach/Dyalect/loops-foreach-2.dyalect
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
for i in [1,2,3].Iterate() {
|
||||
print(i)
|
||||
}
|
||||
9
Task/Loops-Foreach/Dyalect/loops-foreach-3.dyalect
Normal file
9
Task/Loops-Foreach/Dyalect/loops-foreach-3.dyalect
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
func myCollection() {
|
||||
yield 1
|
||||
yield 2
|
||||
yield 3
|
||||
}
|
||||
|
||||
for i in myCollection() {
|
||||
print(i)
|
||||
}
|
||||
3
Task/Loops-Foreach/E/loops-foreach.e
Normal file
3
Task/Loops-Foreach/E/loops-foreach.e
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
for e in theCollection {
|
||||
println(e)
|
||||
}
|
||||
4
Task/Loops-Foreach/ERRE/loops-foreach.erre
Normal file
4
Task/Loops-Foreach/ERRE/loops-foreach.erre
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
FOR INDEX$=("The","quick","brown","fox","jumps","over","the","lazy","dog.") DO
|
||||
PRINT(INDEX$;" ";)
|
||||
END FOR
|
||||
PRINT
|
||||
3
Task/Loops-Foreach/EasyLang/loops-foreach.easy
Normal file
3
Task/Loops-Foreach/EasyLang/loops-foreach.easy
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
for i in [ 5 1 19 25 12 1 14 7 ]
|
||||
print i
|
||||
.
|
||||
13
Task/Loops-Foreach/EchoLisp/loops-foreach.l
Normal file
13
Task/Loops-Foreach/EchoLisp/loops-foreach.l
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
(define my-list '( albert simon antoinette))
|
||||
(for ((h my-list)) (write h))
|
||||
albert simon antoinette
|
||||
|
||||
(define my-vector #(55 66 soixante-dix-sept))
|
||||
(for (( u my-vector)) (write u))
|
||||
55 66 soixante-dix-sept
|
||||
|
||||
(define my-string "Longtemps")
|
||||
(for ((une-lettre my-string)) (write une-lettre))
|
||||
"L" "o" "n" "g" "t" "e" "m" "p" "s"
|
||||
|
||||
;; etc ... for other collections like Streams, Hashes, Graphs, ...
|
||||
25
Task/Loops-Foreach/Ecstasy/loops-foreach.ecstasy
Normal file
25
Task/Loops-Foreach/Ecstasy/loops-foreach.ecstasy
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
module LoopForEach {
|
||||
@Inject Console console;
|
||||
void run() {
|
||||
val vals = [10, 20, 30, 40];
|
||||
console.print("Array of values:");
|
||||
Loop: for (val val : vals) {
|
||||
console.print($" value #{Loop.count + 1}: {val}");
|
||||
}
|
||||
|
||||
Map<String, Int> pairs = ["x"=42, "y"=69];
|
||||
console.print("\nKeys and values:");
|
||||
for ((String key, Int val) : pairs) {
|
||||
console.print($" {key}={val}");
|
||||
}
|
||||
console.print("\nJust the keys:");
|
||||
Loop: for (String key : pairs) {
|
||||
console.print($" key #{Loop.count + 1}: {key}");
|
||||
}
|
||||
|
||||
console.print("\nValues from a range:");
|
||||
for (Int n : 1..5) {
|
||||
console.print($" {n}");
|
||||
}
|
||||
}
|
||||
}
|
||||
1
Task/Loops-Foreach/Efene/loops-foreach-1.efene
Normal file
1
Task/Loops-Foreach/Efene/loops-foreach-1.efene
Normal file
|
|
@ -0,0 +1 @@
|
|||
io.format("~p~n", [Collection])
|
||||
1
Task/Loops-Foreach/Efene/loops-foreach-2.efene
Normal file
1
Task/Loops-Foreach/Efene/loops-foreach-2.efene
Normal file
|
|
@ -0,0 +1 @@
|
|||
lists.foreach(fn (X) { io.format("~p~n", [X]) }, Collection)
|
||||
1
Task/Loops-Foreach/Eiffel/loops-foreach-1.e
Normal file
1
Task/Loops-Foreach/Eiffel/loops-foreach-1.e
Normal file
|
|
@ -0,0 +1 @@
|
|||
across my_list as ic loop print (ic.item) end
|
||||
1
Task/Loops-Foreach/Eiffel/loops-foreach-2.e
Normal file
1
Task/Loops-Foreach/Eiffel/loops-foreach-2.e
Normal file
|
|
@ -0,0 +1 @@
|
|||
across my_list as ic all ic.item.count > 3 end
|
||||
1
Task/Loops-Foreach/Eiffel/loops-foreach-3.e
Normal file
1
Task/Loops-Foreach/Eiffel/loops-foreach-3.e
Normal file
|
|
@ -0,0 +1 @@
|
|||
across my_list as ic some ic.item.count > 3 end
|
||||
6
Task/Loops-Foreach/Ela/loops-foreach.ela
Normal file
6
Task/Loops-Foreach/Ela/loops-foreach.ela
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
open monad io
|
||||
|
||||
each [] = do return ()
|
||||
each (x::xs) = do
|
||||
putStrLn $ show x
|
||||
each xs
|
||||
12
Task/Loops-Foreach/Elena/loops-foreach.elena
Normal file
12
Task/Loops-Foreach/Elena/loops-foreach.elena
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import system'routines;
|
||||
import extensions;
|
||||
|
||||
public program()
|
||||
{
|
||||
var things := new string[]{"Apple", "Banana", "Coconut"};
|
||||
|
||||
things.forEach:(thing)
|
||||
{
|
||||
console.printLine:thing
|
||||
}
|
||||
}
|
||||
9
Task/Loops-Foreach/Elixir/loops-foreach.elixir
Normal file
9
Task/Loops-Foreach/Elixir/loops-foreach.elixir
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
iex(1)> list = [1,3.14,"abc",[3],{0,5}]
|
||||
[1, 3.14, "abc", [3], {0, 5}]
|
||||
iex(2)> Enum.each(list, fn x -> IO.inspect x end)
|
||||
1
|
||||
3.14
|
||||
"abc"
|
||||
[3]
|
||||
{0, 5}
|
||||
:ok
|
||||
2
Task/Loops-Foreach/Emacs-Lisp/loops-foreach-1.l
Normal file
2
Task/Loops-Foreach/Emacs-Lisp/loops-foreach-1.l
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(dolist (x '(1 2 3 4))
|
||||
(message "x=%d" x))
|
||||
3
Task/Loops-Foreach/Emacs-Lisp/loops-foreach-2.l
Normal file
3
Task/Loops-Foreach/Emacs-Lisp/loops-foreach-2.l
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(mapc (lambda (x)
|
||||
(message "x=%d" x))
|
||||
'(1 2 3 4))
|
||||
1
Task/Loops-Foreach/Emacs-Lisp/loops-foreach-3.l
Normal file
1
Task/Loops-Foreach/Emacs-Lisp/loops-foreach-3.l
Normal file
|
|
@ -0,0 +1 @@
|
|||
(cl-loop for x in '(1 2 3 4) do (message "x=%d" x))
|
||||
1
Task/Loops-Foreach/Erlang/loops-foreach-1.erl
Normal file
1
Task/Loops-Foreach/Erlang/loops-foreach-1.erl
Normal file
|
|
@ -0,0 +1 @@
|
|||
io:format("~p~n",[Collection]).
|
||||
1
Task/Loops-Foreach/Erlang/loops-foreach-2.erl
Normal file
1
Task/Loops-Foreach/Erlang/loops-foreach-2.erl
Normal file
|
|
@ -0,0 +1 @@
|
|||
lists:foreach(fun(X) -> io:format("~p~n",[X]) end, Collection).
|
||||
24
Task/Loops-Foreach/Euphoria/loops-foreach.euphoria
Normal file
24
Task/Loops-Foreach/Euphoria/loops-foreach.euphoria
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
include std/console.e
|
||||
|
||||
sequence s = {-2,-1,0,1,2} --print elements of a numerical list
|
||||
for i = 1 to length(s) do
|
||||
? s[i]
|
||||
end for
|
||||
|
||||
puts(1,'\n')
|
||||
|
||||
s = {"Name","Date","Field1","Field2"} -- print elements of a list of 'strings'
|
||||
for i = 1 to length(s) do
|
||||
printf(1,"%s\n",{s[i]})
|
||||
end for
|
||||
|
||||
puts(1,'\n')
|
||||
|
||||
for i = 1 to length(s) do -- print subelements of elements of a list of 'strings'
|
||||
for j = 1 to length(s[i]) do
|
||||
printf(1,"%s\n",s[i][j])
|
||||
end for
|
||||
puts(1,'\n')
|
||||
end for
|
||||
|
||||
if getc(0) then end if
|
||||
3
Task/Loops-Foreach/F-Sharp/loops-foreach.fs
Normal file
3
Task/Loops-Foreach/F-Sharp/loops-foreach.fs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
for i in [1 .. 10] do printfn "%d" i
|
||||
|
||||
List.iter (fun i -> printfn "%d" i) [1 .. 10]
|
||||
1
Task/Loops-Foreach/Factor/loops-foreach.factor
Normal file
1
Task/Loops-Foreach/Factor/loops-foreach.factor
Normal file
|
|
@ -0,0 +1 @@
|
|||
{ 1 2 4 } [ . ] each
|
||||
11
Task/Loops-Foreach/Fantom/loops-foreach.fantom
Normal file
11
Task/Loops-Foreach/Fantom/loops-foreach.fantom
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
class Main
|
||||
{
|
||||
public static Void main ()
|
||||
{
|
||||
Int[] collection := [1, 2, 3, 4, 5]
|
||||
collection.each |Int item|
|
||||
{
|
||||
echo (item)
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Task/Loops-Foreach/Fennel/loops-foreach-1.fennel
Normal file
2
Task/Loops-Foreach/Fennel/loops-foreach-1.fennel
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(each [k v (ipairs [:apple :banana :orange])]
|
||||
(print k v))
|
||||
2
Task/Loops-Foreach/Fennel/loops-foreach-2.fennel
Normal file
2
Task/Loops-Foreach/Fennel/loops-foreach-2.fennel
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(each [k v (pairs {:apple :x :banana 4 :orange 3})]
|
||||
(print k v))
|
||||
3
Task/Loops-Foreach/Forth/loops-foreach-1.fth
Normal file
3
Task/Loops-Foreach/Forth/loops-foreach-1.fth
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
create a 3 , 2 , 1 ,
|
||||
: .array ( a len -- )
|
||||
cells bounds do i @ . cell +loop ; \ 3 2 1
|
||||
20
Task/Loops-Foreach/Forth/loops-foreach-2.fth
Normal file
20
Task/Loops-Foreach/Forth/loops-foreach-2.fth
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
: FOREACH ( array size XT --)
|
||||
>R \ save execution token on return stack
|
||||
CELLS BOUNDS \ convert addr,len -> last,first addresses
|
||||
BEGIN
|
||||
2DUP > \ test addresses
|
||||
WHILE ( last>first )
|
||||
DUP R@ EXECUTE \ apply the execution token to the address
|
||||
CELL+ \ move first to the next memory cell
|
||||
REPEAT
|
||||
R> DROP \ clean return stack
|
||||
2DROP \ and data stack
|
||||
;
|
||||
|
||||
\ Make an operator to fetch contents of an address and print
|
||||
: ? ( addr --) @ . ;
|
||||
|
||||
CREATE A[] 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 ,
|
||||
|
||||
\ Usage example:
|
||||
A[] 10 ' ? FOREACH
|
||||
16
Task/Loops-Foreach/Fortran/loops-foreach.f
Normal file
16
Task/Loops-Foreach/Fortran/loops-foreach.f
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
program main
|
||||
|
||||
implicit none
|
||||
|
||||
integer :: i
|
||||
character(len=5),dimension(5),parameter :: colors = ['Red ','Green','Blue ','Black','White']
|
||||
|
||||
!using a do loop:
|
||||
do i=1,size(colors)
|
||||
write(*,'(A)') colors(i)
|
||||
end do
|
||||
|
||||
!this will also print each element:
|
||||
write(*,'(A)') colors
|
||||
|
||||
end program main
|
||||
18
Task/Loops-Foreach/FreeBASIC/loops-foreach.basic
Normal file
18
Task/Loops-Foreach/FreeBASIC/loops-foreach.basic
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
' FB 1.05.0
|
||||
|
||||
' FreeBASIC doesn't have a foreach loop but it's easy to manufacture one using macros
|
||||
|
||||
#Macro ForEach(I, A)
|
||||
For _i as integer = LBound(A) To UBound(A)
|
||||
#Define I (A(_i))
|
||||
#EndMacro
|
||||
|
||||
#Define In ,
|
||||
|
||||
Dim a(-5 To 5) As Integer = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
|
||||
ForEach(i in a)
|
||||
Print i; " ";
|
||||
Next
|
||||
|
||||
Print
|
||||
Sleep
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
for path in $PATH
|
||||
echo You have $path in PATH.
|
||||
end
|
||||
3
Task/Loops-Foreach/Frink/loops-foreach.frink
Normal file
3
Task/Loops-Foreach/Frink/loops-foreach.frink
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
array = [1, 2, 3, 5, 7]
|
||||
for n = array
|
||||
println[n]
|
||||
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