Time for an 2014 update…

This commit is contained in:
Ingy döt Net 2014-01-17 05:32:22 +00:00
parent 372c577f83
commit 09687c4926
2520 changed files with 34227 additions and 7318 deletions

View file

@ -0,0 +1,5 @@
local :h_keys [ :one :two :three ]
local :h_values [ 1 2 3 ]
local :h {}
for item in h_keys:
set-to h item pop-from h_values

View file

@ -0,0 +1,6 @@
def keys = ['a','b','c']
def vals = ['aaa', 'bbb', 'ccc']
def hash = [:]
keys.eachWithIndex { key, i ->
hash[key] = vals[i]
}

View file

@ -0,0 +1 @@
List.metaClass.hash = { list -> [delegate, list].transpose().collectEntries { [(it[0]): it[1]] } }

View file

@ -0,0 +1 @@
assert (['a', 'b', 'c'].hash(['aaa', 'bbb', 'ccc'])) == [a: 'aaa', b: 'bbb', c: 'ccc']

View file

@ -1,6 +0,0 @@
keys = ['a','b','c']
vals = ['aaa', 'bbb', 'ccc']
hash = [:]
keys.eachWithIndex { key, i ->
hash[key] = vals[i]
}

View file

@ -0,0 +1,4 @@
julia> K = ["a", "b", "c"]
julia> V = [1, 2, 3]
julia> H = [key => value for (key, value) in zip(K,V)]
{"b"=>2,"c"=>3,"a"=>1}

View file

@ -0,0 +1,2 @@
julia> H = (String=>Int)[key => value for (key, value) in zip(K,V)]
["b"=>2,"c"=>3,"a"=>1]

View file

@ -0,0 +1,2 @@
julia> H = Dict(K, V)
["b"=>2,"c"=>3,"a"=>1]