September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
15
Task/Hash-from-two-arrays/Gambas/hash-from-two-arrays.gambas
Normal file
15
Task/Hash-from-two-arrays/Gambas/hash-from-two-arrays.gambas
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
Public Sub Main()
|
||||
Dim sValue As String[] = ["Zero", "One", "Two", "Three", "Four", "Five"]
|
||||
Dim sKey As String[] = [0, 1, 2, 3, 4, 5]
|
||||
Dim sCol As New Collection
|
||||
Dim siCount As Short
|
||||
|
||||
For siCount = 0 To sKey.max
|
||||
sCol.Add(sValue[siCount], sKey[siCount])
|
||||
Next
|
||||
|
||||
For siCount = 0 To sKey.max
|
||||
Print Str(sicount) & " = " & sCol[siCount]
|
||||
Next
|
||||
|
||||
End
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
// version 1.1.0
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val names = arrayOf("Jimmy", "Bill", "Barack", "Donald")
|
||||
val ages = arrayOf(92, 70, 55, 70)
|
||||
val hash = mapOf(*names.zip(ages).toTypedArray())
|
||||
hash.forEach { println("${it.key.padEnd(6)} aged ${it.value}") }
|
||||
}
|
||||
13
Task/Hash-from-two-arrays/OoRexx/hash-from-two-arrays.rexx
Normal file
13
Task/Hash-from-two-arrays/OoRexx/hash-from-two-arrays.rexx
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
array1 = .array~of("Rick", "Mike", "David")
|
||||
array2 = .array~of("555-9862", "555-5309", "555-6666")
|
||||
|
||||
-- if the index items are constrained to string objects, this can
|
||||
-- be a directory too.
|
||||
hash = .table~new
|
||||
|
||||
loop i = 1 to array1~size
|
||||
hash[array1[i]] = array2[i]
|
||||
end
|
||||
Say 'Enter a name'
|
||||
Parse Pull name
|
||||
Say name '->' hash[name]
|
||||
|
|
@ -1 +0,0 @@
|
|||
{ @keys »=>« @values }
|
||||
16
Task/Hash-from-two-arrays/Phix/hash-from-two-arrays.phix
Normal file
16
Task/Hash-from-two-arrays/Phix/hash-from-two-arrays.phix
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
function make_hash(sequence keyarray, sequence valuearray)
|
||||
integer dict = new_dict()
|
||||
for i=1 to length(keyarray) do
|
||||
setd(keyarray[i],valuearray[i],dict)
|
||||
-- setd(keyarray[i],i,dict)
|
||||
end for
|
||||
return dict
|
||||
end function
|
||||
|
||||
constant keyarray = {1,"two",PI}
|
||||
constant valuearray = {"one",2,PI}
|
||||
integer dict = make_hash(keyarray,valuearray)
|
||||
?getd(1,dict)
|
||||
?getd("two",dict)
|
||||
?getd(PI,dict)
|
||||
--?valuearray[getd(1,dict)]
|
||||
4
Task/Hash-from-two-arrays/Zkl/hash-from-two-arrays.zkl
Normal file
4
Task/Hash-from-two-arrays/Zkl/hash-from-two-arrays.zkl
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
keys:=T("a","b","c","d"); vals:=T(1,2,3,4);
|
||||
d:=keys.zip(vals).toDictionary();
|
||||
d.println();
|
||||
d["b"].println();
|
||||
Loading…
Add table
Add a link
Reference in a new issue