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,4 @@
// Create an empty list of String
List<String> my_list = new List<String>();
// Create a nested list
List<List<Set<Integer>>> my_list_2 = new List<List<Set<Integer>>>();

View file

@ -0,0 +1,6 @@
List<Integer> myList = new List<Integer>(); // Define a new list
myList.add(47); // Adds a second element of value 47 to the end
// of the list
Integer i = myList.get(0); // Retrieves the element at index 0
myList.set(0, 1); // Adds the integer 1 to the list at index 0
myList.clear(); // Removes all elements from the list

View file

@ -0,0 +1,3 @@
String[] colors = new List<String>();
List<String> colors = new String[1];
colors[0] = 'Green';

View file

@ -0,0 +1,3 @@
Set<String> s1 = new Set<String>{'a', 'b + c'}; // Defines a new set with two elements
Set<String> s2 = new Set<String>(s1); // Defines a new set that contains the
// elements of the set created in the previous step

View file

@ -0,0 +1,4 @@
Set<Integer> s = new Set<Integer>(); // Define a new set
s.add(1); // Add an element to the set
System.assert(s.contains(1)); // Assert that the set contains an element
s.remove(1); // Remove the element from the set

View file

@ -0,0 +1,3 @@
Map<String, String> country_currencies = new Map<String, String>();
Map<ID, Set<String>> m = new Map<ID, Set<String>>();
Map<String, String> MyStrings = new Map<String, String>{'a' => 'b', 'c' => 'd'.toUpperCase()};

View file

@ -0,0 +1,7 @@
Map<Integer, String> m = new Map<Integer, String>(); // Define a new map
m.put(1, 'First entry'); // Insert a new key-value pair in the map
m.put(2, 'Second entry'); // Insert a new key-value pair in the map
System.assert(m.containsKey(1)); // Assert that the map contains a key
String value = m.get(2); // Retrieve a value, given a particular key
System.assertEquals('Second entry', value);
Set<Integer> s = m.keySet(); // Return a set that contains all of the keys in the map

View file

@ -0,0 +1,8 @@
1→{L₁}
2→{L₁+1}
3→{L₁+2}
4→{L₁+3}
Disp {L₁}►Dec,i
Disp {L₁+1}►Dec,i
Disp {L₁+2}►Dec,i
Disp {L₁+3}►Dec,i

View file

