| |
Given
? pragma.syntax("0.8")
? def colors := ["red", "green", "blue"]
# value: ["red", "green", "blue"]
? def hw := "hello world"
# value: "hello world"
? def vice := ["bush" => "quayle", "clinton" => "gore"]
# value: ["bush" => "quayle", "clinton" => "gore"]
Messages Shared with all Tables
Since these messages are shared between Const and Flex tables, they must
be query only. As applied to a Flex table, they operate of the state of
the table at that instant.
Since they are shared between lists and maps, they must be have a common
meaning, whether an index is used with a list, or a key is used with a
map.
Indexing
| Example |
Meaning |
Expansion |
Value |
colors[2]
|
Indexing. Retrieves element #2 (the third element) |
colors.get(2)
|
"blue"
|
hw[2]
|
hw.get(2)
|
'l'
|
vice["bush"]
|
Lookup. This key maps to what value? |
vice.get("bush")
|
"quayle"
|
Containment
| Example |
Meaning |
Value |
colors.contains("green")
colors.contains("orange")
|
Is this an element of the list? |
true
false
|
hw.contains('w')
hw.contains('z')
|
true
false
|
vice.contains("quayle")
vice.contains("clinton")
|
Is this a value of the list? |
true
false
|
Since "vice" maps presidents to their vice presidents, "clinton"
is a key of the list (since he was a president), but is not present as
a value (since he was never a vice president).
Size
| Example |
Meaning |
Value |
colors.size()
|
How many elements are in the list? |
3
|
hw.size()
|
11
|
vice.size()
|
How many keys are in the list? |
2
|
Iteration
xxx Crap below this point
| Example |
Meaning |
Expansion |
Value |
list[2]
|
Indexing. Retrieves element #2 (the third element) |
list.get(2)
|
42
|
[3] == []
|
Are they the same? |
__equalizer.sameEver([3], [])
|
false
|
[3] != []
|
Are they different? |
__equalizer.sameEver([3], []).not()
|
true
|
Dealing with Change
| Example |
Value |
colors.snapshot()
hw.snapshot()
vice.snapshot() |
A Const* with a snapshot of the state at this time |
| Example |
Value |
colors.readOnly()
hw.readOnly()
vice.readOnly() |
A read-only facet for querying the current state |
| Example |
Value |
colors.diverge()
hw.diverge()
vice.diverge() |
A Flex* whose initial state is a snapshot of the state at this time
|
|
|