diff options
author | dos-reis <gdr@axiomatics.org> | 2013-05-17 04:34:37 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2013-05-17 04:34:37 +0000 |
commit | c485556490b352a6e28436bbded564c1b10e348f (patch) | |
tree | 3c2cdef4c0a2bc3af2aed2de8ad5e85b5777294b /src/algebra | |
parent | e546308ba905ffb34a8adea792d10fb3242430a8 (diff) | |
download | open-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')
-rw-r--r-- | src/algebra/Makefile.am | 6 | ||||
-rw-r--r-- | src/algebra/Makefile.in | 6 | ||||
-rw-r--r-- | src/algebra/aggcat.spad.pamphlet | 25 |
3 files changed, 17 insertions, 20 deletions
diff --git a/src/algebra/Makefile.am b/src/algebra/Makefile.am index 4c27b514..7ae1d762 100644 --- a/src/algebra/Makefile.am +++ b/src/algebra/Makefile.am @@ -293,7 +293,7 @@ strap-0/UPOLYC.$(FASLEXT): strap-0/POLYCAT.$(FASLEXT) \ strap-0/FIELD.$(FASLEXT) strap-0/ALGEBRA.$(FASLEXT) strap-0/TBAGG.$(FASLEXT): strap-0/KDAGG.$(FASLEXT) -strap-0/KDAGG.$(FASLEXT): strap-0/DIAGG.$(FASLEXT) +strap-0/KDAGG.$(FASLEXT): strap-0/DIAGG.$(FASLEXT) strap-0/IXAGG.$(FASLEXT) strap-0/DIAGG.$(FASLEXT): strap-0/DIOPS.$(FASLEXT) strap-0/DIOPS.$(FASLEXT): strap-0/BGAGG.$(FASLEXT) strap-0/BGAGG.$(FASLEXT): strap-0/HOAGG.$(FASLEXT) @@ -993,7 +993,7 @@ strap-2/ALAGG.$(FASLEXT): strap-2/TBAGG.$(FASLEXT) strap-2/LSAGG.$(FASLEXT) strap-2/LSAGG.$(FASLEXT): strap-2/STAGG.$(FASLEXT) \ strap-2/FLAGG.$(FASLEXT) strap-2/ELAGG.$(FASLEXT) strap-2/TBAGG.$(FASLEXT): strap-2/KDAGG.$(FASLEXT) -strap-2/KDAGG.$(FASLEXT): strap-2/DIAGG.$(FASLEXT) +strap-2/KDAGG.$(FASLEXT): strap-2/DIAGG.$(FASLEXT) strap-2/IXAGG.$(FASLEXT) strap-2/DIAGG.$(FASLEXT): strap-2/DIOPS.$(FASLEXT) strap-2/DIOPS.$(FASLEXT): strap-2/BGAGG.$(FASLEXT) strap-2/CLAGG.$(FASLEXT) strap-2/BGAGG.$(FASLEXT): strap-2/HOAGG.$(FASLEXT) @@ -1374,7 +1374,7 @@ $(OUT)/SETAGG.$(FASLEXT): $(OUT)/SETCAT.$(FASLEXT) $(OUT)/CLAGG.$(FASLEXT) $(OUT)/STRING.$(FASLEXT): $(OUT)/SRAGG.$(FASLEXT) $(OUT)/ORDFIN.$(FASLEXT) $(OUT)/DIOPS.$(FASLEXT): $(OUT)/STRING.$(FASLEXT) $(OUT)/DIAGG.$(FASLEXT): $(OUT)/DIOPS.$(FASLEXT) -$(OUT)/KDAGG.$(FASLEXT): $(OUT)/DIAGG.$(FASLEXT) +$(OUT)/KDAGG.$(FASLEXT): $(OUT)/DIAGG.$(FASLEXT) $(OUT)/IXAGG.$(FASLEXT) $(OUT)/TBAGG.$(FASLEXT): $(OUT)/KDAGG.$(FASLEXT) $(OUT)/ALAGG.$(FASLEXT): $(OUT)/TBAGG.$(FASLEXT) $(OUT)/LIST.$(FASLEXT): $(OUT)/LSAGG.$(FASLEXT) $(OUT)/REF.$(FASLEXT) \ diff --git a/src/algebra/Makefile.in b/src/algebra/Makefile.in index 766ace73..fc03a0b9 100644 --- a/src/algebra/Makefile.in +++ b/src/algebra/Makefile.in @@ -1783,7 +1783,7 @@ strap-0/UPOLYC.$(FASLEXT): strap-0/POLYCAT.$(FASLEXT) \ strap-0/FIELD.$(FASLEXT) strap-0/ALGEBRA.$(FASLEXT) strap-0/TBAGG.$(FASLEXT): strap-0/KDAGG.$(FASLEXT) -strap-0/KDAGG.$(FASLEXT): strap-0/DIAGG.$(FASLEXT) +strap-0/KDAGG.$(FASLEXT): strap-0/DIAGG.$(FASLEXT) strap-0/IXAGG.$(FASLEXT) strap-0/DIAGG.$(FASLEXT): strap-0/DIOPS.$(FASLEXT) strap-0/DIOPS.$(FASLEXT): strap-0/BGAGG.$(FASLEXT) strap-0/BGAGG.$(FASLEXT): strap-0/HOAGG.$(FASLEXT) @@ -2480,7 +2480,7 @@ strap-2/ALAGG.$(FASLEXT): strap-2/TBAGG.$(FASLEXT) strap-2/LSAGG.$(FASLEXT) strap-2/LSAGG.$(FASLEXT): strap-2/STAGG.$(FASLEXT) \ strap-2/FLAGG.$(FASLEXT) strap-2/ELAGG.$(FASLEXT) strap-2/TBAGG.$(FASLEXT): strap-2/KDAGG.$(FASLEXT) -strap-2/KDAGG.$(FASLEXT): strap-2/DIAGG.$(FASLEXT) +strap-2/KDAGG.$(FASLEXT): strap-2/DIAGG.$(FASLEXT) strap-2/IXAGG.$(FASLEXT) strap-2/DIAGG.$(FASLEXT): strap-2/DIOPS.$(FASLEXT) strap-2/DIOPS.$(FASLEXT): strap-2/BGAGG.$(FASLEXT) strap-2/CLAGG.$(FASLEXT) strap-2/BGAGG.$(FASLEXT): strap-2/HOAGG.$(FASLEXT) @@ -2714,7 +2714,7 @@ $(OUT)/SETAGG.$(FASLEXT): $(OUT)/SETCAT.$(FASLEXT) $(OUT)/CLAGG.$(FASLEXT) $(OUT)/STRING.$(FASLEXT): $(OUT)/SRAGG.$(FASLEXT) $(OUT)/ORDFIN.$(FASLEXT) $(OUT)/DIOPS.$(FASLEXT): $(OUT)/STRING.$(FASLEXT) $(OUT)/DIAGG.$(FASLEXT): $(OUT)/DIOPS.$(FASLEXT) -$(OUT)/KDAGG.$(FASLEXT): $(OUT)/DIAGG.$(FASLEXT) +$(OUT)/KDAGG.$(FASLEXT): $(OUT)/DIAGG.$(FASLEXT) $(OUT)/IXAGG.$(FASLEXT) $(OUT)/TBAGG.$(FASLEXT): $(OUT)/KDAGG.$(FASLEXT) $(OUT)/ALAGG.$(FASLEXT): $(OUT)/TBAGG.$(FASLEXT) $(OUT)/LIST.$(FASLEXT): $(OUT)/LSAGG.$(FASLEXT) $(OUT)/REF.$(FASLEXT) \ 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 |