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,5 @@
shared void run() {
value keys = [1, 2, 3];
value items = ['a', 'b', 'c'];
value hash = map(zipEntries(keys, items));
}

View file

@ -0,0 +1,5 @@
keys = <[apple banana orange grape]>
values = <[red yellow orange purple]>
object = new
@[keys[i]] = values[i] for i til keys.length

View file

@ -0,0 +1,10 @@
(lib 'hash)
(define H (make-hash))
(define keys '(elvis simon antoinette))
(define kvalues '("the king" "gallubert" "de gabolde d'Audan"))
(list->hash (map cons keys kvalues) H)
→ #hash:3
(hash-ref H 'elvis)
→ "the king"

View file

@ -0,0 +1,7 @@
LOCAL arr1 := { 6, "eight" }, arr2 := { 16, 8 }
LOCAL hash := { => }
LOCAL i, j
FOR EACH i, j IN arr1, arr2
hash[ i ] := j
NEXT

View file

@ -0,0 +1,6 @@
(let* ((keys (list 'foo 'bar 'baz))
(vals (list '"foo data" '"bar data" '"baz data"))
(tuples (: lists zipwith
(lambda (a b) (tuple a b)) keys vals))
(my-dict (: dict from_list tuples)))
(: io format '"fetched data: ~p~n" (list (: dict fetch 'baz my-dict))))

View file

@ -0,0 +1,11 @@
local(
array1 = array('a', 'b', 'c'),
array2 = array(1, 2, 3),
hash = map
)
loop(#array1 -> size) => {
#hash -> insert(#array1 -> get(loop_count) = #array2 -> get(loop_count))
}
#hash

View file

@ -0,0 +1,11 @@
keys = ["a","b","c"]
values = [1,2,3]
props = [:]
cnt = keys.count
repeat with i = 1 to cnt
props[keys[i]] = values[i]
end repeat
put props
-- ["a": 1, "b": 2, "c": 3]

View file

@ -0,0 +1,12 @@
put "a,b,c" into list1
put 10,20,30 into list2
split list1 using comma
split list2 using comma
repeat with i=1 to the number of elements of list1
put list2[i] into list3[list1[i]]
end repeat
combine list3 using comma and colon
put list3
-- ouput
-- a:10,b:20,c:30

View file

@ -0,0 +1,6 @@
import tables, sequtils
let keys = @['a','b','c']
let values = @[1, 2, 3]
let table = toTable zip(keys, values)

View file

@ -0,0 +1,6 @@
var keys = %w(a b c)
var vals = [1, 2, 3]
var hash = Hash()
hash{keys...} = vals...
say hash

View file

@ -0,0 +1,6 @@
let keys = { "foo", "bar", "baz" };
let vals = { 13, 37, 42 };
var hash = {};
for var i = 0; i < sizeof keys; i++ {
hash[keys[i]] = vals[i];
}

View file

@ -0,0 +1,6 @@
let keys = ["a","b","c"]
let vals = [1,2,3]
var hash = [String: Int]()
for (key, val) in zip(keys, vals) {
hash[key] = val
}

View file

@ -0,0 +1 @@
@hash ["a" "b" "c"] [1 2 3] ; returns {a 1 b 2 c 3}

View file

@ -0,0 +1 @@
^(@obj @zip)

View file

@ -0,0 +1,4 @@
@let {
hash ^(@obj @zip)
!!hash ["a" "b" "c"] [1 2 3]
}

View file

@ -0,0 +1,12 @@
# hash(keys) creates a JSON object with the given keys as keys
# and values taken from the input array in turn.
# "keys" must be an array of strings.
# The input array may be of any length and have values of any type,
# but only the first (keys|length) values will be used;
# the input will in effect be padded with nulls if required.
def hash(keys):
. as $values
| reduce range(0; keys|length) as $i
( {}; . + { (keys[$i]) : $values[$i] });
[1,2,3] | hash( ["a","b","c"] )

View file

@ -0,0 +1,6 @@
jq -n -f Hash_from_two_arrays.jq
{
"a": 1,
"b": 2,
"c": 3
}

View file

@ -0,0 +1,5 @@
{
"1": 10,
"2": 20,
"3": 30
}