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
|
|
@ -0,0 +1,12 @@
|
|||
'a'→{L₁}
|
||||
'b'→{L₁+1}
|
||||
'c'→{L₁+2}
|
||||
'A'→{L₂}
|
||||
'B'→{L₂+1}
|
||||
'C'→{L₂+2}
|
||||
1→{L₃}
|
||||
2→{L₃+1}
|
||||
3→{L₃+2}
|
||||
For(I,0,2)
|
||||
Disp {L₁+I}►Char,{L₂+I}►Char,{L₃+I}►Dec,i
|
||||
End
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
;; looping over different sequences : infinite stream, string, list and vector
|
||||
;; loop stops as soon a one sequence ends.
|
||||
;; the (iota 6) = ( 0 1 2 3 4 5) sequence will stop first.
|
||||
|
||||
|
||||
(for ((i (in-naturals 1000)) (j "ABCDEFGHIJK") (k (iota 6)) (m #(o p q r s t u v w)))
|
||||
(writeln i j k m))
|
||||
|
||||
1000 "A" 0 o
|
||||
1001 "B" 1 p
|
||||
1002 "C" 2 q
|
||||
1003 "D" 3 r
|
||||
1004 "E" 4 s
|
||||
1005 "F" 5 t
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
' FB 1.05.0 Win64
|
||||
|
||||
Function min(x As Integer, y As Integer) As Integer
|
||||
Return IIf(x < y, x, y)
|
||||
End Function
|
||||
|
||||
Dim arr1(1 To 3) As String = {"a", "b", "c"}
|
||||
Dim arr2(1 To 3) As String = {"A", "B", "C"}
|
||||
Dim arr3(1 To 3) As Integer = {1, 2, 3}
|
||||
|
||||
For i As Integer = 1 To 3
|
||||
Print arr1(i) & arr2(i) & arr3(i)
|
||||
Next
|
||||
|
||||
Print
|
||||
|
||||
' For arrays of different lengths we would need to iterate up to the mimimm length of all 3 in order
|
||||
' to get a contribution from each one. For example:
|
||||
|
||||
Dim arr4(1 To 4) As String = {"A", "B", "C", "D"}
|
||||
Dim arr5(1 To 2) As Integer = {1, 2}
|
||||
|
||||
Dim ub As Integer = min(UBound(arr1), min(UBound(arr4), UBound(arr5)))
|
||||
For i As Integer = 1 To ub
|
||||
Print arr1(i) & arr2(i) & arr3(i)
|
||||
Next
|
||||
|
||||
Print
|
||||
Sleep
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
import lists.zip3
|
||||
|
||||
for x <- zip3( ['a', 'b', 'c'], ['A', 'B', 'C'], [1, 2, 3] )
|
||||
println( x.mkString() )
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
(lists:zipwith3
|
||||
(lambda (i j k)
|
||||
(io:format "~s~s~p~n" `(,i ,j ,k)))
|
||||
'(a b c)
|
||||
'(A B C)
|
||||
'(1 2 3))
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
command loopArrays
|
||||
local lowA, uppA, nums, z
|
||||
put "a,b,c" into lowA
|
||||
put "A,B,C" into uppA
|
||||
put "1,2,3" into nums
|
||||
|
||||
split lowA by comma
|
||||
split uppA by comma
|
||||
split nums by comma
|
||||
|
||||
repeat with n = 1 to the number of elements of lowA
|
||||
put lowA[n] & uppA[n] & nums[n] & return after z
|
||||
end repeat
|
||||
put z
|
||||
|
||||
end loopArrays
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
command loopDelimitedList
|
||||
local lowA, uppA, nums, z
|
||||
put "a,b,c" into lowA
|
||||
put "A,B,C" into uppA
|
||||
put "1,2,3" into nums
|
||||
|
||||
repeat with n = 1 to the number of items of lowA
|
||||
put item n of lowA & item n of uppA & item n of nums
|
||||
& return after z
|
||||
end repeat
|
||||
put z
|
||||
|
||||
end loopDelimitedList
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
let
|
||||
a = @['a','b','c']
|
||||
b = @["A","B","C"]
|
||||
c = @[1,2,3]
|
||||
|
||||
for i in 0..2:
|
||||
echo a[i], b[i], c[i]
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
[ "a", "b", "c" ] [ "A", "B", "C" ] [ 1, 2, 3 ]
|
||||
zipAll(3) apply(#[ apply(#print) printcr ])
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
procedure print3(sequence a, b, c)
|
||||
for i=1 to min({length(a),length(b),length(c)}) do
|
||||
printf(1, "%s%s%g\n", {a[i], b[i], c[i]})
|
||||
end for
|
||||
end procedure
|
||||
|
||||
print3("abc","ABC",{1, 2, 3})
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
array1 = ["a", "b", "c"]
|
||||
array2 = ["A", "B", "C"]
|
||||
array3 = [1, 2, 3]
|
||||
|
||||
for n = 1 to 3
|
||||
see array1[n] + array2[n] + array3[n] + nl
|
||||
next
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
MultiArray.new(%w(a b c),%w(A B C),%w(1 2 3)).each { |i,j,k|
|
||||
say (i, j, k);
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
let a1 = ["a", "b", "c"]
|
||||
let a2 = ["A", "B", "C"]
|
||||
let a3 = [1, 2, 3]
|
||||
|
||||
for i in 0 ..< a1.count {
|
||||
println("\(a1[i])\(a2[i])\(a3[i])")
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
> decl string<> a b c
|
||||
> append (split "abc" "") a
|
||||
> append (split "ABC" "") b
|
||||
> append (split "123" "") c
|
||||
> for (decl int i) (< i (size a)) (inc i)
|
||||
.. out a<i> b<i> c<i> endl console
|
||||
..end
|
||||
aA1
|
||||
bB2
|
||||
cC3
|
||||
> _
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
LOCAL i As Integer, n As Integer, c As String
|
||||
LOCAL ARRAY a1[3], a2[3], a3[4], a[3]
|
||||
*!* Populate the arrays and store the array lengths in a
|
||||
a1[1] = "a"
|
||||
a1[2] = "b"
|
||||
a1[3] = "c"
|
||||
a[1] = ALEN(a1)
|
||||
a2[1] = "A"
|
||||
a2[2] = "B"
|
||||
a2[3] = "C"
|
||||
a[2] = ALEN(a2)
|
||||
a3[1] = "1"
|
||||
a3[2] = "2"
|
||||
a3[3] = "3"
|
||||
a3[4] = "4"
|
||||
a[3] = ALEN(a3)
|
||||
*!* Find the maximum length of the arrays
|
||||
*!* In this case, 4
|
||||
n = MAX(a[1], a[2], a[3])
|
||||
? "Simple Loop"
|
||||
FOR i = 1 TO n
|
||||
c = ""
|
||||
c = c + IIF(i <= a[1], a1[i], "#")
|
||||
c = c + IIF(i <= a[2], a2[i], "#")
|
||||
c = c + IIF(i <= a[3], a3[i], "#")
|
||||
? c
|
||||
ENDFOR
|
||||
*!* Solution using a cursor
|
||||
CREATE CURSOR tmp (c1 C(1), c2 C(1), c3 C(1), c4 C(3))
|
||||
INSERT INTO tmp (c1, c2, c3) VALUES ("a", "A", "1")
|
||||
INSERT INTO tmp (c1, c2, c3) VALUES ("b", "B", "2")
|
||||
INSERT INTO tmp (c1, c2, c3) VALUES ("c", "C", "3")
|
||||
INSERT INTO tmp (c1, c2, c3) VALUES ("#", "#", "4")
|
||||
REPLACE c4 WITH c1 + c2 + c3 ALL
|
||||
? "Solution using a cursor"
|
||||
LIST OFF FIELDS c4
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
each (x X n) (zip '(a b c) '(A B C) '(1 2 3))
|
||||
prn x X n
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
# zip/0 emits [] if input is [].
|
||||
|
||||
def zip:
|
||||
. as $in
|
||||
| [range(0; $in[0]|length) as $i | $in | map( .[$i] ) ];
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
# transpose a possibly jagged matrix
|
||||
def transpose:
|
||||
if . == [] then []
|
||||
else (.[1:] | transpose) as $t
|
||||
| .[0] as $row
|
||||
| reduce range(0; [($t|length), (.[0]|length)] | max) as $i
|
||||
([]; . + [ [ $row[$i] ] + $t[$i] ])
|
||||
end;
|
||||
Loading…
Add table
Add a link
Reference in a new issue