@ -0,0 +1,9 @@
(define my-collection ' ( 🌱 ☀️ ☔️ ))
(set! my-collection (cons '🎥 my-collection))
(set! my-collection (cons '🐧 my-collection))
my-collection
→ (🐧 🎥 🌱 ☀️ ☔️)
;; save it
(local-put 'my-collection)
→ my-collection

View file

@ -0,0 +1,17 @@
' FB 1.05.0 Win64
'create fixed size array of integers
Dim a(1 To 5) As Integer = {1, 2, 3, 4, 5}
Print a(2), a(4)
'create empty dynamic array of doubles
Dim b() As Double
' add two elements by first redimensioning the array to hold this number of elements
Redim b(0 To 1)
b(0) = 3.5 : b(1) = 7.1
Print b(0), b(1)
'create 2 dimensional fixed size array of bytes
Dim c(1 To 2, 1 To 2) As Byte = {{1, 2}, {3, 4}}
Print c(1, 1), c(2,2)
Sleep

View file

@ -0,0 +1,13 @@
-- list stuff
l = [1, 2]
l.add(3)
l.add(4)
put l
-- [1, 2, 3, 4]
-- property list stuff
pl = [#foo: 1, #bar: 2]
pl[#foobar] = 3
pl["barfoo"] = 4
put pl
-- [#foo: 1, #bar: 2, #foobar: 3, "barfoo": 4]

View file

@ -0,0 +1,6 @@
var a = [1,2,3,4,5,6,7,8,9]
var b: array[128, int]
b[9] = 10
b[0..8] = a
var c: array['a'..'d', float] = [1.0, 1.1, 1.2, 1.3]
c['b'] = 10000

View file

@ -0,0 +1,11 @@
var d = @[1,2,3,5,6,7,8,9]
d.add(10)
d.add([11,12,13,14])
d[0] = 0
var e: seq[float] = @[]
e.add(15.5)
var f = newSeq[string]()
f.add("foo")
f.add("bar")

View file

@ -0,0 +1,7 @@
var g = (13, 13, 14)
g[0] = 12
var h: tuple[key: string, val: int] = ("foo", 100)
# A sequence of key-val tuples:
var i = {"foo": 12, "bar": 13}

View file

@ -0,0 +1,6 @@
var j: set[char]
j.incl('X')
var k = {'a'..'z', '0'..'9'}
j = j + k

View file

@ -0,0 +1,7 @@
import tables
var l = initTable[string, int]()
l["foo"] = 12
l["bar"] = 13
var m = {"foo": 12, "bar": 13}.toTable
m["baz"] = 14

View file

@ -0,0 +1,6 @@
import sets
var n = initSet[string]()
n.incl("foo")
var o = ["foo", "bar", "baz"].toSet
o.incl("foobar")

View file

@ -0,0 +1,4 @@
import queues
var p = initQueue[int]()
p.add(12)
p.add(13)

View file

@ -0,0 +1 @@
[ 1, 1.2, "abcd", [ 1, 2, 3 ] ]

View file

@ -0,0 +1 @@
ListBuffer new dup add(10) dup add("aaa") dup add(Date now) dup add(1.3) println

View file

@ -0,0 +1,4 @@
sequence collection = {}
collection = append(collection,"one")
collection = prepend(collection,2)
? collection -- {2,"one"}

View file

@ -0,0 +1,7 @@
setd("one",0)
setd(2,0)
function visitor(object key, object /*data*/, object /*user_data*/)
?key
return 1
end function
traverse_dict(routine_id("visitor")) -- shows 2, "one"

View file

@ -0,0 +1,5 @@
# creating an empty array and adding values
var a = [] #=> []
a[0] = 1 #=> [1]
a[3] = "abc" #=> [1, nil, nil, "abc"]
a << 3.14 #=> [1, nil, nil, "abc", 3.14]

View file

@ -0,0 +1,5 @@
# creating an empty hash
var h = Hash() #=> Hash()
h{:foo} = 1 #=> Hash("foo"=>1)
h{:bar} = 2.4 #=> Hash("foo"=>1, "bar"=>2.4)
h{:bar} += 3 #=> Hash("foo"=>1, "bar"=>5.4)

View file

@ -0,0 +1,14 @@
# create a simple pair
var p = Pair('a', 'b')
say p.first; #=> 'a'
say p.second; #=> 'b'
# create a pair of pairs
var pair = 'foo':'bar':'baz':(); # => Pair('foo', Pair('bar', Pair('baz', nil)))
# iterate over the values of a pair of pairs
loop {
say pair.first; #=> 'foo', 'bar', 'baz'
pair = pair.second;
pair == nil && break;
}

View file

@ -0,0 +1,15 @@
# creating a struct
struct Person {
String name,
Number age,
String sex
}
var a = Person("John Smith", 41, :man)
a.age += 1 # increment age
a.name = "Dr. #{a.name}" # update name
say a.name #=> "Dr. John Smith"
say a.age #=> 42
say a.sex #=> "man"

View file

@ -0,0 +1,22 @@
LOCAL loColl As Collection, o, a1, a2, a3
a1 = CREATEOBJECT("animal", "dog", 4)
a2 = CREATEOBJECT("animal", "chicken", 2)
a3 = CREATEOBJECT("animal", "snake", 0)
loColl = NEWOBJECT("Collection")
loColl.Add(a1)
loColl.Add(a2)
loColl.Add(a3)
FOR EACH o IN loColl FOXOBJECT
? o.Name, o.Legs
ENDFOR
DEFINE CLASS animal As Custom
Legs = 0
PROCEDURE Init(tcName, tnLegs)
THIS.Name = tcName
THIS.Legs = tnLegs
ENDPROC
ENDDEFINE

View file

@ -0,0 +1,16 @@
var list = [] // Empty Array
list = [1,2,3,4]
list.add(5)
list.clear()
list = [0] * 10
list.count // 10
var map = {}
map["key"] = "value"
map[3] = 31
map.count // 2
map.clear()
for (e in map.keys) {
// Do stuff
}

View file

@ -0,0 +1 @@
{"a": 1} == {a: 1}

View file

@ -0,0 +1 @@
"a" as $key | 1 as $value | {($key): $value}

View file

@ -0,0 +1 @@
[0,1,2] | .[0] = 10