diff options
Diffstat (limited to 'src/algebra')
-rw-r--r-- | src/algebra/Makefile.am | 2 | ||||
-rw-r--r-- | src/algebra/Makefile.in | 2 | ||||
-rw-r--r-- | src/algebra/aggcat.spad.pamphlet | 111 | ||||
-rw-r--r-- | src/algebra/files.spad.pamphlet | 1 | ||||
-rw-r--r-- | src/algebra/table.spad.pamphlet | 14 |
5 files changed, 61 insertions, 69 deletions
diff --git a/src/algebra/Makefile.am b/src/algebra/Makefile.am index 7ae1d762..9a44eddb 100644 --- a/src/algebra/Makefile.am +++ b/src/algebra/Makefile.am @@ -292,7 +292,7 @@ strap-0/UPOLYC.$(FASLEXT): strap-0/POLYCAT.$(FASLEXT) \ strap-0/COMRING.$(FASLEXT) strap-0/INTDOM.$(FASLEXT) \ strap-0/FIELD.$(FASLEXT) strap-0/ALGEBRA.$(FASLEXT) -strap-0/TBAGG.$(FASLEXT): strap-0/KDAGG.$(FASLEXT) +strap-0/TBAGG.$(FASLEXT): strap-0/KDAGG.$(FASLEXT) strap-0/FINAGG.$(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) diff --git a/src/algebra/Makefile.in b/src/algebra/Makefile.in index fc03a0b9..388c2ef9 100644 --- a/src/algebra/Makefile.in +++ b/src/algebra/Makefile.in @@ -1782,7 +1782,7 @@ strap-0/UPOLYC.$(FASLEXT): strap-0/POLYCAT.$(FASLEXT) \ strap-0/COMRING.$(FASLEXT) strap-0/INTDOM.$(FASLEXT) \ strap-0/FIELD.$(FASLEXT) strap-0/ALGEBRA.$(FASLEXT) -strap-0/TBAGG.$(FASLEXT): strap-0/KDAGG.$(FASLEXT) +strap-0/TBAGG.$(FASLEXT): strap-0/KDAGG.$(FASLEXT) strap-0/FINAGG.$(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) diff --git a/src/algebra/aggcat.spad.pamphlet b/src/algebra/aggcat.spad.pamphlet index db90d09d..f95287ad 100644 --- a/src/algebra/aggcat.spad.pamphlet +++ b/src/algebra/aggcat.spad.pamphlet @@ -1104,7 +1104,7 @@ import List )abbrev category TBAGG TableAggregate ++ Author: Michael Monagan, Stephen Watt; revised by Manuel Bronstein and Richard Jenks ++ Date Created: August 87 through August 88 -++ Date Last Updated: April 1991 +++ Date Last Updated: May 17, 2013. ++ Basic Operations: ++ Related Constructors: ++ Also See: @@ -1115,7 +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 == - KeyedDictionary(Key,Entry) with + Join(KeyedDictionary(Key,Entry), FiniteAggregate Record(key:Key,entry:Entry)) with table: () -> % ++ table()$T creates an empty table of type T. table: List Record(key:Key,entry:Entry) -> % @@ -1153,63 +1153,62 @@ TableAggregate(Key:SetCategory, Entry:SetCategory): Category == -- for k in keys t | not key?(k, s) repeat z.k := f(t.k, x) -- z - if % has finiteAggregate then - parts(t:%):List Record(key:Key,entry:Entry) == [[k, t.k] for k in keys t] - parts(t:%):List Entry == [t.k for k in keys t] - entries(t:%):List Entry == parts(t) - - s:% = t:% == - eq?(s,t) => true - #s ~= #t => false - for k in keys s repeat - (e := search(k, t)) case "failed" or (e::Entry) ~= s.k => - return false - true - - map(f: Record(key:Key,entry:Entry)->Record(key:Key,entry:Entry), t: %): % == - z := table() - for k in keys t repeat - ke: Record(key:Key,entry:Entry) := f [k, t.k] - z ke.key := ke.entry - z - map!(f: Record(key:Key,entry:Entry)->Record(key:Key,entry:Entry), t: %): % == - lke: List Record(key:Key,entry:Entry) := nil() - for k in keys t repeat - lke := cons(f [k, remove!(k,t)::Entry], lke) - for ke in lke repeat - t ke.key := ke.entry - t - - inspect(t: %): Record(key:Key,entry:Entry) == - ks := keys t - empty? ks => error "Cannot extract from an empty aggregate" - [first ks, t first ks] - - find(f: Record(key:Key,entry:Entry)->Boolean, t:%): Union(Record(key:Key,entry:Entry), "failed") == - for ke in parts(t)@List(Record(key:Key,entry:Entry)) repeat if f ke then return ke - "failed" + parts(t:%):List Record(key:Key,entry:Entry) == [[k, t.k] for k in keys t] + parts(t:%):List Entry == [t.k for k in keys t] + entries(t:%):List Entry == parts(t) - index?(k: Key, t: %): Boolean == - search(k,t) case Entry + s:% = t:% == + eq?(s,t) => true + #s ~= #t => false + for k in keys s repeat + (e := search(k, t)) case "failed" or (e::Entry) ~= s.k => + return false + true - remove!(x:Record(key:Key,entry:Entry), t:%) == - if member?(x, t) then remove!(x.key, t) - t - extract!(t: %): Record(key:Key,entry:Entry) == - k: Record(key:Key,entry:Entry) := inspect t - remove!(k.key, t) - k + map(f: Record(key:Key,entry:Entry)->Record(key:Key,entry:Entry), t: %): % == + z := table() + for k in keys t repeat + ke: Record(key:Key,entry:Entry) := f [k, t.k] + z ke.key := ke.entry + z + map!(f: Record(key:Key,entry:Entry)->Record(key:Key,entry:Entry), t: %): % == + lke: List Record(key:Key,entry:Entry) := nil() + for k in keys t repeat + lke := cons(f [k, remove!(k,t)::Entry], lke) + for ke in lke repeat + t ke.key := ke.entry + t + + inspect(t: %): Record(key:Key,entry:Entry) == + ks := keys t + empty? ks => error "Cannot extract from an empty aggregate" + [first ks, t first ks] + + find(f: Record(key:Key,entry:Entry)->Boolean, t:%): Union(Record(key:Key,entry:Entry), "failed") == + for ke in parts(t)@List(Record(key:Key,entry:Entry)) repeat if f ke then return ke + "failed" + + index?(k: Key, t: %): Boolean == + search(k,t) case Entry + + remove!(x:Record(key:Key,entry:Entry), t:%) == + if member?(x, t) then remove!(x.key, t) + t + extract!(t: %): Record(key:Key,entry:Entry) == + k: Record(key:Key,entry:Entry) := inspect t + remove!(k.key, t) + k - any?(f: Entry->Boolean, t: %): Boolean == - for k in keys t | f t k repeat return true - false - every?(f: Entry->Boolean, t: %): Boolean == - for k in keys t | not f t k repeat return false - true - count(f: Entry->Boolean, t: %): NonNegativeInteger == - tally: NonNegativeInteger := 0 - for k in keys t | f t k repeat tally := tally + 1 - tally + any?(f: Entry->Boolean, t: %): Boolean == + for k in keys t | f t k repeat return true + false + every?(f: Entry->Boolean, t: %): Boolean == + for k in keys t | not f t k repeat return false + true + count(f: Entry->Boolean, t: %): NonNegativeInteger == + tally: NonNegativeInteger := 0 + for k in keys t | f t k repeat tally := tally + 1 + tally @ diff --git a/src/algebra/files.spad.pamphlet b/src/algebra/files.spad.pamphlet index efc90616..e379d003 100644 --- a/src/algebra/files.spad.pamphlet +++ b/src/algebra/files.spad.pamphlet @@ -303,7 +303,6 @@ KeyedAccessFile(Entry): KAFcategory == KAFcapsule where KAFcategory == Join(FileCategory(Name, Record(key: Key, entry: Entry)), TableAggregate(Key, Entry)) with - finiteAggregate pack!: % -> % ++ pack!(f) reorganizes the file f on disk to recover ++ unused space. diff --git a/src/algebra/table.spad.pamphlet b/src/algebra/table.spad.pamphlet index 22984b89..dc650485 100644 --- a/src/algebra/table.spad.pamphlet +++ b/src/algebra/table.spad.pamphlet @@ -31,9 +31,7 @@ HashTable(Key, Entry, hashfn): Exports == Implementation where Key, Entry: SetCategory hashfn: String -- Union("EQ", "EQL", "EQUAL", "UEQUAL", "CVEC", "ID") - Exports ==> TableAggregate(Key, Entry) with - finiteAggregate - + Exports ==> TableAggregate(Key, Entry) Implementation ==> add import tableValue: (%,Key) -> Entry from Foreign Builtin import tableLength: % -> NonNegativeInteger from Foreign Builtin @@ -80,10 +78,8 @@ HashTable(Key, Entry, hashfn): Exports == Implementation where ++ for the implementation of \spadtype{Table}. InnerTable(Key: SetCategory, Entry: SetCategory, addDom):Exports == Implementation where - addDom : TableAggregate(Key, Entry) with - finiteAggregate - Exports ==> TableAggregate(Key, Entry) with - finiteAggregate + addDom : TableAggregate(Key, Entry) + Exports ==> TableAggregate(Key, Entry) Implementation ==> addDom @ @@ -108,9 +104,7 @@ InnerTable(Key: SetCategory, Entry: SetCategory, addDom):Exports == Implementati ++ \spadtype{AssociationList} Table(Key: SetCategory, Entry: SetCategory):Exports == Implementation where - Exports ==> TableAggregate(Key, Entry) with - finiteAggregate - + Exports ==> TableAggregate(Key, Entry) Implementation ==> InnerTable(Key, Entry, if hashable(Key)$Lisp then HashTable(Key, Entry, "EQUAL") else AssociationList(Key, Entry)) |