September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View 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

View file

@ -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}") }
}

View 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]

View file

@ -1 +0,0 @@
{ @keys »=>« @values }

View 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)]

View 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();