Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,3 @@
a:<1; <2; 3>>
b: <"Hello"; 42>
c: a,b

View file

@ -0,0 +1,4 @@
List<String> listA = new List<String> { 'apple' };
List<String> listB = new List<String> { 'banana' };
listA.addAll(listB);
System.debug(listA); // Prints (apple, banana)

View file

@ -0,0 +1,6 @@
shared void arrayConcatenation() {
value a = Array {1, 2, 3};
value b = Array {4, 5, 6};
value c = concatenate(a, b);
print(c);
}

View file

@ -0,0 +1,4 @@
A := [1, 2, 3, 4];
B := [5, 6, 7, 8];
C := A + B;

View file

@ -0,0 +1,31 @@
PROGRAM ARRAY_CONCAT
DIM A[5],B[5],C[10]
!
! for rosettacode.org
!
BEGIN
DATA(1,2,3,4,5)
DATA(6,7,8,9,0)
FOR I=1 TO 5 DO ! read array A[.]
READ(A[I])
END FOR
FOR I=1 TO 5 DO ! read array B[.]
READ(B[I])
END FOR
FOR I=1 TO 10 DO ! append B[.] to A[.]
IF I>5 THEN
C[I]=B[I-5]
ELSE
C[I]=A[I]
END IF
PRINT(C[I];) ! print single C value
END FOR
PRINT
END PROGRAM

View file

@ -0,0 +1,12 @@
;;;; VECTORS
(vector-append (make-vector 6 42) (make-vector 4 666))
→ #( 42 42 42 42 42 42 666 666 666 666)
;;;; LISTS
(append (iota 5) (iota 6))
→ (0 1 2 3 4 0 1 2 3 4 5)
;; NB - append may also be used with sequences (lazy lists)
(lib 'sequences)
(take (append [1 .. 7] [7 6 .. 0]) #:all)
→ (1 2 3 4 5 6 7 6 5 4 3 2 1)

View file

@ -0,0 +1,19 @@
import Element exposing (show, toHtml) -- elm-package install evancz/elm-graphics
import Html.App exposing (beginnerProgram)
import Array exposing (Array, append, initialize)
xs : Array Int
xs =
initialize 3 identity -- [0, 1, 2]
ys : Array Int
ys =
initialize 3 <| (+) 3 -- [3, 4, 5]
main = beginnerProgram { model = ()
, view = \_ -> toHtml (show (append xs ys))
, update = \_ _ -> ()
}
-- Array.fromList [0,1,2,3,4,5]

View file

@ -0,0 +1,26 @@
' FB 1.05.0 Win64
Sub ConcatArrays(a() As String, b() As String, c() As String)
Dim aSize As Integer = UBound(a) - LBound(a) + 1
Dim bSize As Integer = UBound(b) - LBound(b) + 1
Dim cSize As Integer = aSize + bSize
Redim c(0 To cSize - 1)
Dim i As Integer
For i = 0 To aSize - 1
c(i) = a(LBound(a) + i)
Next
For i = 0 To bSize - 1
c(UBound(a) + i + 1) = b(LBound(b) + i)
Next
End Sub
Dim a(3) As String = {"The", "quick", "brown", "fox"}
Dim b(4) As String = {"jumped", "over", "the", "lazy", "dog"}
Dim c() As String
ConcatArrays(a(), b(), c())
For i As Integer = LBound(c) To UBound(c)
Print c(i); " ";
Next
Print : Print
Print "Press any key to quit the program"
Sleep

View file

@ -0,0 +1,5 @@
arr1 = array( [1, 2, 3] )
arr2 = array( [4, 5, 6] )
arr3 = array( [7, 8, 9] )
println( arr1 + arr2 + arr3 )

View file

@ -0,0 +1 @@
concat as bs cd

View file

@ -0,0 +1,6 @@
software {
var a = [1, 2, 3]
var b = [4, 5, 6]
print(a + b)
}

View file

@ -0,0 +1,4 @@
> (++ '(1 2 3) '(4 5 6))
(1 2 3 4 5 6)
> (: lists append '(1 2 3) '(4 5 6))
(1 2 3 4 5 6)

View file

@ -0,0 +1,12 @@
local(arr1 = array(1, 2, 3))
local(arr2 = array(4, 5, 6))
local(arr3 = #arr1->asCopy) // make arr3 a copy of arr2
#arr3->merge(#arr2) // concatenate 2 arrays
Result:
arr1 = array(1, 2, 3)
arr2 = array(4, 5, 6)
arr3 = array(4, 5, 6)
arr3 = array(1, 2, 3, 4, 5, 6)

View file

@ -0,0 +1,9 @@
a = [1,2]
b = [3,4,5]
repeat with v in b
a.append(v)
end repeat
put a
-- [1, 2, 3, 4, 5]

View file

@ -0,0 +1,4 @@
var
x = @[1,2,3,4,5,6]
y = @[7,8,9,10,11]
z = x & y

View file

@ -0,0 +1,7 @@
var
a = [1,2,3,4,5,6]
b = [7,8,9,10,11]
c: array[11, int]
c[0..5] = a
c[6..10] = b

View file

@ -0,0 +1 @@
[1, 2, 3 ] [ 4, 5, 6, 7 ] +

View file

@ -0,0 +1,2 @@
sequence s1 = {1,2,3}, s2 = {4,5,6}
? s1 & s2

View file

@ -0,0 +1,8 @@
arr1 = [1, 2, 3]
arr2 = [4, 5, 6]
arr3 = [7, 8, 9]
arr4 = arr1 + arr2
see arr4
see nl
arr5 = arr4 + arr3
see arr5

View file

@ -0,0 +1,3 @@
var arr1 = [1, 2, 3];
var arr2 = [4, 5, 6];
var arr3 = (arr1 + arr2); # => [1, 2, 3, 4, 5, 6]

View file

@ -0,0 +1,3 @@
let array1 = [1,2,3]
let array2 = [4,5,6]
let array3 = array1 + array2

View file

@ -0,0 +1,16 @@
# create two streams (the ursa equivalent of arrays)
# a contains the numbers 1-10, b contains 11-20
decl int<> a b
decl int i
for (set i 1) (< i 11) (inc i)
append i a
end for
for (set i 11) (< i 21) (inc i)
append i b
end for
# append the values in b to a
append b a
# output a to the console
out a endl console

View file

@ -0,0 +1,4 @@
a <- '(1 2 3)
b <- '(4 5 6)
a+b
# => (1 2 3 4 5 6)

View file

@ -0,0 +1,6 @@
var arr1 = [1,2,3]
var arr2 = [4,5,6]
for (e in arr2) {
arr1.add(e)
}
System.print(arr1)

View file

@ -0,0 +1,3 @@
[1,2] + [3] + [null] # => [1,2,3,null]
[range(1;3), 3, null] # => [1,2,3,null]