aboutsummaryrefslogtreecommitdiff
path: root/src/algebra/aggcat.spad.pamphlet
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2013-05-17 04:34:37 +0000
committerdos-reis <gdr@axiomatics.org>2013-05-17 04:34:37 +0000
commitc485556490b352a6e28436bbded564c1b10e348f (patch)
tree3c2cdef4c0a2bc3af2aed2de8ad5e85b5777294b /src/algebra/aggcat.spad.pamphlet
parente546308ba905ffb34a8adea792d10fb3242430a8 (diff)
downloadopen-axiom-c485556490b352a6e28436bbded564c1b10e348f.tar.gz
* algebra/aggcat.spad.pamphlet (KeyedDictionary): Now extend
IndexedAggregate too. Give default implementation for elt. (TableAggregate): Simplify.
Diffstat (limited to 'src/algebra/aggcat.spad.pamphlet')
-rw-r--r--src/algebra/aggcat.spad.pamphlet25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/algebra/aggcat.spad.pamphlet b/src/algebra/aggcat.spad.pamphlet
index 576a5a24..db90d09d 100644
--- a/src/algebra/aggcat.spad.pamphlet
+++ b/src/algebra/aggcat.spad.pamphlet
@@ -882,7 +882,7 @@ import List
++ A keyed dictionary is a dictionary of key-entry pairs for which there is
++ a unique entry for each key.
KeyedDictionary(Key:SetCategory, Entry:SetCategory): Category ==
- Dictionary Record(key:Key,entry:Entry) with
+ Join(Dictionary Record(key:Key,entry:Entry),IndexedAggregate(Key,Entry)) with
key?: (Key, %) -> Boolean
++ key?(k,t) tests if k is a key in table t.
keys: % -> List Key
@@ -899,13 +899,21 @@ KeyedDictionary(Key:SetCategory, Entry:SetCategory): Category ==
add
key?(k, t) == search(k, t) case Entry
- member?(p, t) ==
+ member?(p: Record(key: Key,entry: Entry), t: %): Boolean ==
r := search(p.key, t)
r case Entry and r::Entry = p.entry
if % has finiteAggregate then
keys t == [x.key for x in parts t]
+ elt(t, k) ==
+ (r := search(k, t)) case Entry => r::Entry
+ error "key not in table"
+
+ elt(t, k, e) ==
+ (r := search(k, t)) case Entry => r::Entry
+ e
+
@
\section{category ELTAB Eltable}
@@ -1107,10 +1115,7 @@ import List
++ A table aggregate is a model of a table, i.e. a discrete many-to-one
++ mapping from keys to entries.
TableAggregate(Key:SetCategory, Entry:SetCategory): Category ==
- Join(KeyedDictionary(Key,Entry),IndexedAggregate(Key,Entry)) with
- setelt: (%,Key,Entry) -> Entry -- setelt! later
- ++ setelt(t,k,e) (also written \axiom{t.k := e}) is equivalent
- ++ to \axiom{(insert([k,e],t); e)}.
+ KeyedDictionary(Key,Entry) with
table: () -> %
++ table()$T creates an empty table of type T.
table: List Record(key:Key,entry:Entry) -> %
@@ -1133,14 +1138,6 @@ TableAggregate(Key:SetCategory, Entry:SetCategory): Category ==
prefix("table"::OutputForm,
[k::OutputForm = (t.k)::OutputForm for k in keys t])
- elt(t, k) ==
- (r := search(k, t)) case Entry => r::Entry
- error "key not in table"
-
- elt(t, k, e) ==
- (r := search(k, t)) case Entry => r::Entry
- e
-
map!(f: Entry->Entry, t: %) ==
for k in keys t repeat t.k := f t.k
t