Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
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);
|
||||
}
|
||||
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
|
||||
13
Task/Loops-Foreach/EchoLisp/loops-foreach.echolisp
Normal file
13
Task/Loops-Foreach/EchoLisp/loops-foreach.echolisp
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, ...
|
||||
18
Task/Loops-Foreach/FreeBASIC/loops-foreach.freebasic
Normal file
18
Task/Loops-Foreach/FreeBASIC/loops-foreach.freebasic
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
|
||||
4
Task/Loops-Foreach/LFE/loops-foreach.lfe
Normal file
4
Task/Loops-Foreach/LFE/loops-foreach.lfe
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(lists:foreach
|
||||
(lambda (x)
|
||||
(io:format "item: ~p~n" (list x)))
|
||||
(lists:seq 1 10))
|
||||
1
Task/Loops-Foreach/Lasso/loops-foreach-1.lasso
Normal file
1
Task/Loops-Foreach/Lasso/loops-foreach-1.lasso
Normal file
|
|
@ -0,0 +1 @@
|
|||
array(1,2,3) => foreach { stdoutnl(#1) }
|
||||
1
Task/Loops-Foreach/Lasso/loops-foreach-2.lasso
Normal file
1
Task/Loops-Foreach/Lasso/loops-foreach-2.lasso
Normal file
|
|
@ -0,0 +1 @@
|
|||
with i in array(1,2,3) do { stdoutnl(#i) }
|
||||
4
Task/Loops-Foreach/Lingo/loops-foreach-1.lingo
Normal file
4
Task/Loops-Foreach/Lingo/loops-foreach-1.lingo
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
days = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]
|
||||
repeat with day in days
|
||||
put day
|
||||
end repeat
|
||||
13
Task/Loops-Foreach/Lingo/loops-foreach-2.lingo
Normal file
13
Task/Loops-Foreach/Lingo/loops-foreach-2.lingo
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
----------------------------------------
|
||||
-- One of the five native iterative methods defined in ECMAScript 5
|
||||
-- @param {list} tList
|
||||
-- @param {symbol} cbFunc
|
||||
-- @param {object} [cbObj=_movie]
|
||||
----------------------------------------
|
||||
on forEach (tList, cbFunc, cbObj)
|
||||
if voidP(cbObj) then cbObj = _movie
|
||||
cnt = tList.count
|
||||
repeat with i = 1 to cnt
|
||||
call(cbFunc, cbObj, tList[i], i, tList)
|
||||
end repeat
|
||||
end
|
||||
2
Task/Loops-Foreach/Lingo/loops-foreach-3.lingo
Normal file
2
Task/Loops-Foreach/Lingo/loops-foreach-3.lingo
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
days = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]
|
||||
forEach(days, #alert, _player)
|
||||
4
Task/Loops-Foreach/LiveCode/loops-foreach.livecode
Normal file
4
Task/Loops-Foreach/LiveCode/loops-foreach.livecode
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
repeat for each item x in "red, green, blue"
|
||||
put x & cr
|
||||
--wait 100 millisec -- req'd if you want to see in the LC Message Box (akin to repl)
|
||||
end repeat
|
||||
6
Task/Loops-Foreach/Nim/loops-foreach.nim
Normal file
6
Task/Loops-Foreach/Nim/loops-foreach.nim
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)
|
||||
1
Task/Loops-Foreach/Oforth/loops-foreach-1.oforth
Normal file
1
Task/Loops-Foreach/Oforth/loops-foreach-1.oforth
Normal file
|
|
@ -0,0 +1 @@
|
|||
: printMonths | m | Date.Months forEach: m [ m . ] ;
|
||||
1
Task/Loops-Foreach/Oforth/loops-foreach-2.oforth
Normal file
1
Task/Loops-Foreach/Oforth/loops-foreach-2.oforth
Normal file
|
|
@ -0,0 +1 @@
|
|||
#. Date.Months apply
|
||||
5
Task/Loops-Foreach/PHL/loops-foreach.phl
Normal file
5
Task/Loops-Foreach/PHL/loops-foreach.phl
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
var numbers = 1..10;
|
||||
|
||||
numbers each # (number) [
|
||||
printf("%i\n", number);
|
||||
];
|
||||
4
Task/Loops-Foreach/Phix/loops-foreach.phix
Normal file
4
Task/Loops-Foreach/Phix/loops-foreach.phix
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
sequence s = {-2,"field",3.14159268979,{"this","that"}}
|
||||
for i=1 to length(s) do
|
||||
?s[i]
|
||||
end for
|
||||
4
Task/Loops-Foreach/Ring/loops-foreach.ring
Normal file
4
Task/Loops-Foreach/Ring/loops-foreach.ring
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
aList = "Welcome to the Ring Programming Language"
|
||||
for n in aList
|
||||
see n + nl
|
||||
next
|
||||
3
Task/Loops-Foreach/Sidef/loops-foreach-1.sidef
Normal file
3
Task/Loops-Foreach/Sidef/loops-foreach-1.sidef
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
foreach [1,2,3] { |i|
|
||||
say i
|
||||
}
|
||||
3
Task/Loops-Foreach/Sidef/loops-foreach-2.sidef
Normal file
3
Task/Loops-Foreach/Sidef/loops-foreach-2.sidef
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
for i in [1,2,3] {
|
||||
say i
|
||||
}
|
||||
3
Task/Loops-Foreach/Sidef/loops-foreach-3.sidef
Normal file
3
Task/Loops-Foreach/Sidef/loops-foreach-3.sidef
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[1,2,3].each { |i|
|
||||
say i
|
||||
}
|
||||
4
Task/Loops-Foreach/Sparkling/loops-foreach.sparkling
Normal file
4
Task/Loops-Foreach/Sparkling/loops-foreach.sparkling
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
let hash = { "foo": 42, "bar": 1337, "baz": "qux" };
|
||||
foreach(hash, function(key, val) {
|
||||
print(key, " -> ", val);
|
||||
});
|
||||
3
Task/Loops-Foreach/Swift/loops-foreach-1.swift
Normal file
3
Task/Loops-Foreach/Swift/loops-foreach-1.swift
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
for i in [1,2,3] {
|
||||
print(i)
|
||||
}
|
||||
3
Task/Loops-Foreach/Swift/loops-foreach-2.swift
Normal file
3
Task/Loops-Foreach/Swift/loops-foreach-2.swift
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[1,2,3].forEach {
|
||||
print($0)
|
||||
}
|
||||
2
Task/Loops-Foreach/Wart/loops-foreach.wart
Normal file
2
Task/Loops-Foreach/Wart/loops-foreach.wart
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
each x '(1 2 3)
|
||||
prn x
|
||||
1
Task/Loops-Foreach/XLISP/loops-foreach.xlisp
Normal file
1
Task/Loops-Foreach/XLISP/loops-foreach.xlisp
Normal file
|
|
@ -0,0 +1 @@
|
|||
(FOR-EACH PRINT '(CYRUS CAMBYSES DARIUS XERXES ARTAXERXES))
|
||||
1
Task/Loops-Foreach/jq/loops-foreach-1.jq
Normal file
1
Task/Loops-Foreach/jq/loops-foreach-1.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
def example: [1,2];
|
||||
2
Task/Loops-Foreach/jq/loops-foreach-2.jq
Normal file
2
Task/Loops-Foreach/jq/loops-foreach-2.jq
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
example | .[]
|
||||
# or equivalently: example[]
|
||||
2
Task/Loops-Foreach/jq/loops-foreach-3.jq
Normal file
2
Task/Loops-Foreach/jq/loops-foreach-3.jq
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
{"a":1, "b":2} | .[]
|
||||
# or equivalently: {"a":1, "b":2}[]
|
||||
1
Task/Loops-Foreach/jq/loops-foreach-4.jq
Normal file
1
Task/Loops-Foreach/jq/loops-foreach-4.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
example | . as $a | range(0; length) | $a[.]
|
||||
1
Task/Loops-Foreach/jq/loops-foreach-5.jq
Normal file
1
Task/Loops-Foreach/jq/loops-foreach-5.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"a":1, "b":2} | . as $o | keys | map( [., $o[.]] )
|
||||
3
Task/Loops-Foreach/jq/loops-foreach-6.jq
Normal file
3
Task/Loops-Foreach/jq/loops-foreach-6.jq
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
"abc" | . as $s | range(0;length) | $s[.:.+1]
|
||||
|
||||
"abc" | explode | map( [.]|implode) | .[]
|
||||
Loading…
Add table
Add a link
Reference in a new issue