September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
5
Task/Collections/OoRexx/collections-1.rexx
Normal file
5
Task/Collections/OoRexx/collections-1.rexx
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
a = .array~new(4) -- creates an array of 4 items, with all slots empty
|
||||
say a~size a~items -- size is 4, but there are 0 items
|
||||
a[1] = "Fred" -- assigns a value to the first item
|
||||
a[5] = "Mike" -- assigns a value to the fifth slot, expanding the size
|
||||
say a~size a~items -- size is now 5, with 2 items
|
||||
9
Task/Collections/OoRexx/collections-2.rexx
Normal file
9
Task/Collections/OoRexx/collections-2.rexx
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
l = .list~new -- lists have no inherent size
|
||||
index = l~insert('123') -- adds an item to this list, returning the index
|
||||
l~insert('Fred', .nil) -- inserts this at the beginning
|
||||
l~insert('Mike') -- adds this to the end
|
||||
l~insert('Rick', index) -- inserts this after '123'
|
||||
l[index] = l[index] + 1 -- the original item is now '124'
|
||||
do item over l -- iterate over the items, displaying them in order
|
||||
say item
|
||||
end
|
||||
7
Task/Collections/OoRexx/collections-3.rexx
Normal file
7
Task/Collections/OoRexx/collections-3.rexx
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
q = .queue~of(2,4,6) -- creates a queue containing 3 items
|
||||
say q[1] q[3] -- displays "2 6"
|
||||
i = q~pull -- removes the first item
|
||||
q~queue(i) -- adds it to the end
|
||||
say q[1] q[3] -- displays "4 2"
|
||||
q[1] = q[1] + 1 -- updates the first item
|
||||
say q[1] q[3] -- displays "5 2"
|
||||
4
Task/Collections/OoRexx/collections-4.rexx
Normal file
4
Task/Collections/OoRexx/collections-4.rexx
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
t = .table~new
|
||||
t['abc'] = 1
|
||||
t['def'] = 2
|
||||
say t['abc'] t['def'] -- displays "1 2"
|
||||
12
Task/Collections/OoRexx/collections-5.rexx
Normal file
12
Task/Collections/OoRexx/collections-5.rexx
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
t = .table~new -- a table example to demonstrate the difference
|
||||
t['abc'] = 1 -- sets an item at index 'abc'
|
||||
t['abc'] = 2 -- updates that item
|
||||
say t~items t['abc'] -- displays "1 2"
|
||||
r = .relation~new
|
||||
r['abc'] = 1 -- sets an item at index 'abc'
|
||||
r['abc'] = 2 -- adds an additional item at the same index
|
||||
say r~items r['abc'] -- displays "2 2" this has two items in it now
|
||||
|
||||
do item over r~allAt('abc') -- retrieves all items at the index 'abc'
|
||||
say item
|
||||
end
|
||||
4
Task/Collections/OoRexx/collections-6.rexx
Normal file
4
Task/Collections/OoRexx/collections-6.rexx
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
d = .directory~new
|
||||
d['abc'] = 1
|
||||
d['def'] = 2
|
||||
say d['abc'] d['def'] -- displays "1 2"
|
||||
4
Task/Collections/OoRexx/collections-7.rexx
Normal file
4
Task/Collections/OoRexx/collections-7.rexx
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
d = .directory~new
|
||||
d~abc = 1
|
||||
d~def = 2
|
||||
say d~abc d~def -- displays "1 2"
|
||||
7
Task/Collections/OoRexx/collections-8.rexx
Normal file
7
Task/Collections/OoRexx/collections-8.rexx
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
s = .set~new
|
||||
text = "the quick brown fox jumped over the lazy dog"
|
||||
do word over text~makearray(' ')
|
||||
s~put(word)
|
||||
end
|
||||
|
||||
say "text has" text~words", but only" s~items "unique words"
|
||||
Loading…
Add table
Add a link
Reference in a new issue