diff --git a/books/bookvol10.2.pamphlet b/books/bookvol10.2.pamphlet index 8b0afca..3307f21 100644 --- a/books/bookvol10.2.pamphlet +++ b/books/bookvol10.2.pamphlet @@ -299,6 +299,7 @@ This is the root of the category hierarchy and is not represented by code. \pageto{ConvertibleTo}{KONVERT} \pageto{ElementaryFunctionCategory}{ELEMFUN} \pageto{Eltable}{ELTAB} +\pageto{FullyEvalableOver}{FEVALAB} \pageto{HyperbolicFunctionCategory}{HYPCAT} \pageto{InnerEvalable}{IEVALAB} \pageto{Logic}{LOGIC} @@ -628,7 +629,7 @@ AttributeRegistry(): Category == with "ATTREG" -> "CATEGORY" @ -<>= +<>= "AttributeRegistry()" [color=lightblue,href="bookvol10.2.pdf#nameddest=ATTREG"]; "AttributeRegistry()" -> "Category" @@ -1094,6 +1095,11 @@ Eltable(S:SetCategory, Index:Type): Category == with "Eltable(a:Ring,b:Ring)" -> "Eltable(a:SetCategory,b:Type)" +"Eltable(a:SetCategory,b:SetCategory)" + [color=seagreen,href="bookvol10.2.pdf#nameddest=ELTAB"]; +"Eltable(a:SetCategory,b:SetCategory)" -> + "Eltable(a:SetCategory,b:Type)" + @ <>= digraph pic { @@ -1815,15 +1821,17 @@ digraph pic { \pagehead{Type}{TYPE} \pagepic{ps/v102type.ps}{TYPE}{1.00} +{\bf See:}\\ +\pageto{Aggregate}{AGG} +\pageto{FullyPatternMatchable}{FPATMAB} +\pageto{SegmentCategory}{SEGCAT} +\pagefrom{Category}{CATEGORY} + {\bf Attributes exported:} \begin{itemize} \item {\bf nil} \end{itemize} -{\bf See:}\\ -\pageto{Aggregate}{AGG} -\pageto{FullyPatternMatchable}{FPATMAB} -\pagefrom{Category}{CATEGORY} <>= )abbrev category TYPE Type ++ The new fundamental Type (keeping Object for 1.5 as well) @@ -2504,6 +2512,122 @@ digraph pic { @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\pagehead{SegmentCategory}{SEGCAT} +\pagepic{ps/v102segmentcategory.ps}{SEGCAT}{1.00} + +{\bf See:}\\ +\pageto{SegmentExpansionCategory}{SEGXCAT} +\pagefrom{Type}{TYPE} + +{\bf Exports:}\\ +\begin{tabular}{lllll} +\cross{SEGCAT}{BY} & +\cross{SEGCAT}{convert} & +\cross{SEGCAT}{hi} & +\cross{SEGCAT}{high} & +\cross{SEGCAT}{incr} \\ +\cross{SEGCAT}{lo} & +\cross{SEGCAT}{low} & +\cross{SEGCAT}{segment} & +\cross{SEGCAT}{?..?} & +\end{tabular} + +{\bf Attributes Exported:} +\begin{itemize} +\item {\bf nil} +\end{itemize} + +These are directly exported but not implemented: +\begin{verbatim} + BY : (%,Integer) -> % + convert : S -> % + hi : % -> S + high : % -> S + incr : % -> Integer + lo : % -> S + low : % -> S + segment : (S,S) -> % + ?..? : (S,S) -> % +\end{verbatim} + +<>= +)abbrev category SEGCAT SegmentCategory +++ Author: Stephen M. Watt +++ Date Created: December 1986 +++ Date Last Updated: June 3, 1991 +++ Basic Operations: +++ Related Domains: +++ Also See: +++ AMS Classifications: +++ Keywords: range, segment +++ Examples: +++ References: +++ Description: +++ This category provides operations on ranges, or {\em segments} +++ as they are called. + +SegmentCategory(S:Type): Category == Type with + SEGMENT: (S, S) -> % + ++ \spad{l..h} creates a segment with l and h as the endpoints. + BY: (%, Integer) -> % + ++ \spad{s by n} creates a new segment in which only every + ++ \spad{n}-th element is used. + lo: % -> S + ++ lo(s) returns the first endpoint of s. + ++ Note: \spad{lo(l..h) = l}. + hi: % -> S + ++ hi(s) returns the second endpoint of s. + ++ Note: \spad{hi(l..h) = h}. + low: % -> S + ++ low(s) returns the first endpoint of s. + ++ Note: \spad{low(l..h) = l}. + high: % -> S + ++ high(s) returns the second endpoint of s. + ++ Note: \spad{high(l..h) = h}. + incr: % -> Integer + ++ incr(s) returns \spad{n}, where s is a segment in which every + ++ \spad{n}-th element is used. + ++ Note: \spad{incr(l..h by n) = n}. + segment: (S, S) -> % + ++ segment(i,j) is an alternate way to create the segment + ++ \spad{i..j}. + convert: S -> % + ++ convert(i) creates the segment \spad{i..i}. + +@ +<>= +"SEGCAT" + [color=lightblue,href="bookvol10.2.pdf#nameddest=SEGCAT"]; +"SEGCAT" -> "TYPE" + +@ +<>= +"SegmentCategory(a:Type)" + [color=lightblue,href="bookvol10.2.pdf#nameddest=SEGCAT"]; +"SegmentCategory(a:Type)" -> "Type()" + +"SegmentCategory(OrderedRing)" + [color=seagreen,href="bookvol10.2.pdf#nameddest=SEGCAT"]; +"SegmentCategory(OrderedRing)" -> "SegmentCategory(a:Type)" + +@ +<>= +digraph pic { + fontsize=10; + bgcolor="#FFFF66"; + node [shape=box, color=white, style=filled]; + +"SegmentCategory(a:Type)" [color=lightblue]; +"SegmentCategory(a:Type)" -> "Type()" + +"Type()" [color=lightblue]; +"Type()" -> "Category" + +"Category" [color=lightblue]; +} + +@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \pagehead{SetCategory}{SETCAT} \pagepic{ps/v102setcategory.ps}{SETCAT}{1.00} @@ -2518,8 +2642,10 @@ digraph pic { \pageto{PatternMatchable}{PATMAB} \pageto{SemiGroup}{SGROUP} \pageto{SetAggregate}{SETAGG} +\pageto{SExpressionCategory}{SEXCAT} \pageto{StepThrough}{STEP} \pageto{StringCategory}{STRICAT} +\pageto{ThreeSpaceCategory}{SPACEC} \pagefrom{BasicType}{BASTYPE} \pagefrom{CoercibleTo}{KOERCE} @@ -2928,6 +3054,126 @@ digraph pic { @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\pagehead{FullyEvalableOver}{FEVALAB} +\pagepic{ps/v102fullyevalableover.ps}{FEVALAB}{0.75} + +{\bf See:}\\ +\pagefrom{Category}{CATEGORY} + +{\bf Exports:}\\ +\begin{tabular}{lll} +\cross{FEVALAB}{eval} & +\cross{FEVALAB}{map} & +\cross{FEVALAB}{?.?} +\end{tabular} + +These are directly exported but not implemented: +\begin{verbatim} + map : ((R -> R),%) -> % +\end{verbatim} + +These are implemented by this category: +\begin{verbatim} + ?.? : (%,R) -> % if R has ELTAB(R,R) + eval : (%,Equation R) -> % if R has EVALAB R + eval : (%,List Symbol,List R) -> % if R has IEVALAB(SYMBOL,R) +\end{verbatim} + +These exports come from \refto{Evalable}(a:Type): +\begin{verbatim} + eval : (%,List Equation R) -> % if R has EVALAB R + eval : (%,R,R) -> % if R has EVALAB R + eval : (%,List R,List R) -> % if R has EVALAB R +\end{verbatim} + +These exports come from \refto{InnerEvalable}(a:Symbol,b:SetCategory): +\begin{verbatim} + eval : (%,Symbol,R) -> % if R has IEVALAB(SYMBOL,R) +\end{verbatim} + +<>= +)abbrev category FEVALAB FullyEvalableOver +++ Author: +++ Date Created: +++ Date Last Updated: June 3, 1991 +++ Basic Operations: +++ Related Domains: Equation +++ Also See: +++ AMS Classifications: +++ Keywords: equation +++ Examples: +++ References: +++ Description: +++ This category provides a selection of evaluation operations +++ depending on what the argument type R provides. +FullyEvalableOver(R:SetCategory): Category == with + map: (R -> R, $) -> $ + ++ map(f, ex) evaluates ex, applying f to values of type R in ex. + if R has Eltable(R, R) then Eltable(R, $) + if R has Evalable(R) then Evalable(R) + if R has InnerEvalable(Symbol, R) then InnerEvalable(Symbol, R) + add + if R has Eltable(R, R) then + elt(x:$, r:R) == map(#1.r, x) + + if R has Evalable(R) then + eval(x:$, l:List Equation R) == map(eval(#1, l), x) + + if R has InnerEvalable(Symbol, R) then + eval(x:$, ls:List Symbol, lv:List R) == map(eval(#1, ls, lv), x) + +@ +<>= +"FEVALAB" + [color=lightblue,href="bookvol10.2.pdf#nameddest=FEVALAB"]; +"FEVALAB" -> "ELTAB" +"FEVALAB" -> "EVALAB" +"FEVALAB" -> "IEVALAB" +"FEVALAB" -> "CATEGORY" +@ +<>= +"FullyEvalableOver(a:SetCategory)" + [color=lightblue,href="bookvol10.2.pdf#nameddest=FEVALAB"]; +"FullyEvalableOver(a:SetCategory)" -> "Eltable(a:SetCategory,b:Type)" +"FullyEvalableOver(a:SetCategory)" -> "Evalable(a:SetCategory)" +"FullyEvalableOver(a:SetCategory)" -> "Category" + +@ +<>= +digraph pic { + fontsize=10; + bgcolor="#FFFF66"; + node [shape=box, color=white, style=filled]; + +"FullyEvalableOver(a:SetCategory)" [color=lightblue]; +"FullyEvalableOver(a:SetCategory)" -> "Eltable(a:SetCategory,b:SetCategory)" +"FullyEvalableOver(a:SetCategory)" -> "Evalable(a:SetCategory)" +"FullyEvalableOver(a:SetCategory)" -> "Category" + +"Eltable(a:SetCategory,b:SetCategory)" + [color=seagreen,href="bookvol10.2.pdf#nameddest=ELTAB"]; +"Eltable(a:SetCategory,b:SetCategory)" -> + "Eltable(a:SetCategory,b:Type)" + +"Eltable(a:SetCategory,b:Type)" [color=lightblue]; +"Eltable(a:SetCategory,b:Type)" -> "Category" + +"Evalable(a:SetCategory)" + [color=lightblue,href="bookvol10.2.pdf#nameddest=EVALAB"]; +"Evalable(a:SetCategory)" -> "InnerEvalable(a:SetCategory,b:SetCategory)" + +"InnerEvalable(a:SetCategory,b:SetCategory)" [color=seagreen]; +"InnerEvalable(a:SetCategory,b:SetCategory)" -> + "InnerEvalable(a:SetCategory,b:Type)" + +"InnerEvalable(a:SetCategory,b:Type)" [color=lightblue]; +"InnerEvalable(a:SetCategory,b:Type)" -> "Category" + +"Category" [color=lightblue]; +} + +@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \pagehead{FileCategory}{FILECAT} \pagepic{ps/v102filecategory.ps}{FILECAT}{1.00} @@ -4252,6 +4498,123 @@ digraph pic { @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\pagehead{SegmentExpansionCategory}{SEGXCAT} +\pagepic{ps/v102segmentexpansioncategory.ps}{SEGXCAT}{0.75} + +{\bf See:}\\ +\pagefrom{SegmentCategory}{SEGCAT} + +{\bf Exports:}\\ +\begin{tabular}{lllll} +\cross{SEGXCAT}{BY} & +\cross{SEGXCAT}{convert} & +\cross{SEGXCAT}{expand} & +\cross{SEGXCAT}{hi} & +\cross{SEGXCAT}{high} \\ +\cross{SEGXCAT}{incr} & +\cross{SEGXCAT}{lo} & +\cross{SEGXCAT}{low} & +\cross{SEGXCAT}{map} & +\cross{SEGXCAT}{segment} \\ +\cross{SEGXCAT}{?..?} &&&& +\end{tabular} + + +{\bf Attributes exported:} +\begin{itemize} +\item {\bf nil} +\end{itemize} + +These are directly exported but not implemented: +\begin{verbatim} + expand : % -> L + expand : List % -> L + map : ((S -> S),%) -> L +\end{verbatim} + +These exports come from \refto{SegmentCategory}(OrderedRing): +\begin{verbatim} + BY : (%,Integer) -> % + convert : S -> % + hi : % -> S + high : % -> S + incr : % -> Integer + lo : % -> S + low : % -> S + segment : (S,S) -> % + ?..? : (S,S) -> % +\end{verbatim} + +<>= +)abbrev category SEGXCAT SegmentExpansionCategory +++ Author: Stephen M. Watt +++ Date Created: June 5, 1991 +++ Date Last Updated: +++ Basic Operations: +++ Related Domains: Segment, UniversalSegment +++ Also See: +++ AMS Classifications: +++ Keywords: +++ Examples: +++ References: +++ Description: +++ This category provides an interface for expanding segments to +++ a stream of elements. +SegmentExpansionCategory(S: OrderedRing, L: StreamAggregate(S)): Category == + SegmentCategory(S) with + expand: List % -> L + ++ expand(l) creates a new value of type L in which each segment + ++ \spad{l..h by k} is replaced with \spad{l, l+k, ... lN}, + ++ where \spad{lN <= h < lN+k}. + ++ For example, \spad{expand [1..4, 7..9] = [1,2,3,4,7,8,9]}. + expand: % -> L + ++ expand(l..h by k) creates value of type L with elements + ++ \spad{l, l+k, ... lN} where \spad{lN <= h < lN+k}. + ++ For example, \spad{expand(1..5 by 2) = [1,3,5]}. + map: (S -> S, %) -> L + ++ map(f,l..h by k) produces a value of type L by applying f + ++ to each of the succesive elements of the segment, that is, + ++ \spad{[f(l), f(l+k), ..., f(lN)]}, where \spad{lN <= h < lN+k}. + +@ +<>= +"SEGXCAT" + [color=lightblue,href="bookvol10.2.pdf#nameddest=SEGXCAT"]; +"SEGXCAT" -> "SEGCAT" +@ +<>= +"SegmentExpansionCategory(a:OrderedRing,b:StreamAggregate(OrderedRing))" + [color=lightblue,href="bookvol10.2.pdf#nameddest=SEGXCAT"]; +"SegmentExpansionCategory(a:OrderedRing,b:StreamAggregate(OrderedRing))" + -> "SegmentCategory(OrderedRing)" + +@ +<>= +digraph pic { + fontsize=10; + bgcolor="#FFFF66"; + node [shape=box, color=white, style=filled]; + +"SegmentExpansionCategory(a:OrderedRing,b:StreamAggregate(OrderedRing))" + [color=lightblue,href="bookvol10.2.pdf#nameddest=SEGXCAT"]; +"SegmentExpansionCategory(a:OrderedRing,b:StreamAggregate(OrderedRing))" + -> "SegmentCategory(OrderedRing)" + +"SegmentCategory(OrderedRing)" + [color=seagreen,href="bookvol10.2.pdf#nameddest=SEGCAT"]; +"SegmentCategory(OrderedRing)" -> "SegmentCategory(a:Type)" + +"SegmentCategory(a:Type)" [color=lightblue]; +"SegmentCategory(a:Type)" -> "Type()" + +"Type()" [color=lightblue]; +"Type()" -> "Category" + +"Category" [color=lightblue]; +} + +@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \pagehead{SemiGroup}{SGROUP} \pagepic{ps/v102semigroup.ps}{SGROUP}{0.75} @@ -4382,6 +4745,200 @@ digraph pic { @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\pagehead{SExpressionCategory}{SEXCAT} +\pagepic{ps/v102sexpressioncategory.ps}{SEXCAT}{0.60} + +{\bf See:}\\ +\pagefrom{SetCategory}{SETCAT} + +{\bf Exports:}\\ +\begin{tabular}{lllll} +\cross{SEXCAT}{atom?} & +\cross{SEXCAT}{car} & +\cross{SEXCAT}{cdr} & +\cross{SEXCAT}{coerce} & +\cross{SEXCAT}{convert} \\ +\cross{SEXCAT}{destruct} & +\cross{SEXCAT}{eq} & +\cross{SEXCAT}{expr} & +\cross{SEXCAT}{float} & +\cross{SEXCAT}{float?} \\ +\cross{SEXCAT}{hash} & +\cross{SEXCAT}{integer} & +\cross{SEXCAT}{integer?} & +\cross{SEXCAT}{latex} & +\cross{SEXCAT}{list?} \\ +\cross{SEXCAT}{null?} & +\cross{SEXCAT}{pair?} & +\cross{SEXCAT}{string} & +\cross{SEXCAT}{string?} & +\cross{SEXCAT}{symbol} \\ +\cross{SEXCAT}{symbol?} & +\cross{SEXCAT}{\#?} & +\cross{SEXCAT}{?=?} & +\cross{SEXCAT}{?\~{}=?} & +\cross{SEXCAT}{?.?} \\ +\end{tabular} + +These are directly exported but not implemented: +\begin{verbatim} + atom? : % -> Boolean + car : % -> % + cdr : % -> % + convert : Expr -> % + convert : Flt -> % + convert : Int -> % + convert : Sym -> % + convert : Str -> % + convert : List % -> % + destruct : % -> List % + eq : (%,%) -> Boolean + expr : % -> Expr + float : % -> Flt + float? : % -> Boolean + integer : % -> Int + integer? : % -> Boolean + list? : % -> Boolean + null? : % -> Boolean + pair? : % -> Boolean + string : % -> Str + string? : % -> Boolean + symbol : % -> Sym + symbol? : % -> Boolean + #? : % -> Integer + ?.? : (%,List Integer) -> % + ?.? : (%,Integer) -> % +\end{verbatim} + +These exports come from \refto{SetCategory}(): +\begin{verbatim} + coerce : % -> OutputForm + hash : % -> SingleInteger + latex : % -> String + ?=? : (%,%) -> Boolean + ?~=? : (%,%) -> Boolean +\end{verbatim} + +<>= +)abbrev category SEXCAT SExpressionCategory +++ Category for Lisp values +++ Author: S.M.Watt +++ Date Created: July 1987 +++ Date Last Modified: 23 May 1991 +++ Description: +++ This category allows the manipulation of Lisp values while keeping +++ the grunge fairly localized. +-- The coerce to expression lets the +-- values be displayed in the usual parenthesized way (displaying +-- them as type Expression can cause the formatter to die, since +-- certain magic cookies are in unexpected places). +-- SMW July 87 +SExpressionCategory(Str, Sym, Int, Flt, Expr): Category == Decl where + Str, Sym, Int, Flt, Expr: SetCategory + + Decl ==> SetCategory with + eq: (%,%) -> Boolean + ++ eq(s, t) is true if EQ(s,t) is true in Lisp. + null?: % -> Boolean + ++ null?(s) is true if s is the S-expression (). + atom?: % -> Boolean + ++ atom?(s) is true if s is a Lisp atom. + pair?: % -> Boolean + ++ pair?(s) is true if s has is a non-null Lisp list. + list?: % -> Boolean + ++ list?(s) is true if s is a Lisp list, possibly (). + string?: % -> Boolean + ++ string?(s) is true if s is an atom and belong to Str. + symbol?: % -> Boolean + ++ symbol?(s) is true if s is an atom and belong to Sym. + integer?: % -> Boolean + ++ integer?(s) is true if s is an atom and belong to Int. + float?: % -> Boolean + ++ float?(s) is true if s is an atom and belong to Flt. + destruct: % -> List % + ++ destruct((a1,...,an)) returns the list [a1,...,an]. + string: % -> Str + ++ string(s) returns s as an element of Str. + ++ Error: if s is not an atom that also belongs to Str. + symbol: % -> Sym + ++ symbol(s) returns s as an element of Sym. + ++ Error: if s is not an atom that also belongs to Sym. + integer: % -> Int + ++ integer(s) returns s as an element of Int. + ++ Error: if s is not an atom that also belongs to Int. + float: % -> Flt + ++ float(s) returns s as an element of Flt; + ++ Error: if s is not an atom that also belongs to Flt. + expr: % -> Expr + ++ expr(s) returns s as an element of Expr; + ++ Error: if s is not an atom that also belongs to Expr. + convert: List % -> % + ++ convert([a1,...,an]) returns an S-expression \spad{(a1,...,an)}. + convert: Str -> % + ++ convert(x) returns the Lisp atom x; + convert: Sym -> % + ++ convert(x) returns the Lisp atom x. + convert: Int -> % + ++ convert(x) returns the Lisp atom x. + convert: Flt -> % + ++ convert(x) returns the Lisp atom x. + convert: Expr -> % + ++ convert(x) returns the Lisp atom x. + car: % -> % + ++ car((a1,...,an)) returns a1. + cdr: % -> % + ++ cdr((a1,...,an)) returns \spad{(a2,...,an)}. + "#": % -> Integer + ++ #((a1,...,an)) returns n. + elt: (%, Integer) -> % + ++ elt((a1,...,an), i) returns \spad{ai}. + elt: (%, List Integer) -> % + ++ elt((a1,...,an), [i1,...,im]) returns \spad{(a_i1,...,a_im)}. + +@ +<>= +"SEXCAT" + [color=lightblue,href="bookvol10.2.pdf#nameddest=SEXCAT"]; +"SEXCAT" -> "SETCAT" + +@ +<>= +"SExpressionCategory(a:SetCategory,b:SetCategory,c:SetCategory,d:SetCategory,e:SetCategory)" + [color=lightblue,href="bookvol10.2.pdf#nameddest=SEXCAT"]; +"SExpressionCategory(a:SetCategory,b:SetCategory,c:SetCategory,d:SetCategory,e:SetCategory)" -> + "SetCategory()" + +@ +<>= +digraph pic { + fontsize=10; + bgcolor="#FFFF66"; + node [shape=box, color=white, style=filled]; + +"SExpressionCategory(a:SetCategory,b:SetCategory,c:SetCategory,d:SetCategory,e:SetCategory)" + [color=lightblue]; +"SExpressionCategory(a:SetCategory,b:SetCategory,c:SetCategory,d:SetCategory,e:SetCategory)" -> + "SetCategory()" + +"SetCategory()" [color=lightblue]; +"SetCategory()" -> "BasicType()" +"SetCategory()" -> "CoercibleTo(OutputForm)" + +"BasicType()" [color=lightblue]; +"BasicType()" -> "Category" + +"CoercibleTo(OutputForm)" [color=seagreen]; +"CoercibleTo(OutputForm)" -> "CoercibleTo(a:Type)" + +"CoercibleTo(a:Type)" [color=lightblue]; +"CoercibleTo(a:Type)" -> "Category" + +"Category" [color=lightblue]; + +} + +@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \pagehead{StepThrough}{STEP} \pagepic{ps/v102stepthrough.ps}{STEP}{1.00} @@ -4485,6 +5042,454 @@ digraph pic { } @ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\pagehead{ThreeSpaceCategory}{SPACEC} +\pagepic{ps/v102threespacecategory.ps}{SPACEC}{1.00} + +{\bf See:}\\ +\pagefrom{SetCategory}{SETCAT} + +{\bf Exports:}\\ +\begin{tabular}{lllll} +\cross{SPACEC}{check} & +\cross{SPACEC}{closedCurve} & +\cross{SPACEC}{closedCurve?} & +\cross{SPACEC}{coerce} \\ +\cross{SPACEC}{components} & +\cross{SPACEC}{composite} & +\cross{SPACEC}{composites} & +\cross{SPACEC}{copy} \\ +\cross{SPACEC}{create3Space} & +\cross{SPACEC}{curve} & +\cross{SPACEC}{curve?} & +\cross{SPACEC}{enterPointData} \\ +\cross{SPACEC}{hash} & +\cross{SPACEC}{latex} & +\cross{SPACEC}{lllip} & +\cross{SPACEC}{lllp} \\ +\cross{SPACEC}{llprop} & +\cross{SPACEC}{lp} & +\cross{SPACEC}{lprop} & +\cross{SPACEC}{merge} \\ +\cross{SPACEC}{mesh} & +\cross{SPACEC}{mesh?} & +\cross{SPACEC}{modifyPointData} & +\cross{SPACEC}{numberOfComponents} \\ +\cross{SPACEC}{numberOfComposites} & +\cross{SPACEC}{objects} & +\cross{SPACEC}{point} & +\cross{SPACEC}{point?} \\ +\cross{SPACEC}{polygon} & +\cross{SPACEC}{polygon?} & +\cross{SPACEC}{subspace} & +\cross{SPACEC}{?=?} \\ +\cross{SPACEC}{?\~{}=?} &&& +\end{tabular} + +These are directly exported but not implemented: +\begin{verbatim} + check : % -> % + closedCurve : (%,List List R) -> % + closedCurve : (%,List Point R) -> % + closedCurve : List Point R -> % + closedCurve : % -> List Point R + closedCurve? : % -> Boolean + coerce : % -> OutputForm + components : % -> List % + composite : List % -> % + composites : % -> List % + copy : % -> % + create3Space : () -> % + create3Space : SubSpace(3,R) -> % + curve : (%,List List R) -> % + curve : (%,List Point R) -> % + curve : List Point R -> % + curve : % -> List Point R + curve? : % -> Boolean + enterPointData : (%,List Point R) -> NonNegativeInteger + lllip : % -> List List List NonNegativeInteger + lllp : % -> List List List Point R + llprop : % -> List List SubSpaceComponentProperty + lp : % -> List Point R + lprop : % -> List SubSpaceComponentProperty + merge : List % -> % + merge : (%,%) -> % + mesh : % -> List List Point R + mesh : List List Point R -> % + mesh : (List List Point R,Boolean,Boolean) -> % + mesh : (%,List List List R,Boolean,Boolean) -> % + mesh : (%,List List Point R,Boolean,Boolean) -> % + mesh : (%,List List List R, + List SubSpaceComponentProperty, + SubSpaceComponentProperty) -> % + mesh : (%,List List Point R, + List SubSpaceComponentProperty, + SubSpaceComponentProperty) -> % + mesh? : % -> Boolean + modifyPointData : (%,NonNegativeInteger,Point R) -> % + numberOfComponents : % -> NonNegativeInteger + numberOfComposites : % -> NonNegativeInteger + objects : % -> + Record(points: NonNegativeInteger, + curves: NonNegativeInteger, + polygons: NonNegativeInteger, + constructs: NonNegativeInteger) + point : (%,Point R) -> % + point : (%,List R) -> % + point : (%,NonNegativeInteger) -> % + point : Point R -> % + point : % -> Point R + point? : % -> Boolean + polygon : (%,List Point R) -> % + polygon : (%,List List R) -> % + polygon : List Point R -> % + polygon : % -> List Point R + polygon? : % -> Boolean + subspace : % -> SubSpace(3,R) +\end{verbatim} + +These exports come from \refto{SetCategory}(): +\begin{verbatim} + hash : % -> SingleInteger + latex : % -> String + ?=? : (%,%) -> Boolean + ?~=? : (%,%) -> Boolean +\end{verbatim} + +<>= +)abbrev category SPACEC ThreeSpaceCategory +++ Author: +++ Date Created: +++ Date Last Updated: +++ Basic Operations: create3Space, numberOfComponents, numberOfComposites, +++ merge, composite, components, copy, enterPointData, modifyPointData, +++ point, point?, curve, curve?, closedCurve, closedCurve?, polygon, +++ polygon? mesh, mesh?, lp, lllip, lllp, llprop, lprop, objects, +++ check, subspace, coerce +++ Related Constructors: +++ Also See: +++ AMS Classifications: +++ Keywords: +++ References: +++ Description: The category ThreeSpaceCategory is used for creating +++ three dimensional objects using functions for defining points, curves, +++ polygons, constructs and the subspaces containing them. + +ThreeSpaceCategory(R:Ring): Exports == Implementation where + I ==> Integer + PI ==> PositiveInteger + NNI ==> NonNegativeInteger + L ==> List + B ==> Boolean + O ==> OutputForm + SUBSPACE ==> SubSpace(3,R) + POINT ==> Point(R) + PROP ==> SubSpaceComponentProperty() + REP3D ==> Record(lp:L POINT,llliPt:L L L NNI, llProp:L L PROP, lProp:L PROP) + OBJ3D ==> Record(points:NNI, curves:NNI, polygons:NNI, constructs:NNI) + + Exports ==> Category + Implementation ==> + SetCategory with + create3Space : () -> % + ++ create3Space() creates a \spadtype{ThreeSpace} object capable of + ++ holding point, curve, mesh components and any combination. + create3Space : SUBSPACE -> % + ++ create3Space(s) creates a \spadtype{ThreeSpace} object containing + ++ objects pre-defined within some \spadtype{SubSpace} s. + numberOfComponents : % -> NNI + ++ numberOfComponents(s) returns the number of distinct + ++ object components in the indicated \spadtype{ThreeSpace}, s, such + ++ as points, curves, polygons, and constructs. + numberOfComposites : % -> NNI + ++ numberOfComposites(s) returns the number of supercomponents, + ++ or composites, in the \spadtype{ThreeSpace}, s; Composites are + ++ arbitrary groupings of otherwise distinct and unrelated components; + ++ A \spadtype{ThreeSpace} need not have any composites defined at all + ++ and, outside of the requirement that no component can belong + ++ to more than one composite at a time, the definition and + ++ interpretation of composites are unrestricted. + merge : L % -> % + ++ merge([s1,s2,...,sn]) will create a new \spadtype{ThreeSpace} that + ++ has the components of all the ones in the list; Groupings of + ++ components into composites are maintained. + merge : (%,%) -> % + ++ merge(s1,s2) will create a new \spadtype{ThreeSpace} that has the + ++ components of \spad{s1} and \spad{s2}; Groupings of components + ++ into composites are maintained. + composite : L % -> % + ++ composite([s1,s2,...,sn]) will create a new \spadtype{ThreeSpace} + ++ that is a union of all the components from each + ++ \spadtype{ThreeSpace} in the parameter list, grouped as a composite. + components : % -> L % + ++ components(s) takes the \spadtype{ThreeSpace} s, and creates a list + ++ containing a unique \spadtype{ThreeSpace} for each single component + ++ of s. If s has no components defined, the list returned is empty. + composites : % -> L % + ++ composites(s) takes the \spadtype{ThreeSpace} s, and creates a list + ++ containing a unique \spadtype{ThreeSpace} for each single composite + ++ of s. If s has no composites defined (composites need to be + ++ explicitly created), the list returned is empty. Note that not all + ++ the components need to be part of a composite. + copy : % -> % + ++ copy(s) returns a new \spadtype{ThreeSpace} that is an exact copy + ++ of s. + enterPointData : (%,L POINT) -> NNI + ++ enterPointData(s,[p0,p1,...,pn]) adds a list of points from p0 + ++ through pn to the \spadtype{ThreeSpace}, s, and returns the index, + ++ to the starting point of the list; + modifyPointData : (%,NNI,POINT) -> % + ++ modifyPointData(s,i,p) changes the point at the indexed + ++ location i in the \spadtype{ThreeSpace}, s, to that of point p. + ++ This is useful for making changes to a point which has been + ++ transformed. + + -- 3D primitives + point : (%,POINT) -> % + ++ point(s,p) adds a point component defined by the point, p, + ++ specified as a list from \spad{List(R)}, to the + ++ \spadtype{ThreeSpace}, s, where R is the \spadtype{Ring} over + ++ which the point is defined. + point : (%,L R) -> % + ++ point(s,[x,y,z]) adds a point component defined by a list of + ++ elements which are from the \spad{PointDomain(R)} to the + ++ \spadtype{ThreeSpace}, s, where R is the \spadtype{Ring} over + ++ which the point elements are defined. + point : (%,NNI) -> % + ++ point(s,i) adds a point component which is placed into a component + ++ list of the \spadtype{ThreeSpace}, s, at the index given by i. + point : POINT -> % + ++ point(p) returns a \spadtype{ThreeSpace} object which is composed + ++ of one component, the point p. + point : % -> POINT + ++ point(s) checks to see if the \spadtype{ThreeSpace}, s, is + ++ composed of only a single point and if so, returns the point. + ++ An error is signaled otherwise. + point? : % -> B + ++ point?(s) queries whether the \spadtype{ThreeSpace}, s, is + ++ composed of a single component which is a point and returns the + ++ boolean result. + curve : (%,L POINT) -> % + ++ curve(s,[p0,p1,...,pn]) adds a space curve component defined by a + ++ list of points \spad{p0} through \spad{pn}, to the + ++ \spadtype{ThreeSpace} s. + curve : (%,L L R) -> % + ++ curve(s,[[p0],[p1],...,[pn]]) adds a space curve which is a list of + ++ points p0 through pn defined by lists of elements from the domain + ++ \spad{PointDomain(m,R)}, where R is the \spadtype{Ring} over which + ++ the point elements are defined and m is the dimension of the + ++ points, to the \spadtype{ThreeSpace} s. + curve : L POINT -> % + ++ curve([p0,p1,p2,...,pn]) creates a space curve defined + ++ by the list of points \spad{p0} through \spad{pn}, and returns the + ++ \spadtype{ThreeSpace} whose component is the curve. + curve : % -> L POINT + ++ curve(s) checks to see if the \spadtype{ThreeSpace}, s, is + ++ composed of a single curve defined by a list of points and if so, + ++ returns the curve, i.e., list of points. An error is signaled + ++ otherwise. + curve? : % -> B + ++ curve?(s) queries whether the \spadtype{ThreeSpace}, s, is a curve, + ++ i.e., has one component, a list of list of points, and returns + ++ true if it is, or false otherwise. + closedCurve : (%,L POINT) -> % + ++ closedCurve(s,[p0,p1,...,pn,p0]) adds a closed curve component + ++ which is a list of points defined by the first element p0 through + ++ the last element pn and back to the first element p0 again, to the + ++ \spadtype{ThreeSpace} s. + closedCurve : (%,L L R) -> % + ++ closedCurve(s,[[lr0],[lr1],...,[lrn],[lr0]]) adds a closed curve + ++ component defined by a list of points \spad{lr0} through + ++ \spad{lrn}, which are lists of elements from the domain + ++ \spad{PointDomain(m,R)}, where R is the \spadtype{Ring} over which + ++ the point elements are defined and m is the dimension of the + ++ points, in which the last element of the list of points contains + ++ a copy of the first element list, lr0. + ++ The closed curve is added to the \spadtype{ThreeSpace}, s. + closedCurve : L POINT -> % + ++ closedCurve(lp) sets a list of points defined by the first element + ++ of lp through the last element of lp and back to the first elelment + ++ again and returns a \spadtype{ThreeSpace} whose component is the + ++ closed curve defined by lp. + closedCurve : % -> L POINT + ++ closedCurve(s) checks to see if the \spadtype{ThreeSpace}, s, is + ++ composed of a single closed curve component defined by a list of + ++ points in which the first point is also the last point, all of + ++ which are from the domain \spad{PointDomain(m,R)} and if so, + ++ returns the list of points. An error is signaled otherwise. + closedCurve? : % -> B + ++ closedCurve?(s) returns true if the \spadtype{ThreeSpace} s + ++ contains a single closed curve component, i.e., the first element + ++ of the curve is also the last element, or false otherwise. + polygon : (%,L POINT) -> % + ++ polygon(s,[p0,p1,...,pn]) adds a polygon component defined by a + ++ list of points, p0 throught pn, to the \spadtype{ThreeSpace} s. + polygon : (%,L L R) -> % + ++ polygon(s,[[r0],[r1],...,[rn]]) adds a polygon component defined + ++ by a list of points \spad{r0} through \spad{rn}, which are lists of + ++ elements from the domain \spad{PointDomain(m,R)} to the + ++ \spadtype{ThreeSpace} s, where m is the dimension of the points + ++ and R is the \spadtype{Ring} over which the points are defined. + polygon : L POINT -> % + ++ polygon([p0,p1,...,pn]) creates a polygon defined by a list of + ++ points, p0 through pn, and returns a \spadtype{ThreeSpace} whose + ++ component is the polygon. + polygon : % -> L POINT + ++ polygon(s) checks to see if the \spadtype{ThreeSpace}, s, is + ++ composed of a single polygon component defined by a list of + ++ points, and if so, returns the list of points; An error is + ++ signaled otherwise. + polygon? : % -> B + ++ polygon?(s) returns true if the \spadtype{ThreeSpace} s contains + ++ a single polygon component, or false otherwise. + mesh : (%,L L POINT,L PROP,PROP) -> % + ++ mesh(s,[[p0],[p1],...,[pn]],[props],prop) adds a surface component, + ++ defined over a list curves which contains lists of points, to the + ++ \spadtype{ThreeSpace} s; props is a list which contains the + ++ subspace component properties for each surface parameter, and + ++ prop is the subspace component property by which the points are + ++ defined. + mesh : (%,L L L R,L PROP,PROP) -> % + ++ mesh(s,[ [[r10]...,[r1m]],[[r20]...,[r2m]],...,[[rn0]...,[rnm]] ], + ++ [props], prop) + ++ adds a surface component to the \spadtype{ThreeSpace} s, which is + ++ defined over a rectangular domain of size WxH where W is the number + ++ of lists of points from the domain \spad{PointDomain(R)} and H is + ++ the number of elements in each of those lists; lprops is the list + ++ of the subspace component properties for each curve list, and + ++ prop is the subspace component property by which the points are + ++ defined. + mesh : (%,L L POINT,B,B) -> % + ++ mesh(s,[[p0],[p1],...,[pn]], close1, close2) adds a surface + ++ component to the \spadtype{ThreeSpace}, which is defined over a + ++ list of curves, in which each of these curves is a list of points. + ++ The boolean arguments close1 and close2 indicate how the surface + ++ is to be closed. Argument close1 equal true + ++ means that each individual list (a curve) is to be closed, i.e. the + ++ last point of the list is to be connected to the first point. + ++ Argument close2 equal true + ++ means that the boundary at one end of the surface is to be + ++ connected to the boundary at the other end, i.e. the boundaries + ++ are defined as the first list of points (curve) and + ++ the last list of points (curve). + mesh : (%,L L L R,B,B) -> % + ++ mesh(s,[ [[r10]...,[r1m]],[[r20]...,[r2m]],...,[[rn0]...,[rnm]] ], + ++ close1, close2) + ++ adds a surface component to the \spadtype{ThreeSpace} s, which is + ++ defined over a rectangular domain of size WxH where W is the number + ++ of lists of points from the domain \spad{PointDomain(R)} and H is + ++ the number of elements in each of those lists; the booleans close1 + ++ and close2 indicate how the surface is to be closed: if close1 is + ++ true this means that each individual list (a curve) is to be + ++ closed (i.e., + ++ the last point of the list is to be connected to the first point); + ++ if close2 is true, this means that the boundary at one end of the + ++ surface is to be connected to the boundary at the other end + ++ (the boundaries are defined as the first list of points (curve) + ++ and the last list of points (curve)). + mesh : L L POINT -> % + ++ mesh([[p0],[p1],...,[pn]]) creates a surface defined by a list of + ++ curves which are lists, p0 through pn, of points, and returns a + ++ \spadtype{ThreeSpace} whose component is the surface. + mesh : (L L POINT,B,B) -> % + ++ mesh([[p0],[p1],...,[pn]], close1, close2) creates a surface + ++ defined over a list of curves, p0 through pn, which are lists of + ++ points; the booleans close1 and close2 indicate how the surface is + ++ to be closed: close1 set to true means that each individual list + ++ (a curve) is to be closed (that is, the last point of the list is + ++ to be connected to the first point); close2 set to true means + ++ that the boundary at one end of the surface is to be connected to + ++ the boundary at the other end (the boundaries are defined as the + ++ first list of points (curve) and the last list of points (curve)); + ++ the \spadtype{ThreeSpace} containing this surface is returned. + mesh : % -> L L POINT + ++ mesh(s) checks to see if the \spadtype{ThreeSpace}, s, is + ++ composed of a single surface component defined by a list curves + ++ which contain lists of points, and if so, returns the list of + ++ lists of points; An error is signaled otherwise. + mesh? : % -> B + ++ mesh?(s) returns true if the \spadtype{ThreeSpace} s is composed + ++ of one component, a mesh comprising a list of curves which are lists + ++ of points, or returns false if otherwise + lp : % -> L POINT + ++ lp(s) returns the list of points component which the + ++ \spadtype{ThreeSpace}, s, contains; these points are used by + ++ reference, i.e., the component holds indices referring to the + ++ points rather than the points themselves. This allows for sharing + ++ of the points. + lllip : % -> L L L NNI + ++ lllip(s) checks to see if the \spadtype{ThreeSpace}, s, is + ++ composed of a list of components, which are lists of curves, + ++ which are lists of indices to points, and if so, returns the list + ++ of lists of lists; An error is signaled otherwise. + lllp : % -> L L L POINT -- used by view3D + ++ lllp(s) checks to see if the \spadtype{ThreeSpace}, s, is + ++ composed of a list of components, which are lists of curves, + ++ which are lists of points, and if so, returns the list of + ++ lists of lists; An error is signaled otherwise. + llprop : % -> L L PROP -- used by view3D + ++ llprop(s) checks to see if the \spadtype{ThreeSpace}, s, is + ++ composed of a list of curves which are lists of the + ++ subspace component properties of the curves, and if so, returns the + ++ list of lists; An error is signaled otherwise. + lprop : % -> L PROP -- used by view3D + ++ lprop(s) checks to see if the \spadtype{ThreeSpace}, s, is + ++ composed of a list of subspace component properties, and if so, + ++ returns the list; An error is signaled otherwise. + objects : % -> OBJ3D + ++ objects(s) returns the \spadtype{ThreeSpace}, s, in the form of a + ++ 3D object record containing information on the number of points, + ++ curves, polygons and constructs comprising the + ++ \spadtype{ThreeSpace}.. + check : % -> % -- used by mesh + ++ check(s) returns lllpt, list of lists of lists of point information + ++ about the \spadtype{ThreeSpace} s. + subspace : % -> SUBSPACE + ++ subspace(s) returns the \spadtype{SubSpace} which holds all the + ++ point information in the \spadtype{ThreeSpace}, s. + coerce : % -> O + ++ coerce(s) returns the \spadtype{ThreeSpace} s to Output format. + +@ +<>= +"SPACEC" + [color=lightblue,href="bookvol10.2.pdf#nameddest=SPACEC"]; +"SPACEC" -> "SETCAT" + +@ +<>= +"ThreeSpaceCategory(a:Ring)" + [color=lightblue,href="bookvol10.2.pdf#nameddest=SPACEC"]; +"ThreeSpaceCategory(a:Ring)" -> "SetCategory()" + +@ +<>= +digraph pic { + fontsize=10; + bgcolor="#FFFF66"; + node [shape=box, color=white, style=filled]; + +"ThreeSpaceCategory(a:Ring)" [color=lightblue]; +"ThreeSpaceCategory(a:Ring)" -> "SetCategory()" + +"SetCategory()" [color=lightblue]; +"SetCategory()" -> "BasicType()" +"SetCategory()" -> "CoercibleTo(OutputForm)" + +"BasicType()" [color=lightblue]; +"BasicType()" -> "Category" + +"CoercibleTo(OutputForm)" [color=seagreen]; +"CoercibleTo(OutputForm)" -> "CoercibleTo(a:Type)" + +"CoercibleTo(a:Type)" [color=lightblue]; +"CoercibleTo(a:Type)" -> "Category" + +"Category" [color=lightblue]; + +} + +@ \chapter{Category Layer 4} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \pagehead{AbelianMonoid}{ABELMON} @@ -6701,6 +7706,7 @@ digraph pic { \pagepic{ps/v102binaryrecursiveaggregate.ps}{BRAGG}{1.00} {\bf See:}\\ +\pageto{BinaryTreeCategory}{BTCAT} \pagefrom{RecursiveAggregate}{RCAGG} {\bf Exports:}\\ @@ -6956,6 +7962,11 @@ BinaryRecursiveAggregate(S:Type):Category == RecursiveAggregate S with [color=lightblue,href="bookvol10.2.pdf#nameddest=BRAGG"]; "BinaryRecursiveAggregate(a:Type)" -> "RecursiveAggregate(a:Type)" +"BinaryRecursiveAggregate(a:SetCategory)" + [color=seagreen,href="bookvol10.2.pdf#nameddest=BRAGG"]; +"BinaryRecursiveAggregate(a:SetCategory)" -> + "BinaryRecursiveAggregate(a:Type)" + @ <>= digraph pic { @@ -9774,6 +10785,232 @@ digraph pic { @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\pagehead{BinaryTreeCategory}{BTCAT} +\pagepic{ps/v102binarytreecategory.ps}{BTCAT}{1.00} + +{\bf See:}\\ +\pagefrom{BinaryRecursiveAggregate}{BRAGG} + +{\bf Exports:}\\ +\begin{tabular}{lllll} +\cross{BTCAT}{any?} & +\cross{BTCAT}{child?} & +\cross{BTCAT}{children} & +\cross{BTCAT}{coerce} & +\cross{BTCAT}{copy} \\ +\cross{BTCAT}{count} & +\cross{BTCAT}{count} & +\cross{BTCAT}{cyclic?} & +\cross{BTCAT}{distance} & +\cross{BTCAT}{empty} \\ +\cross{BTCAT}{empty?} & +\cross{BTCAT}{eq?} & +\cross{BTCAT}{eval} & +\cross{BTCAT}{every?} & +\cross{BTCAT}{hash} \\ +\cross{BTCAT}{latex} & +\cross{BTCAT}{leaf?} & +\cross{BTCAT}{leaves} & +\cross{BTCAT}{less?} & +\cross{BTCAT}{left} \\ +\cross{BTCAT}{map} & +\cross{BTCAT}{map!} & +\cross{BTCAT}{member?} & +\cross{BTCAT}{members} & +\cross{BTCAT}{more?} \\ +\cross{BTCAT}{node} & +\cross{BTCAT}{node?} & +\cross{BTCAT}{nodes} & +\cross{BTCAT}{parts} & +\cross{BTCAT}{right} \\ +\cross{BTCAT}{sample} & +\cross{BTCAT}{setchildren!} & +\cross{BTCAT}{setelt} & +\cross{BTCAT}{setleft!} & +\cross{BTCAT}{setright!} \\ +\cross{BTCAT}{setvalue!} & +\cross{BTCAT}{size?} & +\cross{BTCAT}{value} & +\cross{BTCAT}{\#?} & +\cross{BTCAT}{?=?} \\ +\cross{BTCAT}{?\~{}=?} & +\cross{BTCAT}{?.right} & +\cross{BTCAT}{?.left} & +\cross{BTCAT}{?.value} & +\end{tabular} + +{\bf Attributes Exported:} +\begin{itemize} +\item {\bf \cross{BTCAT}{finiteAggregate}} +is true if it is an aggregate with a finite number of elements. +\item {\bf \cross{BTCAT}{shallowlyMutable}} +is true if its values have immediate components that are +updateable (mutable). Note: the properties of any component +domain are irrevelant to the shallowlyMutable proper. +\item {\bf nil} +\end{itemize} + +These are directly exported but not implemented: +\begin{verbatim} + node : (%,S,%) -> % +\end{verbatim} + +These are implemented by this category: +\begin{verbatim} + copy : % -> % + map! : ((S -> S),%) -> % if $ has shallowlyMutable + #? : % -> NonNegativeInteger if $ has finiteAggregate +\end{verbatim} + +These exports come from \refto{BinaryRecursiveAggregate}(S:SetCategory): +\begin{verbatim} + any? : ((S -> Boolean),%) -> Boolean if $ has finiteAggregate + child? : (%,%) -> Boolean if S has SETCAT + children : % -> List % + coerce : % -> OutputForm if S has SETCAT + count : (S,%) -> NonNegativeInteger if S has SETCAT and $ has finiteAggregate + count : ((S -> Boolean),%) -> NonNegativeInteger if $ has finiteAggregate + cyclic? : % -> Boolean + distance : (%,%) -> Integer + empty : () -> % + empty? : % -> Boolean + eq? : (%,%) -> Boolean + eval : (%,List S,List S) -> % if S has EVALAB S and S has SETCAT + eval : (%,S,S) -> % if S has EVALAB S and S has SETCAT + eval : (%,Equation S) -> % if S has EVALAB S and S has SETCAT + eval : (%,List Equation S) -> % if S has EVALAB S and S has SETCAT + leaf? : % -> Boolean + leaves : % -> List S + left : % -> % + every? : ((S -> Boolean),%) -> Boolean if $ has finiteAggregate + hash : % -> SingleInteger if S has SETCAT + latex : % -> String if S has SETCAT + less? : (%,NonNegativeInteger) -> Boolean + map : ((S -> S),%) -> % + member? : (S,%) -> Boolean if S has SETCAT and $ has finiteAggregate + members : % -> List S if $ has finiteAggregate + more? : (%,NonNegativeInteger) -> Boolean + parts : % -> List S if $ has finiteAggregate + right : % -> % + sample : () -> % + setchildren! : (%,List %) -> % if $ has shallowlyMutable + setelt : (%,value,S) -> S if $ has shallowlyMutable + setelt : (%,right,%) -> % if $ has shallowlyMutable + setelt : (%,left,%) -> % if $ has shallowlyMutable + setleft! : (%,%) -> % if $ has shallowlyMutable + setright! : (%,%) -> % if $ has shallowlyMutable + setvalue! : (%,S) -> S if $ has shallowlyMutable + size? : (%,NonNegativeInteger) -> Boolean + value : % -> S + ?~=? : (%,%) -> Boolean if S has SETCAT + ?.value : (%,value) -> S + ?=? : (%,%) -> Boolean if S has SETCAT + ?.right : (%,right) -> % + ?.left : (%,left) -> % +\end{verbatim} + +<>= +)abbrev category BTCAT BinaryTreeCategory +++ Author:W. H. Burge +++ Date Created:17 Feb 1992 +++ Date Last Updated: +++ Basic Operations: +++ Related Domains: +++ Also See: +++ AMS Classifications: +++ Keywords: +++ Examples: +++ References: +++ Description: \spadtype{BinaryTreeCategory(S)} is the category of +++ binary trees: a tree which is either empty or else is a +++ \spadfun{node} consisting of a value and a \spadfun{left} and +++ \spadfun{right}, both binary trees. +BinaryTreeCategory(S: SetCategory): Category == _ + BinaryRecursiveAggregate(S) with + shallowlyMutable + ++ Binary trees have updateable components + finiteAggregate + ++ Binary trees have a finite number of components + node: (%,S,%) -> % + ++ node(left,v,right) creates a binary tree with value \spad{v}, a binary + ++ tree \spad{left}, and a binary tree \spad{right}. + ++ + add + cycleTreeMax ==> 5 + + copy t == + empty? t => empty() + node(copy left t, value t, copy right t) + + if % has shallowlyMutable then + map_!(f,t) == + empty? t => t + t.value := f(t.value) + map_!(f,left t) + map_!(f,right t) + t + + if % has finiteAggregate then + treeCount : (%, NonNegativeInteger) -> NonNegativeInteger + + #t == treeCount(t,0) + + treeCount(t,k) == + empty? t => k + k := k + 1 + k = cycleTreeMax and cyclic? t => error "cyclic binary tree" + k := treeCount(left t,k) + treeCount(right t,k) + +@ +<>= +"BTCAT" + [color=lightblue,href="bookvol10.2.pdf#nameddest=BTCAT"]; +"BTCAT" -> "BRAGG" + +@ +<>= +"BinaryTreeCategory(a:SetCategory)" + [color=lightblue,href="bookvol10.2.pdf#nameddest=BTCAT"]; +"BinaryTreeCategory(a:SetCategory)" -> + "BinaryRecursiveAggregate(a:SetCategory)" + +@ +<>= +digraph pic { + fontsize=10; + bgcolor="#FFFF66"; + node [shape=box, color=white, style=filled]; + +"BinaryTreeCategory(a:SetCategory)" [color=lightblue]; +"BinaryTreeCategory(a:SetCategory)" -> + "BinaryRecursiveAggregate(a:SetCategory)" + +"BinaryRecursiveAggregate(a:SetCategory)" + [color=seagreen,href="bookvol10.2.pdf#nameddest=BRAGG"]; +"BinaryRecursiveAggregate(a:SetCategory)" -> + "BinaryRecursiveAggregate(a:Type)" + +"BinaryRecursiveAggregate(a:Type)" [color=lightblue]; +"BinaryRecursiveAggregate(a:Type)" -> "RecursiveAggregate(a:Type)" + +"RecursiveAggregate(a:Type)" [color=lightblue]; +"RecursiveAggregate(a:Type)" -> "HomogeneousAggregate(a:Type)" + +"HomogeneousAggregate(a:Type)" [color=lightblue]; +"HomogeneousAggregate(a:Type)" -> "Aggregate()" + +"Aggregate()" [color=lightblue]; +"Aggregate()" -> "Type()" + +"Type()" [color=lightblue]; +"Type()" -> "Category" + +"Category" [color=lightblue]; +} + +@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \pagehead{Dictionary}{DIAGG} \pagepic{ps/v102dictionary.ps}{DIAGG}{1.00} @@ -11194,6 +12431,7 @@ digraph pic { \pagepic{ps/v102streamaggregate.ps}{STAGG}{0.50} {\bf See:}\\ +\pageto{LazyStreamAggregate}{LZSTAGG} \pagefrom{LinearAggregate}{LNAGG} \pagefrom{UnaryRecursiveAggregate}{URAGG} @@ -11396,24 +12634,24 @@ These exports come from \refto{UnaryRecursiveAggregate}(S:Type): These exports come from \refto{LinearAggregate}(S:Type): \begin{verbatim} construct : List S -> % + convert : % -> InputForm if S has KONVERT INFORM delete : (%,Integer) -> % + delete : (%,UniversalSegment Integer) -> % elt : (%,Integer,S) -> S + entry? : (S,%) -> Boolean + if $ has finiteAggregate + and S has SETCAT entries : % -> List S + find : ((S -> Boolean),%) -> Union(S,"failed") index? : (Integer,%) -> Boolean indices : % -> List Integer insert : (S,%,Integer) -> % insert : (%,%,Integer) -> % + maxIndex : % -> Integer if Integer has ORDSET map : (((S,S) -> S),%,%) -> % + minIndex : % -> Integer if Integer has ORDSET new : (NonNegativeInteger,S) -> % qelt : (%,Integer) -> S - convert : % -> InputForm if S has KONVERT INFORM - delete : (%,UniversalSegment Integer) -> % - entry? : (S,%) -> Boolean - if $ has finiteAggregate - and S has SETCAT - find : ((S -> Boolean),%) -> Union(S,"failed") - maxIndex : % -> Integer if Integer has ORDSET - minIndex : % -> Integer if Integer has ORDSET qsetelt! : (%,Integer,S) -> S if $ has shallowlyMutable reduce : (((S,S) -> S),%,S,S) -> S @@ -11581,651 +12819,9 @@ digraph pic { "..." [color=lightblue]; } -@ -\chapter{Category Layer 7} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\pagehead{NonAssociativeRng}{NARNG} -\pagepic{ps/v102nonassociativerng.ps}{NARNG}{1.00} - -{\bf See:}\\ -\pageto{NonAssociativeAlgebra}{NAALG} -\pageto{NonAssociativeRing}{NASRING} -\pagefrom{AbelianGroup}{ABELGRP} -\pagefrom{Monad}{MONAD} - -{\bf Exports:}\\ -\begin{tabular}{lllll} -\cross{NARNG}{0} & -\cross{NARNG}{antiCommutator} & -\cross{NARNG}{associator} & -\cross{NARNG}{coerce} & -\cross{NARNG}{commutator} \\ -\cross{NARNG}{hash} & -\cross{NARNG}{latex} & -\cross{NARNG}{leftPower} & -\cross{NARNG}{rightPower} & -\cross{NARNG}{sample} \\ -\cross{NARNG}{subtractIfCan} & -\cross{NARNG}{zero?} & -\cross{NARNG}{?*?} & -\cross{NARNG}{?**?} & -\cross{NARNG}{?+?} \\ -\cross{NARNG}{?-?} & -\cross{NARNG}{-?} & -\cross{NARNG}{?=?} & -\cross{NARNG}{?\~{}=?} & -\end{tabular} - -These are implemented by this category: -\begin{verbatim} - antiCommutator : (%,%) -> % - associator : (%,%,%) -> % - commutator : (%,%) -> % -\end{verbatim} - -These exports come from \refto{AbelianGroup}(): -\begin{verbatim} - 0 : () -> % - coerce : % -> OutputForm - hash : % -> SingleInteger - latex : % -> String - sample : () -> % - subtractIfCan : (%,%) -> Union(%,"failed") - zero? : % -> Boolean - ?~=? : (%,%) -> Boolean - ?*? : (PositiveInteger,%) -> % - ?+? : (%,%) -> % - ?=? : (%,%) -> Boolean - ?*? : (Integer,%) -> % - ?*? : (NonNegativeInteger,%) -> % - ?-? : (%,%) -> % - -? : % -> % -\end{verbatim} - -These exports come from \refto{Monad}(): -\begin{verbatim} - leftPower : (%,PositiveInteger) -> % - rightPower : (%,PositiveInteger) -> % - ?*? : (%,%) -> % - ?**? : (%,PositiveInteger) -> % -\end{verbatim} - -<>= -)abbrev category NARNG NonAssociativeRng -++ Author: J. Grabmeier, R. Wisbauer -++ Date Created: 01 March 1991 -++ Date Last Updated: 03 July 1991 -++ Basic Operations: +, *, -, ** -++ Related Constructors: Rng, Ring, NonAssociativeRing -++ Also See: -++ AMS Classifications: -++ Keywords: not associative ring -++ Reference: -++ R.D. Schafer: An Introduction to Nonassociative Algebras -++ Academic Press, New York, 1966 -++ Description: -++ NonAssociativeRng is a basic ring-type structure, not necessarily -++ commutative or associative, and not necessarily with unit. -++ Axioms -++ x*(y+z) = x*y + x*z -++ (x+y)*z = x*z + y*z -++ Common Additional Axioms -++ noZeroDivisors ab = 0 => a=0 or b=0 -NonAssociativeRng(): Category == Join(AbelianGroup,Monad) with - associator: (%,%,%) -> % - ++ associator(a,b,c) returns \spad{(a*b)*c-a*(b*c)}. - commutator: (%,%) -> % - ++ commutator(a,b) returns \spad{a*b-b*a}. - antiCommutator: (%,%) -> % - ++ antiCommutator(a,b) returns \spad{a*b+b*a}. - add - associator(x,y,z) == (x*y)*z - x*(y*z) - commutator(x,y) == x*y - y*x - antiCommutator(x,y) == x*y + y*x - -@ -<>= -"NARNG" - [color=lightblue,href="bookvol10.2.pdf#nameddest=NARNG"]; -"NARNG" -> "ABELGRP" -"NARNG" -> "MONAD" - -@ -<>= -"NonAssociativeRng()" - [color=lightblue,href="bookvol10.2.pdf#nameddest=NARNG"]; -"NonAssociativeRng()" -> "AbelianGroup()" -"NonAssociativeRng()" -> "Monad()" - -@ -<>= -digraph pic { - fontsize=10; - bgcolor="#FFFF66"; - node [shape=box, color=white, style=filled]; - -"NonAssociativeRng()" [color=lightblue]; -"NonAssociativeRng()" -> "AbelianGroup()" -"NonAssociativeRng()" -> "Monad()" - -"Monad()" [color=lightblue]; -"Monad()" -> "SETCAT..." -"Monad()" -> "REPSQ..." - -"AbelianGroup()" [color=lightblue]; -"AbelianGroup()" -> "CancellationAbelianMonoid()" -"AbelianGroup()" -> "REPDB..." - -"CancellationAbelianMonoid()" [color=lightblue]; -"CancellationAbelianMonoid()" -> "AbelianMonoid()" - -"AbelianMonoid()" [color=lightblue]; -"AbelianMonoid()" -> "AbelianSemiGroup()" - -"AbelianSemiGroup()" [color=lightblue]; -"AbelianSemiGroup()" -> "SETCAT..." -"AbelianSemiGroup()" -> "REPDB..." - -"REPDB..." [color="#00EE00"]; -"REPSQ..." [color="#00EE00"]; -"SETCAT..." [color=lightblue]; -} - -@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\pagehead{OneDimensionalArrayAggregate}{A1AGG} -\pagepic{ps/v102onedimensionalarrayaggregate.ps}{A1AGG}{1.00} - -{\bf See:}\\ -\pageto{BitAggregate}{BTAGG} -\pageto{StringAggregate}{SRAGG} -\pagefrom{FiniteLinearAggregate}{FLAGG} - -{\bf Exports:}\\ -\begin{tabular}{lllll} -\cross{A1AGG}{any?} & -\cross{A1AGG}{coerce} & -\cross{A1AGG}{concat} & -\cross{A1AGG}{construct} & -\cross{A1AGG}{convert} \\ -\cross{A1AGG}{copy} & -\cross{A1AGG}{copyInto!} & -\cross{A1AGG}{count} & -\cross{A1AGG}{delete} & -\cross{A1AGG}{elt} \\ -\cross{A1AGG}{empty} & -\cross{A1AGG}{empty?} & -\cross{A1AGG}{entries} & -\cross{A1AGG}{entry?} & -\cross{A1AGG}{eq?} \\ -\cross{A1AGG}{eval} & -\cross{A1AGG}{every?} & -\cross{A1AGG}{fill!} & -\cross{A1AGG}{find} & -\cross{A1AGG}{first} \\ -\cross{A1AGG}{hash} & -\cross{A1AGG}{index?} & -\cross{A1AGG}{indices} & -\cross{A1AGG}{insert} & -\cross{A1AGG}{latex} \\ -\cross{A1AGG}{less?} & -\cross{A1AGG}{map} & -\cross{A1AGG}{map!} & -\cross{A1AGG}{max} & -\cross{A1AGG}{maxIndex} \\ -\cross{A1AGG}{member?} & -\cross{A1AGG}{members} & -\cross{A1AGG}{merge} & -\cross{A1AGG}{min} & -\cross{A1AGG}{minIndex} \\ -\cross{A1AGG}{more?} & -\cross{A1AGG}{new} & -\cross{A1AGG}{parts} & -\cross{A1AGG}{position} & -\cross{A1AGG}{qelt} \\ -\cross{A1AGG}{qsetelt!} & -\cross{A1AGG}{reduce} & -\cross{A1AGG}{remove} & -\cross{A1AGG}{removeDuplicates} & -\cross{A1AGG}{reverse} \\ -\cross{A1AGG}{reverse!} & -\cross{A1AGG}{sample} & -\cross{A1AGG}{select} & -\cross{A1AGG}{setelt} & -\cross{A1AGG}{size?} \\ -\cross{A1AGG}{sort} & -\cross{A1AGG}{sort!} & -\cross{A1AGG}{sorted?} & -\cross{A1AGG}{swap!} & -\cross{A1AGG}{\#?} \\ -\cross{A1AGG}{?.?} & -\cross{A1AGG}{?$<$?} & -\cross{A1AGG}{?$<=$?} & -\cross{A1AGG}{?\~{}=?} & -\cross{A1AGG}{?=?} \\ -\cross{A1AGG}{?$>$?} & -\cross{A1AGG}{?$>=$?} &&& -\end{tabular} - -{\bf Attributes Exported:} -\begin{itemize} -\item {\bf \cross{A1AGG}{finiteAggregate}} -is true if it is an aggregate with a finite number of elements. -\item {\bf \cross{A1AGG}{shallowlyMutable}} -is true if its values have immediate components that are -updateable (mutable). Note: the properties of any component -domain are irrevelant to the shallowlyMutable proper. -\item {\bf nil} -\end{itemize} - -These are implemented by this category: -\begin{verbatim} - any? : ((S -> Boolean),%) -> Boolean - if $ has finiteAggregate - coerce : % -> OutputForm if S has SETCAT - concat : (%,%) -> % - concat : List % -> % - construct : List S -> % - copy : % -> % - copyInto! : (%,%,Integer) -> % if $ has shallowlyMutable - count : ((S -> Boolean),%) -> NonNegativeInteger - if $ has finiteAggregate - delete : (%,UniversalSegment Integer) -> % - delete : (%,Integer) -> % - every? : ((S -> Boolean),%) -> Boolean - if $ has finiteAggregate - find : ((S -> Boolean),%) -> Union(S,"failed") - insert : (%,%,Integer) -> % - map : (((S,S) -> S),%,%) -> % - map! : ((S -> S),%) -> % if $ has shallowlyMutable - merge : (((S,S) -> Boolean),%,%) -> % - parts : % -> List S if $ has finiteAggregate - position : ((S -> Boolean),%) -> Integer - position : (S,%,Integer) -> Integer - if S has SETCAT - reduce : (((S,S) -> S),%) -> S - if $ has finiteAggregate - reduce : (((S,S) -> S),%,S) -> S - if $ has finiteAggregate - reduce : (((S,S) -> S),%,S,S) -> S - if S has SETCAT and $ has finiteAggregate - reverse! : % -> % if $ has shallowlyMutable - setelt : (%,UniversalSegment Integer,S) -> S - if $ has shallowlyMutable - sort! : (((S,S) -> Boolean),%) -> % - if $ has shallowlyMutable - sorted? : (((S,S) -> Boolean),%) -> Boolean - ?.? : (%,UniversalSegment Integer) -> % - ?=? : (%,%) -> Boolean if S has SETCAT - ? Boolean if S has ORDSET -\end{verbatim} - -These exports come from \refto{FiniteLinearAggregate}(S:Type): -\begin{verbatim} - concat : (S,%) -> % - concat : (%,S) -> % - convert : % -> InputForm if S has KONVERT INFORM - count : (S,%) -> NonNegativeInteger - if S has SETCAT and $ has finiteAggregate - elt : (%,Integer,S) -> S - empty : () -> % - empty? : % -> Boolean - entries : % -> List S - entry? : (S,%) -> Boolean - if $ has finiteAggregate and S has SETCAT - eq? : (%,%) -> Boolean - eval : (%,List S,List S) -> % - if S has EVALAB S and S has SETCAT - eval : (%,S,S) -> % - if S has EVALAB S and S has SETCAT - eval : (%,Equation S) -> % - if S has EVALAB S and S has SETCAT - eval : (%,List Equation S) -> % - if S has EVALAB S and S has SETCAT - fill! : (%,S) -> % if $ has shallowlyMutable - first : % -> S if Integer has ORDSET - hash : % -> SingleInteger if S has SETCAT - index? : (Integer,%) -> Boolean - indices : % -> List Integer - insert : (S,%,Integer) -> % - latex : % -> String if S has SETCAT - less? : (%,NonNegativeInteger) -> Boolean - map : ((S -> S),%) -> % - max : (%,%) -> % if S has ORDSET - maxIndex : % -> Integer if Integer has ORDSET - member? : (S,%) -> Boolean - if S has SETCAT and $ has finiteAggregate - members : % -> List S if $ has finiteAggregate - merge : (%,%) -> % if S has ORDSET - min : (%,%) -> % if S has ORDSET - minIndex : % -> Integer if Integer has ORDSET - more? : (%,NonNegativeInteger) -> Boolean - new : (NonNegativeInteger,S) -> % - position : (S,%) -> Integer if S has SETCAT - qelt : (%,Integer) -> S - qsetelt! : (%,Integer,S) -> S - if $ has shallowlyMutable - remove : ((S -> Boolean),%) -> % - if $ has finiteAggregate - remove : (S,%) -> % - if S has SETCAT and $ has finiteAggregate - removeDuplicates : % -> % - if S has SETCAT and $ has finiteAggregate - reverse : % -> % - sample : () -> % - select : ((S -> Boolean),%) -> % - if $ has finiteAggregate - setelt : (%,Integer,S) -> S if $ has shallowlyMutable - size? : (%,NonNegativeInteger) -> Boolean - sort : % -> % if S has ORDSET - sort : (((S,S) -> Boolean),%) -> % - sort! : % -> % - if S has ORDSET and $ has shallowlyMutable - sorted? : % -> Boolean if S has ORDSET - swap! : (%,Integer,Integer) -> Void - if $ has shallowlyMutable - #? : % -> NonNegativeInteger if $ has finiteAggregate - ?.? : (%,Integer) -> S - ?~=? : (%,%) -> Boolean if S has SETCAT - ?>? : (%,%) -> Boolean if S has ORDSET - ?>=? : (%,%) -> Boolean if S has ORDSET - ?<=? : (%,%) -> Boolean if S has ORDSET -\end{verbatim} - -<>= -)abbrev category A1AGG OneDimensionalArrayAggregate -++ Author: Michael Monagan; revised by Manuel Bronstein and Richard Jenks -++ Date Created: August 87 through August 88 -++ Date Last Updated: April 1991 -++ Basic Operations: -++ Related Constructors: -++ Also See: -++ AMS Classifications: -++ Keywords: -++ References: -++ Description: -++ One-dimensional-array aggregates serves as models for one-dimensional -++ arrays. Categorically, these aggregates are finite linear aggregates -++ with the \spadatt{shallowlyMutable} property, that is, any component of -++ the array may be changed without affecting the -++ identity of the overall array. -++ Array data structures are typically represented by a fixed area in -++ storage and cannot efficiently grow or shrink on demand as can list -++ structures (see however \spadtype{FlexibleArray} for a data structure -++ which is a cross between a list and an array). -++ Iteration over, and access to, elements of arrays is extremely fast -++ (and often can be optimized to open-code). -++ Insertion and deletion however is generally slow since an entirely new -++ data structure must be created for the result. -OneDimensionalArrayAggregate(S:Type): Category == - FiniteLinearAggregate S with shallowlyMutable - add - parts x == [qelt(x, i) for i in minIndex x .. maxIndex x] - sort_!(f, a) == quickSort(f, a)$FiniteLinearAggregateSort(S, %) - - any?(f, a) == - for i in minIndex a .. maxIndex a repeat - f qelt(a, i) => return true - false - - every?(f, a) == - for i in minIndex a .. maxIndex a repeat - not(f qelt(a, i)) => return false - true - - position(f:S -> Boolean, a:%) == - for i in minIndex a .. maxIndex a repeat - f qelt(a, i) => return i - minIndex(a) - 1 - - find(f, a) == - for i in minIndex a .. maxIndex a repeat - f qelt(a, i) => return qelt(a, i) - "failed" - - count(f:S->Boolean, a:%) == - n:NonNegativeInteger := 0 - for i in minIndex a .. maxIndex a repeat - if f(qelt(a, i)) then n := n+1 - n - - map_!(f, a) == - for i in minIndex a .. maxIndex a repeat - qsetelt_!(a, i, f qelt(a, i)) - a - - setelt(a:%, s:UniversalSegment(Integer), x:S) == - l := lo s; h := if hasHi s then hi s else maxIndex a - l < minIndex a or h > maxIndex a => error "index out of range" - for k in l..h repeat qsetelt_!(a, k, x) - x - - reduce(f, a) == - empty? a => error "cannot reduce an empty aggregate" - r := qelt(a, m := minIndex a) - for k in m+1 .. maxIndex a repeat r := f(r, qelt(a, k)) - r - - reduce(f, a, identity) == - for k in minIndex a .. maxIndex a repeat - identity := f(identity, qelt(a, k)) - identity - - if S has SetCategory then - reduce(f, a, identity,absorber) == - for k in minIndex a .. maxIndex a while identity ^= absorber - repeat identity := f(identity, qelt(a, k)) - identity - --- this is necessary since new has disappeared. - stupidnew: (NonNegativeInteger, %, %) -> % - stupidget: List % -> S --- a and b are not both empty if n > 0 - stupidnew(n, a, b) == - zero? n => empty() - new(n, (empty? a => qelt(b, minIndex b); qelt(a, minIndex a))) --- at least one element of l must be non-empty - stupidget l == - for a in l repeat - not empty? a => return first a - error "Should not happen" - - map(f, a, b) == - m := max(minIndex a, minIndex b) - n := min(maxIndex a, maxIndex b) - l := max(0, n - m + 1)::NonNegativeInteger - c := stupidnew(l, a, b) - for i in minIndex(c).. for j in m..n repeat - qsetelt_!(c, i, f(qelt(a, j), qelt(b, j))) - c - --- map(f, a, b, x) == --- m := min(minIndex a, minIndex b) --- n := max(maxIndex a, maxIndex b) --- l := (n - m + 1)::NonNegativeInteger --- c := new l --- for i in minIndex(c).. for j in m..n repeat --- qsetelt_!(c, i, f(a(j, x), b(j, x))) --- c - - merge(f, a, b) == - r := stupidnew(#a + #b, a, b) - i := minIndex a - m := maxIndex a - j := minIndex b - n := maxIndex b - for k in minIndex(r).. while i <= m and j <= n repeat - if f(qelt(a, i), qelt(b, j)) then - qsetelt_!(r, k, qelt(a, i)) - i := i+1 - else - qsetelt_!(r, k, qelt(b, j)) - j := j+1 - for k in k.. for i in i..m repeat qsetelt_!(r, k, elt(a, i)) - for k in k.. for j in j..n repeat qsetelt_!(r, k, elt(b, j)) - r - - elt(a:%, s:UniversalSegment(Integer)) == - l := lo s - h := if hasHi s then hi s else maxIndex a - l < minIndex a or h > maxIndex a => error "index out of range" - r := stupidnew(max(0, h - l + 1)::NonNegativeInteger, a, a) - for k in minIndex r.. for i in l..h repeat - qsetelt_!(r, k, qelt(a, i)) - r - - insert(a:%, b:%, i:Integer) == - m := minIndex b - n := maxIndex b - i < m or i > n => error "index out of range" - y := stupidnew(#a + #b, a, b) - for k in minIndex y.. for j in m..i-1 repeat - qsetelt_!(y, k, qelt(b, j)) - for k in k.. for j in minIndex a .. maxIndex a repeat - qsetelt_!(y, k, qelt(a, j)) - for k in k.. for j in i..n repeat qsetelt_!(y, k, qelt(b, j)) - y - - copy x == - y := stupidnew(#x, x, x) - for i in minIndex x .. maxIndex x for j in minIndex y .. repeat - qsetelt_!(y, j, qelt(x, i)) - y - - copyInto_!(y, x, s) == - s < minIndex y or s + #x > maxIndex y + 1 => - error "index out of range" - for i in minIndex x .. maxIndex x for j in s.. repeat - qsetelt_!(y, j, qelt(x, i)) - y - - construct l == --- a := new(#l) - empty? l => empty() - a := new(#l, first l) - for i in minIndex(a).. for x in l repeat qsetelt_!(a, i, x) - a - - delete(a:%, s:UniversalSegment(Integer)) == - l := lo s; h := if hasHi s then hi s else maxIndex a - l < minIndex a or h > maxIndex a => error "index out of range" - h < l => copy a - r := stupidnew((#a - h + l - 1)::NonNegativeInteger, a, a) - for k in minIndex(r).. for i in minIndex a..l-1 repeat - qsetelt_!(r, k, qelt(a, i)) - for k in k.. for i in h+1 .. maxIndex a repeat - qsetelt_!(r, k, qelt(a, i)) - r - - delete(x:%, i:Integer) == - i < minIndex x or i > maxIndex x => error "index out of range" - y := stupidnew((#x - 1)::NonNegativeInteger, x, x) - for i in minIndex(y).. for j in minIndex x..i-1 repeat - qsetelt_!(y, i, qelt(x, j)) - for i in i .. for j in i+1 .. maxIndex x repeat - qsetelt_!(y, i, qelt(x, j)) - y - - reverse_! x == - m := minIndex x - n := maxIndex x - for i in 0..((n-m) quo 2) repeat swap_!(x, m+i, n-i) - x - - concat l == - empty? l => empty() - n := _+/[#a for a in l] - i := minIndex(r := new(n, stupidget l)) - for a in l repeat - copyInto_!(r, a, i) - i := i + #a - r - - sorted?(f, a) == - for i in minIndex(a)..maxIndex(a)-1 repeat - not f(qelt(a, i), qelt(a, i + 1)) => return false - true - - concat(x:%, y:%) == - z := stupidnew(#x + #y, x, y) - copyInto_!(z, x, i := minIndex z) - copyInto_!(z, y, i + #x) - z - - if S has SetCategory then - x = y == - #x ^= #y => false - for i in minIndex x .. maxIndex x repeat - not(qelt(x, i) = qelt(y, i)) => return false - true - - coerce(r:%):OutputForm == - bracket commaSeparate - [qelt(r, k)::OutputForm for k in minIndex r .. maxIndex r] - - position(x:S, t:%, s:Integer) == - n := maxIndex t - s < minIndex t or s > n => error "index out of range" - for k in s..n repeat - qelt(t, k) = x => return k - minIndex(t) - 1 - - if S has OrderedSet then - a < b == - for i in minIndex a .. maxIndex a - for j in minIndex b .. maxIndex b repeat - qelt(a, i) ^= qelt(b, j) => return a.i < b.j - #a < #b - - -@ -<>= -"A1AGG" [color=lightblue,href="bookvol10.2.pdf#nameddest=A1AGG"]; -"A1AGG" -> "FLAGG" - -@ -<>= -"OneDimensionalArrayAggregate(a:Type)" - [color=lightblue,href="bookvol10.2.pdf#nameddest=A1AGG"]; -"OneDimensionalArrayAggregate(a:Type)" -> - "FiniteLinearAggregate(a:Type)" - -"OneDimensionalArrayAggregate(Character)" - [color=seagreen,href="bookvol10.2.pdf#nameddest=A1AGG"]; -"OneDimensionalArrayAggregate(Character)" -> - "OneDimensionalArrayAggregate(a:Type)" - -"OneDimensionalArrayAggregate(Boolean)" - [color=seagreen,href="bookvol10.2.pdf#nameddest=A1AGG"]; -"OneDimensionalArrayAggregate(Boolean)" -> - "OneDimensionalArrayAggregate(a:Type)" - -@ -<>= -digraph pic { - fontsize=10; - bgcolor="#FFFF66"; - node [shape=box, color=white, style=filled]; - -"OneDimensionalArrayAggregate(a:Type)" [color=lightblue]; -"OneDimensionalArrayAggregate(a:Type)" -> - "FiniteLinearAggregate(a:Type)" - -"FiniteLinearAggregate(a:Type)" [color=lightblue]; -"FiniteLinearAggregate(a:Type)" -> "LinearAggregate(a:Type)" - -"LinearAggregate(a:Type)" [color=lightblue]; -"LinearAggregate(a:Type)" -> "IndexedAggregate(b:Integer,a:Type)" -"LinearAggregate(a:Type)" -> "CLAGG..." - -"IndexedAggregate(b:Integer,a:Type)" [color=seagreen]; -"IndexedAggregate(b:Integer,a:Type)" -> "IXAGG..." - -"CLAGG..." [color=lightblue]; -"IXAGG..." [color=lightblue]; -} @ +\chapter{Category Layer 7} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \pagehead{FiniteSetAggregate}{FSAGG} \pagepic{ps/v102finitesetaggregate.ps}{FSAGG}{0.75} @@ -12795,6 +13391,826 @@ digraph pic { @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\pagehead{LazyStreamAggregate}{LZSTAGG} +\pagepic{ps/v102lazystreamaggregate.ps}{LZSTAGG}{0.65} + +{\bf See:}\\ +\pagefrom{StreamAggregate}{STAGG} + +{\bf Exports:}\\ +\begin{tabular}{lllll} +\cross{LZSTAGG}{any?} & +\cross{LZSTAGG}{child?} & +\cross{LZSTAGG}{children} & +\cross{LZSTAGG}{coerce} \\ +\cross{LZSTAGG}{complete}& +\cross{LZSTAGG}{concat} & +\cross{LZSTAGG}{concat!} & +\cross{LZSTAGG}{construct} \\ +\cross{LZSTAGG}{copy} & +\cross{LZSTAGG}{convert} & +\cross{LZSTAGG}{count} & +\cross{LZSTAGG}{cycleEntry} \\ +\cross{LZSTAGG}{cycleLength} & +\cross{LZSTAGG}{cycleSplit!} & +\cross{LZSTAGG}{cycleTail} & +\cross{LZSTAGG}{cyclic?} \\ +\cross{LZSTAGG}{delete} & +\cross{LZSTAGG}{distance} & +\cross{LZSTAGG}{elt} & +\cross{LZSTAGG}{empty} \\ +\cross{LZSTAGG}{empty?} & +\cross{LZSTAGG}{entry?} & +\cross{LZSTAGG}{entries} & +\cross{LZSTAGG}{eq?} \\ +\cross{LZSTAGG}{explicitEntries?} & +\cross{LZSTAGG}{explicitlyEmpty?} & +\cross{LZSTAGG}{explicitlyFinite?} & +\cross{LZSTAGG}{extend} \\ +\cross{LZSTAGG}{eval} & +\cross{LZSTAGG}{every?} & +\cross{LZSTAGG}{fill!} & +\cross{LZSTAGG}{find} \\ +\cross{LZSTAGG}{first} & +\cross{LZSTAGG}{frst} & +\cross{LZSTAGG}{hash} & +\cross{LZSTAGG}{index?} \\ +\cross{LZSTAGG}{indices} & +\cross{LZSTAGG}{insert} & +\cross{LZSTAGG}{last} & +\cross{LZSTAGG}{latex} \\ +\cross{LZSTAGG}{lazy?} & +\cross{LZSTAGG}{lazyEvaluate} & +\cross{LZSTAGG}{leaf?} & +\cross{LZSTAGG}{leaves} \\ +\cross{LZSTAGG}{less?} & +\cross{LZSTAGG}{map} & +\cross{LZSTAGG}{map!} & +\cross{LZSTAGG}{maxIndex} \\ +\cross{LZSTAGG}{member?} & +\cross{LZSTAGG}{members} & +\cross{LZSTAGG}{minIndex} & +\cross{LZSTAGG}{more?} \\ +\cross{LZSTAGG}{new} & +\cross{LZSTAGG}{node?} & +\cross{LZSTAGG}{nodes} & +\cross{LZSTAGG}{numberOfComputedEntries} \\ +\cross{LZSTAGG}{parts} & +\cross{LZSTAGG}{possiblyInfinite?} & +\cross{LZSTAGG}{qelt} & +\cross{LZSTAGG}{qsetelt!} \\ +\cross{LZSTAGG}{reduce} & +\cross{LZSTAGG}{remove} & +\cross{LZSTAGG}{removeDuplicates} & +\cross{LZSTAGG}{rest} \\ +\cross{LZSTAGG}{rst} & +\cross{LZSTAGG}{sample} & +\cross{LZSTAGG}{second} & +\cross{LZSTAGG}{select} \\ +\cross{LZSTAGG}{setchildren!} & +\cross{LZSTAGG}{setelt} & +\cross{LZSTAGG}{setfirst!} & +\cross{LZSTAGG}{setlast!} \\ +\cross{LZSTAGG}{setrest!} & +\cross{LZSTAGG}{setvalue!} & +\cross{LZSTAGG}{size?} & +\cross{LZSTAGG}{split!} \\ +\cross{LZSTAGG}{swap!} & +\cross{LZSTAGG}{tail} & +\cross{LZSTAGG}{third} & +\cross{LZSTAGG}{value} \\ +\cross{LZSTAGG}{\#?} & +\cross{LZSTAGG}{?=?} & +\cross{LZSTAGG}{?.?} & +\cross{LZSTAGG}{?.last} \\ +\cross{LZSTAGG}{?.rest} & +\cross{LZSTAGG}{?.first} & +\cross{LZSTAGG}{?.value} & +\cross{LZSTAGG}{?\~{}=?} \\ +\end{tabular} + +{\bf Attributes exported:} +\begin{itemize} +\item {\bf nil} +\end{itemize} + +These are directly exported but not implemented: +\begin{verbatim} + explicitEntries? : % -> Boolean + explicitlyEmpty? : % -> Boolean + frst : % -> S + lazy? : % -> Boolean + lazyEvaluate : % -> % + numberOfComputedEntries : % -> NonNegativeInteger + remove : ((S -> Boolean),%) -> % + rst : % -> % + select : ((S -> Boolean),%) -> % +\end{verbatim} + +These are implemented by this category: +\begin{verbatim} + any? : ((S -> Boolean),%) -> Boolean + if $ has finiteAggregate + child? : (%,%) -> Boolean if S has SETCAT + children : % -> List % + complete : % -> % + construct : List S -> % + cycleEntry : % -> % + cycleLength : % -> NonNegativeInteger + cycleTail : % -> % + cyclic? : % -> Boolean + delete : (%,Integer) -> % + delete : (%,UniversalSegment Integer) -> % + distance : (%,%) -> Integer + elt : (%,Integer,S) -> S + entries : % -> List S + every? : ((S -> Boolean),%) -> Boolean + if $ has finiteAggregate + explicitlyFinite? : % -> Boolean + extend : (%,Integer) -> % + first : (%,NonNegativeInteger) -> % + index? : (Integer,%) -> Boolean + indices : % -> List Integer + insert : (S,%,Integer) -> % + insert : (%,%,Integer) -> % + last : % -> S + last : (%,NonNegativeInteger) -> % + leaf? : % -> Boolean + less? : (%,NonNegativeInteger) -> Boolean + maxIndex : % -> Integer if Integer has ORDSET + minIndex : % -> Integer if Integer has ORDSET + more? : (%,NonNegativeInteger) -> Boolean + node? : (%,%) -> Boolean if S has SETCAT + nodes : % -> List % + possiblyInfinite? : % -> Boolean + rest : % -> % + rest : (%,NonNegativeInteger) -> % + value : % -> S + size? : (%,NonNegativeInteger) -> Boolean + tail : % -> % + #? : % -> NonNegativeInteger if $ has finiteAggregate + ?=? : (%,%) -> Boolean if S has SETCAT + ?.? : (%,UniversalSegment Integer) -> % + ?.? : (%,Integer) -> S + ?.first : (%,first) -> S + ?.last : (%,last) -> S + ?.rest : (%,rest) -> % +\end{verbatim} + +These exports come from \refto{StreamAggregate}(S:Type): +\begin{verbatim} + coerce : % -> OutputForm if S has SETCAT + concat : (%,%) -> % + concat : (%,S) -> % + concat : (S,%) -> % + concat : List % -> % + concat! : (%,%) -> % if $ has shallowlyMutable + concat! : (%,S) -> % if $ has shallowlyMutable + convert : % -> InputForm if S has KONVERT INFORM + copy : % -> % + count : (S,%) -> NonNegativeInteger + if S has SETCAT + and $ has finiteAggregate + count : ((S -> Boolean),%) -> NonNegativeInteger + if $ has finiteAggregate + cycleSplit! : % -> % if $ has shallowlyMutable + empty : () -> % + empty? : % -> Boolean + entry? : (S,%) -> Boolean + if $ has finiteAggregate + and S has SETCAT + eq? : (%,%) -> Boolean + eval : (%,List S,List S) -> % + if S has EVALAB S + and S has SETCAT + eval : (%,S,S) -> % + if S has EVALAB S + and S has SETCAT + eval : (%,Equation S) -> % + if S has EVALAB S + and S has SETCAT + eval : (%,List Equation S) -> % + if S has EVALAB S + and S has SETCAT + fill! : (%,S) -> % if $ has shallowlyMutable + find : ((S -> Boolean),%) -> Union(S,"failed") + first : % -> S + hash : % -> SingleInteger if S has SETCAT + latex : % -> String if S has SETCAT + leaves : % -> List S + map : (((S,S) -> S),%,%) -> % + map : ((S -> S),%) -> % + map! : ((S -> S),%) -> % if $ has shallowlyMutable + member? : (S,%) -> Boolean + if S has SETCAT + and $ has finiteAggregate + members : % -> List S if $ has finiteAggregate + new : (NonNegativeInteger,S) -> % + parts : % -> List S if $ has finiteAggregate + qelt : (%,Integer) -> S + qsetelt! : (%,Integer,S) -> S if $ has shallowlyMutable + reduce : (((S,S) -> S),%,S,S) -> S + if S has SETCAT + and $ has finiteAggregate + reduce : (((S,S) -> S),%,S) -> S if $ has finiteAggregate + reduce : (((S,S) -> S),%) -> S if $ has finiteAggregate + remove : (S,%) -> % if S has SETCAT and $ has finiteAggregate + removeDuplicates : % -> % + if S has SETCAT + and $ has finiteAggregate + sample : () -> % + second : % -> S + setchildren! : (%,List %) -> % if $ has shallowlyMutable + setelt : (%,Integer,S) -> S if $ has shallowlyMutable + setelt : (%,UniversalSegment Integer,S) -> S + if $ has shallowlyMutable + setelt : (%,last,S) -> S if $ has shallowlyMutable + setelt : (%,rest,%) -> % if $ has shallowlyMutable + setelt : (%,first,S) -> S if $ has shallowlyMutable + setelt : (%,value,S) -> S if $ has shallowlyMutable + setfirst! : (%,S) -> S if $ has shallowlyMutable + setlast! : (%,S) -> S if $ has shallowlyMutable + setrest! : (%,%) -> % if $ has shallowlyMutable + setvalue! : (%,S) -> S if $ has shallowlyMutable + split! : (%,Integer) -> % if $ has shallowlyMutable + swap! : (%,Integer,Integer) -> Void if $ has shallowlyMutable + third : % -> S + ?.value : (%,value) -> S + ?~=? : (%,%) -> Boolean if S has SETCAT +\end{verbatim} + +<>= +)abbrev category LZSTAGG LazyStreamAggregate +++ Category of streams with lazy evaluation +++ Author: Clifton J. Williamson +++ Date Created: 22 November 1989 +++ Date Last Updated: 20 July 1990 +++ Keywords: stream, infinite list, infinite sequence +++ Description: +++ LazyStreamAggregate is the category of streams with lazy +++ evaluation. It is understood that the function 'empty?' will +++ cause lazy evaluation if necessary to determine if there are +++ entries. Functions which call 'empty?', e.g. 'first' and 'rest', +++ will also cause lazy evaluation if necessary. + +LazyStreamAggregate(S:Type): Category == StreamAggregate(S) with + remove: (S -> Boolean,%) -> % + ++ remove(f,st) returns a stream consisting of those elements of stream + ++ st which do not satisfy the predicate f. + ++ Note: \spad{remove(f,st) = [x for x in st | not f(x)]}. + ++ + ++X m:=[i for i in 1..] + ++X f(i:PositiveInteger):Boolean == even? i + ++X remove(f,m) + + select: (S -> Boolean,%) -> % + ++ select(f,st) returns a stream consisting of those elements of stream + ++ st satisfying the predicate f. + ++ Note: \spad{select(f,st) = [x for x in st | f(x)]}. + ++ + ++X m:=[i for i in 0..] + ++X select(x+->prime? x,m) + + explicitEntries?: % -> Boolean + ++ explicitEntries?(s) returns true if the stream s has + ++ explicitly computed entries, and false otherwise. + ++ + ++X m:=[i for i in 0..] + ++X explicitEntries? m + + explicitlyEmpty?: % -> Boolean + ++ explicitlyEmpty?(s) returns true if the stream is an + ++ (explicitly) empty stream. + ++ Note: this is a null test which will not cause lazy evaluation. + ++ + ++X m:=[i for i in 0..] + ++X explicitlyEmpty? m + + lazy?: % -> Boolean + ++ lazy?(s) returns true if the first node of the stream s + ++ is a lazy evaluation mechanism which could produce an + ++ additional entry to s. + ++ + ++X m:=[i for i in 0..] + ++X lazy? m + + lazyEvaluate: % -> % + ++ lazyEvaluate(s) causes one lazy evaluation of stream s. + ++ Caution: the first node must be a lazy evaluation mechanism + ++ (satisfies \spad{lazy?(s) = true}) as there is no error check. + ++ Note: a call to this function may + ++ or may not produce an explicit first entry + frst: % -> S + ++ frst(s) returns the first element of stream s. + ++ Caution: this function should only be called after a \spad{empty?} + ++ test has been made since there no error check. + ++ + ++X m:=[i for i in 0..] + ++X frst m + + rst: % -> % + ++ rst(s) returns a pointer to the next node of stream s. + ++ Caution: this function should only be called after a \spad{empty?} + ++ test has been made since there no error check. + ++ + ++X m:=[i for i in 0..] + ++X rst m + + numberOfComputedEntries: % -> NonNegativeInteger + ++ numberOfComputedEntries(st) returns the number of explicitly + ++ computed entries of stream st which exist immediately prior to the + ++ time this function is called. + ++ + ++X m:=[i for i in 0..] + ++X numberOfComputedEntries m + + extend: (%,Integer) -> % + ++ extend(st,n) causes entries to be computed, if necessary, + ++ so that 'st' will have at least 'n' explicit entries or so + ++ that all entries of 'st' will be computed if 'st' is finite + ++ with length <= n. + ++ + ++X m:=[i for i in 0..] + ++X numberOfComputedEntries m + ++X extend(m,20) + ++X numberOfComputedEntries m + + complete: % -> % + ++ complete(st) causes all entries of 'st' to be computed. + ++ this function should only be called on streams which are + ++ known to be finite. + ++ + ++X m:=[i for i in 1..] + ++X n:=filterUntil(i+->i>100,m) + ++X numberOfComputedEntries n + ++X complete n + ++X numberOfComputedEntries n + + add + + MIN ==> 1 -- minimal stream index + + I ==> Integer + NNI ==> NonNegativeInteger + L ==> List + U ==> UniversalSegment Integer + + indexx? : (Integer,%) -> Boolean + cycleElt : % -> Union(%,"failed") + computeCycleLength : % -> NNI + computeCycleEntry : (%,%) -> % + +--% SETCAT functions + + if S has SetCategory then + + x = y == + eq?(x,y) => true + explicitlyFinite? x and explicitlyFinite? y => + entries x = entries y + explicitEntries? x and explicitEntries? y => + frst x = frst y and EQ(rst x, rst y)$Lisp + -- treat cyclic streams + false + +--% HOAGG functions + + --null x == empty? x + + less?(x,n) == + n = 0 => false + empty? x => true + less?(rst x,(n-1) :: NNI) + + more?(x,n) == + empty? x => false + n = 0 => true + more?(rst x,(n-1) :: NNI) + + size?(x,n) == + empty? x => n = 0 + size?(rst x,(n-1) :: NNI) + + # x == + -- error if stream is not finite + y := x + for i in 0.. repeat + explicitlyEmpty? y => return i + lazy? y => error "#: infinite stream" + y := rst y + if odd? i then x := rst x + eq?(x,y) => error "#: infinite stream" + +--% CLAGG functions + + any?(f,x) == + -- error message only when x is a stream with lazy + -- evaluation and f(s) = false for all stream elements + -- 's' which have been computed when the function is + -- called + y := x + for i in 0.. repeat + explicitlyEmpty? y => return false + lazy? y => error "any?: infinite stream" + f frst y => return true + y := rst y + if odd? i then x := rst x + eq?(x,y) => return false + + every?(f,x) == + -- error message only when x is a stream with lazy + -- evaluation and f(s) = true for all stream elements + -- 's' which have been computed when the function is + -- called + y := x + for i in 0.. repeat + explicitlyEmpty? y => return true + lazy? y => error "every?: infinite stream" + not f frst y => return false + y := rst y + if odd? i then x := rst x + eq?(x,y) => return true + +-- following ops count and member? are only exported if $ has finiteAggregate + +-- count(f:S -> Boolean,x:%) == +-- -- error if stream is not finite +-- count : NNI := 0 +-- y := x +-- for i in 0.. repeat +-- explicitlyEmpty? y => return count +-- lazy? y => error "count: infinite stream" +-- if f frst y then count := count + 1 +-- y := rst y +-- if odd? i then x := rst x +-- eq?(x,y) => error "count: infinite stream" + + +-- if S has SetCategory then + +-- count(s:S,x:%) == count(#1 = s,x) +-- -- error if stream is not finite + +-- member?(s,x) == +-- -- error message only when x is a stream with lazy +-- -- evaluation and 's' is not among the stream elements +-- -- which have been computed when the function is called +-- y := x +-- for i in 0.. repeat +-- explicitlyEmpty? y => return false +-- lazy? y => error "member?: infinite stream" +-- frst y = s => return true +-- y := rst y +-- if odd? i then x := rst x +-- eq?(x,y) => return false + + entries x == + -- returns a list of elements which have been computed + -- error if infinite + y := x + l : L S := empty() + for i in 0.. repeat + explicitlyEmpty? y => return reverse_! l + lazy? y => error "infinite stream" + l := concat(frst y,l) + y := rst y + if odd? i then x := rst x + eq?(x,y) => error "infinite stream" + +--% CNAGG functions + + construct l == + empty? l => empty() + concat(first l, construct rest l) + + --entries x == + -- returns a list of the stream elements + -- error if the stream is not finite + --members x + +--% ELTAGG functions + + elt(x:%,n:I) == + n < MIN or empty? x => error "elt: no such element" + n = MIN => frst x + elt(rst x,n - 1) + + elt(x:%,n:I,s:S) == + n < MIN or empty? x => s + n = MIN => frst x + elt(rst x,n - 1) + +--% IXAGG functions + +-- following assumes % has finiteAggregate and S has SetCategory +-- entry?(s,x) == +-- -- error message only when x is a stream with lazy +-- -- evaluation and 's' is not among the stream elements +-- -- which have been computed when the function is called +-- member?(s,x) + + --entries x == + -- error if the stream is not finite + --members x + + indexx?(n,x) == + empty? x => false + n = MIN => true + indexx?(n-1,rst x) + + index?(n,x) == + -- returns 'true' iff 'n' is the index of an entry which + -- may or may not have been computed when the function is + -- called + -- additional entries are computed if necessary + n < MIN => false + indexx?(n,x) + + indices x == + -- error if stream is not finite + y := x + l : L I := empty() + for i in MIN.. repeat + explicitlyEmpty? y => return reverse_! l + lazy? y => error "indices: infinite stream" + l := concat(i,l) + y := rst y + if odd? i then x := rst x + eq?(x,y) => error "indices: infinite stream" + + maxIndex x == + -- error if stream is not finite + empty? x => + error "maxIndex: no maximal index for empty stream" + y := rst x + for i in MIN.. repeat + explicitlyEmpty? y => return i + lazy? y => error "maxIndex: infinite stream" + y := rst y + if odd? i then x := rst x + eq?(x,y) => error "maxIndex: infinite stream" + + minIndex x == + empty? x => error "minIndex: no minimal index for empty stream" + MIN + +--% LNAGG functions + + delete(x:%,n:I) == + -- non-destructive + not index?(n,x) => error "delete: index out of range" + concat(first(x,(n - MIN) :: NNI), rest(x,(n - MIN + 1) :: NNI)) + + delete(x:%,seg:U) == + low := lo seg + hasHi seg => + high := hi seg + high < low => copy x + (not index?(low,x)) or (not index?(high,x)) => + error "delete: index out of range" + concat(first(x,(low - MIN) :: NNI),rest(x,(high - MIN + 1) :: NNI)) + not index?(low,x) => error "delete: index out of range" + first(x,(low - MIN) :: NNI) + + elt(x:%,seg:U) == + low := lo seg + hasHi seg => + high := hi seg + high < low => empty() + (not index?(low,x)) or (not index?(high,x)) => + error "elt: index out of range" + first(rest(x,(low - MIN) :: NNI),(high - low + 1) :: NNI) + not index?(low,x) => error "elt: index out of range" + rest(x,(low - MIN) :: NNI) + + insert(s:S,x:%,n:I) == + not index?(n,x) => error "insert: index out of range" + nn := (n - MIN) :: NNI + concat([first(x,nn), concat(s, empty()), rest(x,nn)]) + + insert(y:%,x:%,n:I) == + not index?(n,x) => error "insert: index out of range" + nn := (n - MIN) :: NNI + concat([first(x,nn), y, rest(x,nn)]) + +--% RCAGG functions + + cycleElt x == cycleElt(x)$CyclicStreamTools(S,%) + + cyclic? x == + cycleElt(x) case "failed" => false + true + + if S has SetCategory then + child?(x,y) == + empty? y => error "child: no children" + x = rst y + + children x == + empty? x => error "children: no children" + [rst x] + + distance(x,z) == + y := x + for i in 0.. repeat + eq?(y,z) => return i + (explicitlyEmpty? y) or (lazy? y) => + error "distance: 2nd arg not a descendent of the 1st" + y := rst y + if odd? i then x := rst x + eq?(x,y) => + error "distance: 2nd arg not a descendent of the 1st" + + if S has SetCategory then + node?(z,x) == + -- error message only when x is a stream with lazy + -- evaluation and 'y' is not a node of 'x' + -- which has been computed when the function is called + y := x + for i in 0.. repeat + z = y => return true + explicitlyEmpty? y => return false + lazy? y => error "node?: infinite stream" + y := rst y + if odd? i then x := rst x + eq?(x,y) => return false + + nodes x == + y := x + l : L % := [] + for i in 0.. repeat + explicitlyEmpty? y => return reverse_! l + lazy? y => error "nodes: infinite stream" + l := concat(y,l) + y := rst y + if odd? i then x := rst x + eq?(x,y) => error "nodes: infinite stream" + l -- @#$%^& compiler + + leaf? x == empty? rest x + + value x == first x + +--% URAGG functions + + computeCycleLength cycElt == + computeCycleLength(cycElt)$CyclicStreamTools(S,%) + + computeCycleEntry(x,cycElt) == + computeCycleEntry(x,cycElt)$CyclicStreamTools(S,%) + + cycleEntry x == + cycElt := cycleElt x + cycElt case "failed" => + error "cycleEntry: non-cyclic stream" + computeCycleEntry(x,cycElt::%) + + cycleLength x == + cycElt := cycleElt x + cycElt case "failed" => + error "cycleLength: non-cyclic stream" + computeCycleLength(cycElt::%) + + cycleTail x == + cycElt := cycleElt x + cycElt case "failed" => + error "cycleTail: non-cyclic stream" + y := x := computeCycleEntry(x,cycElt::%) + z := rst x + repeat + eq?(x,z) => return y + y := z ; z := rst z + + elt(x,"first") == first x + + first(x,n) == + -- former name: take + n = 0 or empty? x => empty() + concat(frst x, first(rst x,(n-1) :: NNI)) + + rest x == + empty? x => error "Can't take the rest of an empty stream." + rst x + + elt(x,"rest") == rest x + + rest(x,n) == + -- former name: drop + n = 0 or empty? x => x + rest(rst x,(n-1) :: NNI) + + last x == + -- error if stream is not finite + empty? x => error "last: empty stream" + y1 := x + y2 := rst x + for i in 0.. repeat + explicitlyEmpty? y2 => return frst y1 + lazy? y2 => error "last: infinite stream" + y1 := y2 + y2 := rst y2 + if odd? i then x := rst x + eq?(x,y2) => error "last: infinite stream" + + if % has finiteAggregate then -- # is only defined for finiteAggregates + last(x,n) == + possiblyInfinite? x => error "last: infinite stream" + m := # x + m < n => error "last: index out of range" + copy rest(x,(m-n)::NNI) + + elt(x,"last") == last x + + tail x == + -- error if stream is not finite + empty? x => error "tail: empty stream" + y1 := x + y2 := rst x + for i in 0.. repeat + explicitlyEmpty? y2 => return y1 + lazy? y2 => error "tail: infinite stream" + y1 := y2 + y2 := rst y2 + if odd? i then x := rst x + eq?(x,y2) => error "tail: infinite stream" + +--% STAGG functions + + possiblyInfinite? x == + y := x + for i in 0.. repeat + explicitlyEmpty? y => return false + lazy? y => return true + if odd? i then x := rst x + y := rst y + eq?(x,y) => return true + + explicitlyFinite? x == not possiblyInfinite? x + +--% LZSTAGG functions + + extend(x,n) == + y := x + for i in 1..n while not empty? y repeat y := rst y + x + + complete x == + y := x + while not empty? y repeat y := rst y + x + +@ +<>= +"LZSTAGG" + [color=lightblue,href="bookvol10.2.pdf#nameddest=LZSTAGG"]; +"LZSTAGG" -> "STAGG" + +@ +<>= +"LazyStreamAggregate(a:Type)" + [color=lightblue,href="bookvol10.2.pdf#nameddest=LZSTAGG"]; +"LazyStreamAggregate(a:Type)" -> "StreamAggregate(a:Type)" + +@ +<>= +digraph pic { + fontsize=10; + bgcolor="#FFFF66"; + node [shape=box, color=white, style=filled]; + +"LazyStreamAggregate(a:Type)" [color=lightblue]; +"LazyStreamAggregate(a:Type)" -> "StreamAggregate(a:Type)" + +"StreamAggregate(a:Type)" [color=lightblue]; +"StreamAggregate(a:Type)" -> "UnaryRecursiveAggregate(a:Type)" +"StreamAggregate(a:Type)" -> "LinearAggregate(a:Type)" + +"UnaryRecursiveAggregate(a:Type)" [color=lightblue]; +"UnaryRecursiveAggregate(a:Type)" -> "RecursiveAggregate(a:Type)" + +"RecursiveAggregate(a:Type)" [color=lightblue]; +"RecursiveAggregate(a:Type)" -> "HOAGG..." + +"LinearAggregate(a:Type)" [color=lightblue]; +"LinearAggregate(a:Type)" -> "IndexedAggregate(b:Integer,a:Type)" +"LinearAggregate(a:Type)" -> "Collection(a:Type)" + +"IndexedAggregate(b:Integer,a:Type)" [color=seagreen]; +"IndexedAggregate(b:Integer,a:Type)" -> + "IndexedAggregate(a:SetCategory,b:Type)" + +"IndexedAggregate(a:SetCategory,b:Type)" [color=lightblue]; +"IndexedAggregate(a:SetCategory,b:Type)" -> "HOAGG..." + +"Collection(a:Type)" [color=lightblue]; +"Collection(a:Type)" -> "HOAGG..." + +"HOAGG..." [color=lightblue]; + +} + +@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \pagehead{LeftModule}{LMODULE} \pagepic{ps/v102leftmodule.ps}{LMODULE}{0.90} @@ -13702,6 +15118,649 @@ digraph pic { @ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\pagehead{NonAssociativeRng}{NARNG} +\pagepic{ps/v102nonassociativerng.ps}{NARNG}{1.00} + +{\bf See:}\\ +\pageto{NonAssociativeAlgebra}{NAALG} +\pageto{NonAssociativeRing}{NASRING} +\pagefrom{AbelianGroup}{ABELGRP} +\pagefrom{Monad}{MONAD} + +{\bf Exports:}\\ +\begin{tabular}{lllll} +\cross{NARNG}{0} & +\cross{NARNG}{antiCommutator} & +\cross{NARNG}{associator} & +\cross{NARNG}{coerce} & +\cross{NARNG}{commutator} \\ +\cross{NARNG}{hash} & +\cross{NARNG}{latex} & +\cross{NARNG}{leftPower} & +\cross{NARNG}{rightPower} & +\cross{NARNG}{sample} \\ +\cross{NARNG}{subtractIfCan} & +\cross{NARNG}{zero?} & +\cross{NARNG}{?*?} & +\cross{NARNG}{?**?} & +\cross{NARNG}{?+?} \\ +\cross{NARNG}{?-?} & +\cross{NARNG}{-?} & +\cross{NARNG}{?=?} & +\cross{NARNG}{?\~{}=?} & +\end{tabular} + +These are implemented by this category: +\begin{verbatim} + antiCommutator : (%,%) -> % + associator : (%,%,%) -> % + commutator : (%,%) -> % +\end{verbatim} + +These exports come from \refto{AbelianGroup}(): +\begin{verbatim} + 0 : () -> % + coerce : % -> OutputForm + hash : % -> SingleInteger + latex : % -> String + sample : () -> % + subtractIfCan : (%,%) -> Union(%,"failed") + zero? : % -> Boolean + ?~=? : (%,%) -> Boolean + ?*? : (PositiveInteger,%) -> % + ?+? : (%,%) -> % + ?=? : (%,%) -> Boolean + ?*? : (Integer,%) -> % + ?*? : (NonNegativeInteger,%) -> % + ?-? : (%,%) -> % + -? : % -> % +\end{verbatim} + +These exports come from \refto{Monad}(): +\begin{verbatim} + leftPower : (%,PositiveInteger) -> % + rightPower : (%,PositiveInteger) -> % + ?*? : (%,%) -> % + ?**? : (%,PositiveInteger) -> % +\end{verbatim} + +<>= +)abbrev category NARNG NonAssociativeRng +++ Author: J. Grabmeier, R. Wisbauer +++ Date Created: 01 March 1991 +++ Date Last Updated: 03 July 1991 +++ Basic Operations: +, *, -, ** +++ Related Constructors: Rng, Ring, NonAssociativeRing +++ Also See: +++ AMS Classifications: +++ Keywords: not associative ring +++ Reference: +++ R.D. Schafer: An Introduction to Nonassociative Algebras +++ Academic Press, New York, 1966 +++ Description: +++ NonAssociativeRng is a basic ring-type structure, not necessarily +++ commutative or associative, and not necessarily with unit. +++ Axioms +++ x*(y+z) = x*y + x*z +++ (x+y)*z = x*z + y*z +++ Common Additional Axioms +++ noZeroDivisors ab = 0 => a=0 or b=0 +NonAssociativeRng(): Category == Join(AbelianGroup,Monad) with + associator: (%,%,%) -> % + ++ associator(a,b,c) returns \spad{(a*b)*c-a*(b*c)}. + commutator: (%,%) -> % + ++ commutator(a,b) returns \spad{a*b-b*a}. + antiCommutator: (%,%) -> % + ++ antiCommutator(a,b) returns \spad{a*b+b*a}. + add + associator(x,y,z) == (x*y)*z - x*(y*z) + commutator(x,y) == x*y - y*x + antiCommutator(x,y) == x*y + y*x + +@ +<>= +"NARNG" + [color=lightblue,href="bookvol10.2.pdf#nameddest=NARNG"]; +"NARNG" -> "ABELGRP" +"NARNG" -> "MONAD" + +@ +<>= +"NonAssociativeRng()" + [color=lightblue,href="bookvol10.2.pdf#nameddest=NARNG"]; +"NonAssociativeRng()" -> "AbelianGroup()" +"NonAssociativeRng()" -> "Monad()" + +@ +<>= +digraph pic { + fontsize=10; + bgcolor="#FFFF66"; + node [shape=box, color=white, style=filled]; + +"NonAssociativeRng()" [color=lightblue]; +"NonAssociativeRng()" -> "AbelianGroup()" +"NonAssociativeRng()" -> "Monad()" + +"Monad()" [color=lightblue]; +"Monad()" -> "SETCAT..." +"Monad()" -> "REPSQ..." + +"AbelianGroup()" [color=lightblue]; +"AbelianGroup()" -> "CancellationAbelianMonoid()" +"AbelianGroup()" -> "REPDB..." + +"CancellationAbelianMonoid()" [color=lightblue]; +"CancellationAbelianMonoid()" -> "AbelianMonoid()" + +"AbelianMonoid()" [color=lightblue]; +"AbelianMonoid()" -> "AbelianSemiGroup()" + +"AbelianSemiGroup()" [color=lightblue]; +"AbelianSemiGroup()" -> "SETCAT..." +"AbelianSemiGroup()" -> "REPDB..." + +"REPDB..." [color="#00EE00"]; +"REPSQ..." [color="#00EE00"]; +"SETCAT..." [color=lightblue]; +} + +@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\pagehead{OneDimensionalArrayAggregate}{A1AGG} +\pagepic{ps/v102onedimensionalarrayaggregate.ps}{A1AGG}{1.00} + +{\bf See:}\\ +\pageto{BitAggregate}{BTAGG} +\pageto{StringAggregate}{SRAGG} +\pagefrom{FiniteLinearAggregate}{FLAGG} + +{\bf Exports:}\\ +\begin{tabular}{lllll} +\cross{A1AGG}{any?} & +\cross{A1AGG}{coerce} & +\cross{A1AGG}{concat} & +\cross{A1AGG}{construct} & +\cross{A1AGG}{convert} \\ +\cross{A1AGG}{copy} & +\cross{A1AGG}{copyInto!} & +\cross{A1AGG}{count} & +\cross{A1AGG}{delete} & +\cross{A1AGG}{elt} \\ +\cross{A1AGG}{empty} & +\cross{A1AGG}{empty?} & +\cross{A1AGG}{entries} & +\cross{A1AGG}{entry?} & +\cross{A1AGG}{eq?} \\ +\cross{A1AGG}{eval} & +\cross{A1AGG}{every?} & +\cross{A1AGG}{fill!} & +\cross{A1AGG}{find} & +\cross{A1AGG}{first} \\ +\cross{A1AGG}{hash} & +\cross{A1AGG}{index?} & +\cross{A1AGG}{indices} & +\cross{A1AGG}{insert} & +\cross{A1AGG}{latex} \\ +\cross{A1AGG}{less?} & +\cross{A1AGG}{map} & +\cross{A1AGG}{map!} & +\cross{A1AGG}{max} & +\cross{A1AGG}{maxIndex} \\ +\cross{A1AGG}{member?} & +\cross{A1AGG}{members} & +\cross{A1AGG}{merge} & +\cross{A1AGG}{min} & +\cross{A1AGG}{minIndex} \\ +\cross{A1AGG}{more?} & +\cross{A1AGG}{new} & +\cross{A1AGG}{parts} & +\cross{A1AGG}{position} & +\cross{A1AGG}{qelt} \\ +\cross{A1AGG}{qsetelt!} & +\cross{A1AGG}{reduce} & +\cross{A1AGG}{remove} & +\cross{A1AGG}{removeDuplicates} & +\cross{A1AGG}{reverse} \\ +\cross{A1AGG}{reverse!} & +\cross{A1AGG}{sample} & +\cross{A1AGG}{select} & +\cross{A1AGG}{setelt} & +\cross{A1AGG}{size?} \\ +\cross{A1AGG}{sort} & +\cross{A1AGG}{sort!} & +\cross{A1AGG}{sorted?} & +\cross{A1AGG}{swap!} & +\cross{A1AGG}{\#?} \\ +\cross{A1AGG}{?.?} & +\cross{A1AGG}{?$<$?} & +\cross{A1AGG}{?$<=$?} & +\cross{A1AGG}{?\~{}=?} & +\cross{A1AGG}{?=?} \\ +\cross{A1AGG}{?$>$?} & +\cross{A1AGG}{?$>=$?} &&& +\end{tabular} + +{\bf Attributes Exported:} +\begin{itemize} +\item {\bf \cross{A1AGG}{finiteAggregate}} +is true if it is an aggregate with a finite number of elements. +\item {\bf \cross{A1AGG}{shallowlyMutable}} +is true if its values have immediate components that are +updateable (mutable). Note: the properties of any component +domain are irrevelant to the shallowlyMutable proper. +\item {\bf nil} +\end{itemize} + +These are implemented by this category: +\begin{verbatim} + any? : ((S -> Boolean),%) -> Boolean + if $ has finiteAggregate + coerce : % -> OutputForm if S has SETCAT + concat : (%,%) -> % + concat : List % -> % + construct : List S -> % + copy : % -> % + copyInto! : (%,%,Integer) -> % if $ has shallowlyMutable + count : ((S -> Boolean),%) -> NonNegativeInteger + if $ has finiteAggregate + delete : (%,UniversalSegment Integer) -> % + delete : (%,Integer) -> % + every? : ((S -> Boolean),%) -> Boolean + if $ has finiteAggregate + find : ((S -> Boolean),%) -> Union(S,"failed") + insert : (%,%,Integer) -> % + map : (((S,S) -> S),%,%) -> % + map! : ((S -> S),%) -> % if $ has shallowlyMutable + merge : (((S,S) -> Boolean),%,%) -> % + parts : % -> List S if $ has finiteAggregate + position : ((S -> Boolean),%) -> Integer + position : (S,%,Integer) -> Integer + if S has SETCAT + reduce : (((S,S) -> S),%) -> S + if $ has finiteAggregate + reduce : (((S,S) -> S),%,S) -> S + if $ has finiteAggregate + reduce : (((S,S) -> S),%,S,S) -> S + if S has SETCAT and $ has finiteAggregate + reverse! : % -> % if $ has shallowlyMutable + setelt : (%,UniversalSegment Integer,S) -> S + if $ has shallowlyMutable + sort! : (((S,S) -> Boolean),%) -> % + if $ has shallowlyMutable + sorted? : (((S,S) -> Boolean),%) -> Boolean + ?.? : (%,UniversalSegment Integer) -> % + ?=? : (%,%) -> Boolean if S has SETCAT + ? Boolean if S has ORDSET +\end{verbatim} + +These exports come from \refto{FiniteLinearAggregate}(S:Type): +\begin{verbatim} + concat : (S,%) -> % + concat : (%,S) -> % + convert : % -> InputForm if S has KONVERT INFORM + count : (S,%) -> NonNegativeInteger + if S has SETCAT and $ has finiteAggregate + elt : (%,Integer,S) -> S + empty : () -> % + empty? : % -> Boolean + entries : % -> List S + entry? : (S,%) -> Boolean + if $ has finiteAggregate and S has SETCAT + eq? : (%,%) -> Boolean + eval : (%,List S,List S) -> % + if S has EVALAB S and S has SETCAT + eval : (%,S,S) -> % + if S has EVALAB S and S has SETCAT + eval : (%,Equation S) -> % + if S has EVALAB S and S has SETCAT + eval : (%,List Equation S) -> % + if S has EVALAB S and S has SETCAT + fill! : (%,S) -> % if $ has shallowlyMutable + first : % -> S if Integer has ORDSET + hash : % -> SingleInteger if S has SETCAT + index? : (Integer,%) -> Boolean + indices : % -> List Integer + insert : (S,%,Integer) -> % + latex : % -> String if S has SETCAT + less? : (%,NonNegativeInteger) -> Boolean + map : ((S -> S),%) -> % + max : (%,%) -> % if S has ORDSET + maxIndex : % -> Integer if Integer has ORDSET + member? : (S,%) -> Boolean + if S has SETCAT and $ has finiteAggregate + members : % -> List S if $ has finiteAggregate + merge : (%,%) -> % if S has ORDSET + min : (%,%) -> % if S has ORDSET + minIndex : % -> Integer if Integer has ORDSET + more? : (%,NonNegativeInteger) -> Boolean + new : (NonNegativeInteger,S) -> % + position : (S,%) -> Integer if S has SETCAT + qelt : (%,Integer) -> S + qsetelt! : (%,Integer,S) -> S + if $ has shallowlyMutable + remove : ((S -> Boolean),%) -> % + if $ has finiteAggregate + remove : (S,%) -> % + if S has SETCAT and $ has finiteAggregate + removeDuplicates : % -> % + if S has SETCAT and $ has finiteAggregate + reverse : % -> % + sample : () -> % + select : ((S -> Boolean),%) -> % + if $ has finiteAggregate + setelt : (%,Integer,S) -> S if $ has shallowlyMutable + size? : (%,NonNegativeInteger) -> Boolean + sort : % -> % if S has ORDSET + sort : (((S,S) -> Boolean),%) -> % + sort! : % -> % + if S has ORDSET and $ has shallowlyMutable + sorted? : % -> Boolean if S has ORDSET + swap! : (%,Integer,Integer) -> Void + if $ has shallowlyMutable + #? : % -> NonNegativeInteger if $ has finiteAggregate + ?.? : (%,Integer) -> S + ?~=? : (%,%) -> Boolean if S has SETCAT + ?>? : (%,%) -> Boolean if S has ORDSET + ?>=? : (%,%) -> Boolean if S has ORDSET + ?<=? : (%,%) -> Boolean if S has ORDSET +\end{verbatim} + +<>= +)abbrev category A1AGG OneDimensionalArrayAggregate +++ Author: Michael Monagan; revised by Manuel Bronstein and Richard Jenks +++ Date Created: August 87 through August 88 +++ Date Last Updated: April 1991 +++ Basic Operations: +++ Related Constructors: +++ Also See: +++ AMS Classifications: +++ Keywords: +++ References: +++ Description: +++ One-dimensional-array aggregates serves as models for one-dimensional +++ arrays. Categorically, these aggregates are finite linear aggregates +++ with the \spadatt{shallowlyMutable} property, that is, any component of +++ the array may be changed without affecting the +++ identity of the overall array. +++ Array data structures are typically represented by a fixed area in +++ storage and cannot efficiently grow or shrink on demand as can list +++ structures (see however \spadtype{FlexibleArray} for a data structure +++ which is a cross between a list and an array). +++ Iteration over, and access to, elements of arrays is extremely fast +++ (and often can be optimized to open-code). +++ Insertion and deletion however is generally slow since an entirely new +++ data structure must be created for the result. +OneDimensionalArrayAggregate(S:Type): Category == + FiniteLinearAggregate S with shallowlyMutable + add + parts x == [qelt(x, i) for i in minIndex x .. maxIndex x] + sort_!(f, a) == quickSort(f, a)$FiniteLinearAggregateSort(S, %) + + any?(f, a) == + for i in minIndex a .. maxIndex a repeat + f qelt(a, i) => return true + false + + every?(f, a) == + for i in minIndex a .. maxIndex a repeat + not(f qelt(a, i)) => return false + true + + position(f:S -> Boolean, a:%) == + for i in minIndex a .. maxIndex a repeat + f qelt(a, i) => return i + minIndex(a) - 1 + + find(f, a) == + for i in minIndex a .. maxIndex a repeat + f qelt(a, i) => return qelt(a, i) + "failed" + + count(f:S->Boolean, a:%) == + n:NonNegativeInteger := 0 + for i in minIndex a .. maxIndex a repeat + if f(qelt(a, i)) then n := n+1 + n + + map_!(f, a) == + for i in minIndex a .. maxIndex a repeat + qsetelt_!(a, i, f qelt(a, i)) + a + + setelt(a:%, s:UniversalSegment(Integer), x:S) == + l := lo s; h := if hasHi s then hi s else maxIndex a + l < minIndex a or h > maxIndex a => error "index out of range" + for k in l..h repeat qsetelt_!(a, k, x) + x + + reduce(f, a) == + empty? a => error "cannot reduce an empty aggregate" + r := qelt(a, m := minIndex a) + for k in m+1 .. maxIndex a repeat r := f(r, qelt(a, k)) + r + + reduce(f, a, identity) == + for k in minIndex a .. maxIndex a repeat + identity := f(identity, qelt(a, k)) + identity + + if S has SetCategory then + reduce(f, a, identity,absorber) == + for k in minIndex a .. maxIndex a while identity ^= absorber + repeat identity := f(identity, qelt(a, k)) + identity + +-- this is necessary since new has disappeared. + stupidnew: (NonNegativeInteger, %, %) -> % + stupidget: List % -> S +-- a and b are not both empty if n > 0 + stupidnew(n, a, b) == + zero? n => empty() + new(n, (empty? a => qelt(b, minIndex b); qelt(a, minIndex a))) +-- at least one element of l must be non-empty + stupidget l == + for a in l repeat + not empty? a => return first a + error "Should not happen" + + map(f, a, b) == + m := max(minIndex a, minIndex b) + n := min(maxIndex a, maxIndex b) + l := max(0, n - m + 1)::NonNegativeInteger + c := stupidnew(l, a, b) + for i in minIndex(c).. for j in m..n repeat + qsetelt_!(c, i, f(qelt(a, j), qelt(b, j))) + c + +-- map(f, a, b, x) == +-- m := min(minIndex a, minIndex b) +-- n := max(maxIndex a, maxIndex b) +-- l := (n - m + 1)::NonNegativeInteger +-- c := new l +-- for i in minIndex(c).. for j in m..n repeat +-- qsetelt_!(c, i, f(a(j, x), b(j, x))) +-- c + + merge(f, a, b) == + r := stupidnew(#a + #b, a, b) + i := minIndex a + m := maxIndex a + j := minIndex b + n := maxIndex b + for k in minIndex(r).. while i <= m and j <= n repeat + if f(qelt(a, i), qelt(b, j)) then + qsetelt_!(r, k, qelt(a, i)) + i := i+1 + else + qsetelt_!(r, k, qelt(b, j)) + j := j+1 + for k in k.. for i in i..m repeat qsetelt_!(r, k, elt(a, i)) + for k in k.. for j in j..n repeat qsetelt_!(r, k, elt(b, j)) + r + + elt(a:%, s:UniversalSegment(Integer)) == + l := lo s + h := if hasHi s then hi s else maxIndex a + l < minIndex a or h > maxIndex a => error "index out of range" + r := stupidnew(max(0, h - l + 1)::NonNegativeInteger, a, a) + for k in minIndex r.. for i in l..h repeat + qsetelt_!(r, k, qelt(a, i)) + r + + insert(a:%, b:%, i:Integer) == + m := minIndex b + n := maxIndex b + i < m or i > n => error "index out of range" + y := stupidnew(#a + #b, a, b) + for k in minIndex y.. for j in m..i-1 repeat + qsetelt_!(y, k, qelt(b, j)) + for k in k.. for j in minIndex a .. maxIndex a repeat + qsetelt_!(y, k, qelt(a, j)) + for k in k.. for j in i..n repeat qsetelt_!(y, k, qelt(b, j)) + y + + copy x == + y := stupidnew(#x, x, x) + for i in minIndex x .. maxIndex x for j in minIndex y .. repeat + qsetelt_!(y, j, qelt(x, i)) + y + + copyInto_!(y, x, s) == + s < minIndex y or s + #x > maxIndex y + 1 => + error "index out of range" + for i in minIndex x .. maxIndex x for j in s.. repeat + qsetelt_!(y, j, qelt(x, i)) + y + + construct l == +-- a := new(#l) + empty? l => empty() + a := new(#l, first l) + for i in minIndex(a).. for x in l repeat qsetelt_!(a, i, x) + a + + delete(a:%, s:UniversalSegment(Integer)) == + l := lo s; h := if hasHi s then hi s else maxIndex a + l < minIndex a or h > maxIndex a => error "index out of range" + h < l => copy a + r := stupidnew((#a - h + l - 1)::NonNegativeInteger, a, a) + for k in minIndex(r).. for i in minIndex a..l-1 repeat + qsetelt_!(r, k, qelt(a, i)) + for k in k.. for i in h+1 .. maxIndex a repeat + qsetelt_!(r, k, qelt(a, i)) + r + + delete(x:%, i:Integer) == + i < minIndex x or i > maxIndex x => error "index out of range" + y := stupidnew((#x - 1)::NonNegativeInteger, x, x) + for i in minIndex(y).. for j in minIndex x..i-1 repeat + qsetelt_!(y, i, qelt(x, j)) + for i in i .. for j in i+1 .. maxIndex x repeat + qsetelt_!(y, i, qelt(x, j)) + y + + reverse_! x == + m := minIndex x + n := maxIndex x + for i in 0..((n-m) quo 2) repeat swap_!(x, m+i, n-i) + x + + concat l == + empty? l => empty() + n := _+/[#a for a in l] + i := minIndex(r := new(n, stupidget l)) + for a in l repeat + copyInto_!(r, a, i) + i := i + #a + r + + sorted?(f, a) == + for i in minIndex(a)..maxIndex(a)-1 repeat + not f(qelt(a, i), qelt(a, i + 1)) => return false + true + + concat(x:%, y:%) == + z := stupidnew(#x + #y, x, y) + copyInto_!(z, x, i := minIndex z) + copyInto_!(z, y, i + #x) + z + + if S has SetCategory then + x = y == + #x ^= #y => false + for i in minIndex x .. maxIndex x repeat + not(qelt(x, i) = qelt(y, i)) => return false + true + + coerce(r:%):OutputForm == + bracket commaSeparate + [qelt(r, k)::OutputForm for k in minIndex r .. maxIndex r] + + position(x:S, t:%, s:Integer) == + n := maxIndex t + s < minIndex t or s > n => error "index out of range" + for k in s..n repeat + qelt(t, k) = x => return k + minIndex(t) - 1 + + if S has OrderedSet then + a < b == + for i in minIndex a .. maxIndex a + for j in minIndex b .. maxIndex b repeat + qelt(a, i) ^= qelt(b, j) => return a.i < b.j + #a < #b + + +@ +<>= +"A1AGG" [color=lightblue,href="bookvol10.2.pdf#nameddest=A1AGG"]; +"A1AGG" -> "FLAGG" + +@ +<>= +"OneDimensionalArrayAggregate(a:Type)" + [color=lightblue,href="bookvol10.2.pdf#nameddest=A1AGG"]; +"OneDimensionalArrayAggregate(a:Type)" -> + "FiniteLinearAggregate(a:Type)" + +"OneDimensionalArrayAggregate(Character)" + [color=seagreen,href="bookvol10.2.pdf#nameddest=A1AGG"]; +"OneDimensionalArrayAggregate(Character)" -> + "OneDimensionalArrayAggregate(a:Type)" + +"OneDimensionalArrayAggregate(Boolean)" + [color=seagreen,href="bookvol10.2.pdf#nameddest=A1AGG"]; +"OneDimensionalArrayAggregate(Boolean)" -> + "OneDimensionalArrayAggregate(a:Type)" + +@ +<>= +digraph pic { + fontsize=10; + bgcolor="#FFFF66"; + node [shape=box, color=white, style=filled]; + +"OneDimensionalArrayAggregate(a:Type)" [color=lightblue]; +"OneDimensionalArrayAggregate(a:Type)" -> + "FiniteLinearAggregate(a:Type)" + +"FiniteLinearAggregate(a:Type)" [color=lightblue]; +"FiniteLinearAggregate(a:Type)" -> "LinearAggregate(a:Type)" + +"LinearAggregate(a:Type)" [color=lightblue]; +"LinearAggregate(a:Type)" -> "IndexedAggregate(b:Integer,a:Type)" +"LinearAggregate(a:Type)" -> "CLAGG..." + +"IndexedAggregate(b:Integer,a:Type)" [color=seagreen]; +"IndexedAggregate(b:Integer,a:Type)" -> "IXAGG..." + +"CLAGG..." [color=lightblue]; +"IXAGG..." [color=lightblue]; +} + +@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \pagehead{OrderedCancellationAbelianMonoid}{OCAMON} \pagepic{ps/v102orderedcancellationabelianmonoid.ps}{OCAMON}{0.75} @@ -38909,6 +40968,7 @@ Note that this code is not included in the generated catdef.spad file. <> <> <> +<> <> <> <> @@ -38931,6 +40991,7 @@ Note that this code is not included in the generated catdef.spad file. <> <> <> +<> <> <> <> @@ -38965,6 +41026,7 @@ Note that this code is not included in the generated catdef.spad file. <> <> <> +<> <> <> <> @@ -39001,10 +41063,14 @@ Note that this code is not included in the generated catdef.spad file. <> <> <> +<> +<> <> <> +<> <> <> +<> <> <> <> @@ -39043,6 +41109,7 @@ digraph dotabb { <> <> <> +<> <> <> <> @@ -39064,6 +41131,7 @@ digraph dotabb { <> <> <> +<> <> <> <> @@ -39097,6 +41165,7 @@ digraph dotabb { <> <> <> +<> <> <> <> @@ -39133,10 +41202,14 @@ digraph dotabb { <> <> <> +<> +<> <> <> +<> <> <> +<> <> <> <> @@ -39178,6 +41251,7 @@ digraph dotfull { <> <> <> +<> <> <> <> @@ -39199,6 +41273,7 @@ digraph dotfull { <> <> <> +<> <> <> <> @@ -39232,6 +41307,7 @@ digraph dotfull { <> <> <> +<> <> <> <> @@ -39268,10 +41344,14 @@ digraph dotfull { <> <> <> +<> +<> <> <> +<> <> <> +<> <> <> <> diff --git a/books/ps/v102binarytreecategory.ps b/books/ps/v102binarytreecategory.ps new file mode 100644 index 0000000..63de869 --- /dev/null +++ b/books/ps/v102binarytreecategory.ps @@ -0,0 +1,570 @@ +%!PS-Adobe-2.0 +%%Creator: dot version 2.8 (Thu Sep 14 20:34:11 UTC 2006) +%%For: (root) root +%%Title: pic +%%Pages: (atend) +%%BoundingBox: 36 36 302 584 +%%EndComments +save +%%BeginProlog +/DotDict 200 dict def +DotDict begin + +/setupLatin1 { +mark +/EncodingVector 256 array def + EncodingVector 0 + +ISOLatin1Encoding 0 255 getinterval putinterval +EncodingVector 45 /hyphen put + +% Set up ISO Latin 1 character encoding +/starnetISO { + dup dup findfont dup length dict begin + { 1 index /FID ne { def }{ pop pop } ifelse + } forall + /Encoding EncodingVector def + currentdict end definefont +} def +/Times-Roman starnetISO def +/Times-Italic starnetISO def +/Times-Bold starnetISO def +/Times-BoldItalic starnetISO def +/Helvetica starnetISO def +/Helvetica-Oblique starnetISO def +/Helvetica-Bold starnetISO def +/Helvetica-BoldOblique starnetISO def +/Courier starnetISO def +/Courier-Oblique starnetISO def +/Courier-Bold starnetISO def +/Courier-BoldOblique starnetISO def +cleartomark +} bind def + +%%BeginResource: procset graphviz 0 0 +/coord-font-family /Times-Roman def +/default-font-family /Times-Roman def +/coordfont coord-font-family findfont 8 scalefont def + +/InvScaleFactor 1.0 def +/set_scale { + dup 1 exch div /InvScaleFactor exch def + dup scale +} bind def + +% styles +/solid { [] 0 setdash } bind def +/dashed { [9 InvScaleFactor mul dup ] 0 setdash } bind def +/dotted { [1 InvScaleFactor mul 6 InvScaleFactor mul] 0 setdash } bind def +/invis {/fill {newpath} def /stroke {newpath} def /show {pop newpath} def} bind def +/bold { 2 setlinewidth } bind def +/filled { } bind def +/unfilled { } bind def +/rounded { } bind def +/diagonals { } bind def + +% hooks for setting color +/nodecolor { sethsbcolor } bind def +/edgecolor { sethsbcolor } bind def +/graphcolor { sethsbcolor } bind def +/nopcolor {pop pop pop} bind def + +/beginpage { % i j npages + /npages exch def + /j exch def + /i exch def + /str 10 string def + npages 1 gt { + gsave + coordfont setfont + 0 0 moveto + (\() show i str cvs show (,) show j str cvs show (\)) show + grestore + } if +} bind def + +/set_font { + findfont exch + scalefont setfont +} def + +% draw aligned label in bounding box aligned to current point +/alignedtext { % width adj text + /text exch def + /adj exch def + /width exch def + gsave + width 0 gt { + text stringwidth pop adj mul 0 rmoveto + } if + [] 0 setdash + text show + grestore +} def + +/boxprim { % xcorner ycorner xsize ysize + 4 2 roll + moveto + 2 copy + exch 0 rlineto + 0 exch rlineto + pop neg 0 rlineto + closepath +} bind def + +/ellipse_path { + /ry exch def + /rx exch def + /y exch def + /x exch def + matrix currentmatrix + newpath + x y translate + rx ry scale + 0 0 1 0 360 arc + setmatrix +} bind def + +/endpage { showpage } bind def +/showpage { } def + +/layercolorseq + [ % layer color sequence - darkest to lightest + [0 0 0] + [.2 .8 .8] + [.4 .8 .8] + [.6 .8 .8] + [.8 .8 .8] + ] +def + +/layerlen layercolorseq length def + +/setlayer {/maxlayer exch def /curlayer exch def + layercolorseq curlayer 1 sub layerlen mod get + aload pop sethsbcolor + /nodecolor {nopcolor} def + /edgecolor {nopcolor} def + /graphcolor {nopcolor} def +} bind def + +/onlayer { curlayer ne {invis} if } def + +/onlayers { + /myupper exch def + /mylower exch def + curlayer mylower lt + curlayer myupper gt + or + {invis} if +} def + +/curlayer 0 def + +%%EndResource +%%EndProlog +%%BeginSetup +14 default-font-family set_font +1 setmiterlimit +% /arrowlength 10 def +% /arrowwidth 5 def + +% make sure pdfmark is harmless for PS-interpreters other than Distiller +/pdfmark where {pop} {userdict /pdfmark /cleartomark load put} ifelse +% make '<<' and '>>' safe on PS Level 1 devices +/languagelevel where {pop languagelevel}{1} ifelse +2 lt { + userdict (<<) cvn ([) cvn load put + userdict (>>) cvn ([) cvn load put +} if + +%%EndSetup +%%Page: 1 1 +%%PageBoundingBox: 36 36 302 584 +%%PageOrientation: Portrait +gsave +36 36 266 548 boxprim clip newpath +36 36 translate +0 0 1 beginpage +1.0000 set_scale +4 4 translate 0 rotate +0.167 0.600 1.000 graphcolor +0.167 0.600 1.000 graphcolor +newpath -6 -6 moveto +-6 546 lineto +264 546 lineto +264 -6 lineto +closepath +fill +0.167 0.600 1.000 graphcolor +newpath -6 -6 moveto +-6 546 lineto +264 546 lineto +264 -6 lineto +closepath +stroke +0.000 0.000 0.000 graphcolor +14.00 /Times-Roman set_font +% BinaryTreeCategory(a:SetCategory) +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 239 540 moveto +19 540 lineto +19 504 lineto +239 504 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 239 540 moveto +19 540 lineto +19 504 lineto +239 504 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +26 517 moveto +(BinaryTreeCategory\(a:SetCategory\)) +[9.36 3.84 6.96 6.24 5.04 6.96 7.92 4.8 6.24 6.24 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6.96 4.56 6.24 3.84 7.68 6 3.84 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6.96 4.56] +xshow +end grestore +end grestore +% BinaryRecursiveAggregate(a:SetCategory) +[ /Rect [ 0 432 258 468 ] + /Border [ 0 0 0 ] + /Action << /Subtype /URI /URI (bookvol10.2.pdf#nameddest=BRAGG) >> + /Subtype /Link +/ANN pdfmark +gsave 10 dict begin +filled +0.404 0.667 0.545 nodecolor +0.404 0.667 0.545 nodecolor +newpath 258 468 moveto +0 468 lineto +0 432 lineto +258 432 lineto +closepath +fill +0.404 0.667 0.545 nodecolor +newpath 258 468 moveto +0 468 lineto +0 432 lineto +258 432 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +8 445 moveto +(BinaryRecursiveAggregate\(a:SetCategory\)) +[9.36 3.84 6.96 6.24 5.04 6.96 9.12 6.24 6.24 6.96 4.8 5.52 3.84 6.48 6.24 9.84 6.96 7.2 4.8 6.24 6.72 6.24 3.84 6.24 4.56 6.24 3.84 7.68 6 3.84 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6.96 4.56] +xshow +end grestore +end grestore +% BinaryTreeCategory(a:SetCategory)->BinaryRecursiveAggregate(a:SetCategory) +newpath 129 504 moveto +129 496 129 487 129 478 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 133 478 moveto +129 468 lineto +126 478 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 133 478 moveto +129 468 lineto +126 478 lineto +closepath +stroke +end grestore +% BinaryRecursiveAggregate(a:Type) +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 237 396 moveto +21 396 lineto +21 360 lineto +237 360 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 237 396 moveto +21 396 lineto +21 360 lineto +237 360 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +29 373 moveto +(BinaryRecursiveAggregate\(a:Type\)) +[9.36 3.84 6.96 6.24 5.04 6.96 9.12 6.24 6.24 6.96 4.8 5.52 3.84 6.48 6.24 9.84 6.96 7.2 4.8 6.24 6.72 6.24 3.84 6.24 4.56 6.24 3.84 7.2 6.96 6.96 6.24 4.56] +xshow +end grestore +end grestore +% BinaryRecursiveAggregate(a:SetCategory)->BinaryRecursiveAggregate(a:Type) +newpath 129 432 moveto +129 424 129 415 129 406 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 133 406 moveto +129 396 lineto +126 406 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 133 406 moveto +129 396 lineto +126 406 lineto +closepath +stroke +end grestore +% RecursiveAggregate(a:Type) +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 217 324 moveto +41 324 lineto +41 288 lineto +217 288 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 217 324 moveto +41 324 lineto +41 288 lineto +217 288 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +48 301 moveto +(RecursiveAggregate\(a:Type\)) +[9.12 6.24 6.24 6.96 4.8 5.52 3.84 6.48 6.24 9.84 6.96 7.2 4.8 6.24 6.72 6.24 3.84 6.24 4.56 6.24 3.84 7.2 6.96 6.96 6.24 4.56] +xshow +end grestore +end grestore +% BinaryRecursiveAggregate(a:Type)->RecursiveAggregate(a:Type) +newpath 129 360 moveto +129 352 129 343 129 334 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 133 334 moveto +129 324 lineto +126 334 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 133 334 moveto +129 324 lineto +126 334 lineto +closepath +stroke +end grestore +% HomogeneousAggregate(a:Type) +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 230 252 moveto +28 252 lineto +28 216 lineto +230 216 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 230 252 moveto +28 252 lineto +28 216 lineto +230 216 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +35 229 moveto +(HomogeneousAggregate\(a:Type\)) +[10.08 6.96 10.8 6.96 6.72 6.24 6.96 6.24 6.96 6.96 5.52 9.84 6.96 7.2 4.8 6.24 6.72 6.24 3.84 6.24 4.56 6.24 3.84 7.2 6.96 6.96 6.24 4.56] +xshow +end grestore +end grestore +% RecursiveAggregate(a:Type)->HomogeneousAggregate(a:Type) +newpath 129 288 moveto +129 280 129 271 129 262 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 133 262 moveto +129 252 lineto +126 262 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 133 262 moveto +129 252 lineto +126 262 lineto +closepath +stroke +end grestore +% Aggregate() +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 171 180 moveto +87 180 lineto +87 144 lineto +171 144 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 171 180 moveto +87 180 lineto +87 144 lineto +171 144 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +94 157 moveto +(Aggregate\(\)) +[9.84 6.96 7.2 4.8 6.24 6.72 6.24 3.84 6.24 4.56 4.56] +xshow +end grestore +end grestore +% HomogeneousAggregate(a:Type)->Aggregate() +newpath 129 216 moveto +129 208 129 199 129 190 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 133 190 moveto +129 180 lineto +126 190 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 133 190 moveto +129 180 lineto +126 190 lineto +closepath +stroke +end grestore +% Type() +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 156 108 moveto +102 108 lineto +102 72 lineto +156 72 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 156 108 moveto +102 108 lineto +102 72 lineto +156 72 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +110 85 moveto +(Type\(\)) +[7.2 6.96 6.96 6.24 4.56 4.56] +xshow +end grestore +end grestore +% Aggregate()->Type() +newpath 129 144 moveto +129 136 129 127 129 118 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 133 118 moveto +129 108 lineto +126 118 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 133 118 moveto +129 108 lineto +126 118 lineto +closepath +stroke +end grestore +% Category +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 163 36 moveto +95 36 lineto +95 0 lineto +163 0 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 163 36 moveto +95 36 lineto +95 0 lineto +163 0 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +103 13 moveto +(Category) +[9.36 6.24 3.84 6.24 6.96 6.96 5.04 6.96] +xshow +end grestore +end grestore +% Type()->Category +newpath 129 72 moveto +129 64 129 55 129 46 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 133 46 moveto +129 36 lineto +126 46 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 133 46 moveto +129 36 lineto +126 46 lineto +closepath +stroke +end grestore +endpage +showpage +grestore +%%PageTrailer +%%EndPage: 1 +%%Trailer +%%Pages: 1 +end +restore +%%EOF diff --git a/books/ps/v102fullyevalableover.ps b/books/ps/v102fullyevalableover.ps new file mode 100644 index 0000000..9806a63 --- /dev/null +++ b/books/ps/v102fullyevalableover.ps @@ -0,0 +1,571 @@ +%!PS-Adobe-2.0 +%%Creator: dot version 2.8 (Thu Sep 14 20:34:11 UTC 2006) +%%For: (root) root +%%Title: pic +%%Pages: (atend) +%%BoundingBox: 36 36 533 368 +%%EndComments +save +%%BeginProlog +/DotDict 200 dict def +DotDict begin + +/setupLatin1 { +mark +/EncodingVector 256 array def + EncodingVector 0 + +ISOLatin1Encoding 0 255 getinterval putinterval +EncodingVector 45 /hyphen put + +% Set up ISO Latin 1 character encoding +/starnetISO { + dup dup findfont dup length dict begin + { 1 index /FID ne { def }{ pop pop } ifelse + } forall + /Encoding EncodingVector def + currentdict end definefont +} def +/Times-Roman starnetISO def +/Times-Italic starnetISO def +/Times-Bold starnetISO def +/Times-BoldItalic starnetISO def +/Helvetica starnetISO def +/Helvetica-Oblique starnetISO def +/Helvetica-Bold starnetISO def +/Helvetica-BoldOblique starnetISO def +/Courier starnetISO def +/Courier-Oblique starnetISO def +/Courier-Bold starnetISO def +/Courier-BoldOblique starnetISO def +cleartomark +} bind def + +%%BeginResource: procset graphviz 0 0 +/coord-font-family /Times-Roman def +/default-font-family /Times-Roman def +/coordfont coord-font-family findfont 8 scalefont def + +/InvScaleFactor 1.0 def +/set_scale { + dup 1 exch div /InvScaleFactor exch def + dup scale +} bind def + +% styles +/solid { [] 0 setdash } bind def +/dashed { [9 InvScaleFactor mul dup ] 0 setdash } bind def +/dotted { [1 InvScaleFactor mul 6 InvScaleFactor mul] 0 setdash } bind def +/invis {/fill {newpath} def /stroke {newpath} def /show {pop newpath} def} bind def +/bold { 2 setlinewidth } bind def +/filled { } bind def +/unfilled { } bind def +/rounded { } bind def +/diagonals { } bind def + +% hooks for setting color +/nodecolor { sethsbcolor } bind def +/edgecolor { sethsbcolor } bind def +/graphcolor { sethsbcolor } bind def +/nopcolor {pop pop pop} bind def + +/beginpage { % i j npages + /npages exch def + /j exch def + /i exch def + /str 10 string def + npages 1 gt { + gsave + coordfont setfont + 0 0 moveto + (\() show i str cvs show (,) show j str cvs show (\)) show + grestore + } if +} bind def + +/set_font { + findfont exch + scalefont setfont +} def + +% draw aligned label in bounding box aligned to current point +/alignedtext { % width adj text + /text exch def + /adj exch def + /width exch def + gsave + width 0 gt { + text stringwidth pop adj mul 0 rmoveto + } if + [] 0 setdash + text show + grestore +} def + +/boxprim { % xcorner ycorner xsize ysize + 4 2 roll + moveto + 2 copy + exch 0 rlineto + 0 exch rlineto + pop neg 0 rlineto + closepath +} bind def + +/ellipse_path { + /ry exch def + /rx exch def + /y exch def + /x exch def + matrix currentmatrix + newpath + x y translate + rx ry scale + 0 0 1 0 360 arc + setmatrix +} bind def + +/endpage { showpage } bind def +/showpage { } def + +/layercolorseq + [ % layer color sequence - darkest to lightest + [0 0 0] + [.2 .8 .8] + [.4 .8 .8] + [.6 .8 .8] + [.8 .8 .8] + ] +def + +/layerlen layercolorseq length def + +/setlayer {/maxlayer exch def /curlayer exch def + layercolorseq curlayer 1 sub layerlen mod get + aload pop sethsbcolor + /nodecolor {nopcolor} def + /edgecolor {nopcolor} def + /graphcolor {nopcolor} def +} bind def + +/onlayer { curlayer ne {invis} if } def + +/onlayers { + /myupper exch def + /mylower exch def + curlayer mylower lt + curlayer myupper gt + or + {invis} if +} def + +/curlayer 0 def + +%%EndResource +%%EndProlog +%%BeginSetup +14 default-font-family set_font +1 setmiterlimit +% /arrowlength 10 def +% /arrowwidth 5 def + +% make sure pdfmark is harmless for PS-interpreters other than Distiller +/pdfmark where {pop} {userdict /pdfmark /cleartomark load put} ifelse +% make '<<' and '>>' safe on PS Level 1 devices +/languagelevel where {pop languagelevel}{1} ifelse +2 lt { + userdict (<<) cvn ([) cvn load put + userdict (>>) cvn ([) cvn load put +} if + +%%EndSetup +%%Page: 1 1 +%%PageBoundingBox: 36 36 533 368 +%%PageOrientation: Portrait +gsave +36 36 497 332 boxprim clip newpath +36 36 translate +0 0 1 beginpage +1.0000 set_scale +4 4 translate 0 rotate +0.167 0.600 1.000 graphcolor +0.167 0.600 1.000 graphcolor +newpath -6 -6 moveto +-6 330 lineto +495 330 lineto +495 -6 lineto +closepath +fill +0.167 0.600 1.000 graphcolor +newpath -6 -6 moveto +-6 330 lineto +495 330 lineto +495 -6 lineto +closepath +stroke +0.000 0.000 0.000 graphcolor +14.00 /Times-Roman set_font +% FullyEvalableOver(a:SetCategory) +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 426 324 moveto +216 324 lineto +216 288 lineto +426 288 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 426 324 moveto +216 324 lineto +216 288 lineto +426 288 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +224 301 moveto +(FullyEvalableOver\(a:SetCategory\)) +[7.44 6.96 3.84 3.6 6.96 8.64 6.72 6.24 3.84 6.24 6.96 3.84 6.24 10.08 6.48 6.24 4.8 4.56 6.24 3.84 7.68 6 3.84 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6.96 4.56] +xshow +end grestore +end grestore +% Eltable(a:SetCategory,b:SetCategory) +[ /Rect [ 0 216 226 252 ] + /Border [ 0 0 0 ] + /Action << /Subtype /URI /URI (bookvol10.2.pdf#nameddest=ELTAB) >> + /Subtype /Link +/ANN pdfmark +gsave 10 dict begin +filled +0.404 0.667 0.545 nodecolor +0.404 0.667 0.545 nodecolor +newpath 226 252 moveto +0 252 lineto +0 216 lineto +226 216 lineto +closepath +fill +0.404 0.667 0.545 nodecolor +newpath 226 252 moveto +0 252 lineto +0 216 lineto +226 216 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +7 229 moveto +(Eltable\(a:SetCategory,b:SetCategory\)) +[8.64 3.84 4.08 6.24 6.96 3.84 6.24 4.56 6.24 3.84 7.68 6 3.84 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6 3.6 6.96 3.84 7.68 6 3.84 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6.96 4.56] +xshow +end grestore +end grestore +% FullyEvalableOver(a:SetCategory)->Eltable(a:SetCategory,b:SetCategory) +newpath 269 288 moveto +240 278 205 266 175 255 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 176 252 moveto +165 252 lineto +174 258 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 176 252 moveto +165 252 lineto +174 258 lineto +closepath +stroke +end grestore +% Evalable(a:SetCategory) +[ /Rect [ 244 216 398 252 ] + /Border [ 0 0 0 ] + /Action << /Subtype /URI /URI (bookvol10.2.pdf#nameddest=EVALAB) >> + /Subtype /Link +/ANN pdfmark +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 398 252 moveto +244 252 lineto +244 216 lineto +398 216 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 398 252 moveto +244 252 lineto +244 216 lineto +398 216 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +252 229 moveto +(Evalable\(a:SetCategory\)) +[8.64 6.72 6.24 3.84 6.24 6.96 3.84 6.24 4.56 6.24 3.84 7.68 6 3.84 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6.96 4.56] +xshow +end grestore +end grestore +% FullyEvalableOver(a:SetCategory)->Evalable(a:SetCategory) +newpath 321 288 moveto +321 280 321 271 321 262 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 325 262 moveto +321 252 lineto +318 262 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 325 262 moveto +321 252 lineto +318 262 lineto +closepath +stroke +end grestore +% Category +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 370 36 moveto +302 36 lineto +302 0 lineto +370 0 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 370 36 moveto +302 36 lineto +302 0 lineto +370 0 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +310 13 moveto +(Category) +[9.36 6.24 3.84 6.24 6.96 6.96 5.04 6.96] +xshow +end grestore +end grestore +% FullyEvalableOver(a:SetCategory)->Category +newpath 356 288 moveto +391 267 443 230 460 180 curveto +466 161 464 83 457 72 curveto +439 46 407 33 380 26 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 381 23 moveto +370 23 lineto +379 29 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 381 23 moveto +370 23 lineto +379 29 lineto +closepath +stroke +end grestore +% Eltable(a:SetCategory,b:Type) +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 206 108 moveto +20 108 lineto +20 72 lineto +206 72 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 206 108 moveto +20 108 lineto +20 72 lineto +206 72 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +28 85 moveto +(Eltable\(a:SetCategory,b:Type\)) +[8.64 3.84 4.08 6.24 6.96 3.84 6.24 4.56 6.24 3.84 7.68 6 3.84 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6 3.6 6.96 3.84 7.2 6.96 6.96 6.24 4.56] +xshow +end grestore +end grestore +% Eltable(a:SetCategory,b:SetCategory)->Eltable(a:SetCategory,b:Type) +newpath 113 216 moveto +113 191 113 147 113 118 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 117 118 moveto +113 108 lineto +110 118 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 117 118 moveto +113 108 lineto +110 118 lineto +closepath +stroke +end grestore +% InnerEvalable(a:SetCategory,b:SetCategory) +gsave 10 dict begin +filled +0.404 0.667 0.545 nodecolor +0.404 0.667 0.545 nodecolor +newpath 451 180 moveto +185 180 lineto +185 144 lineto +451 144 lineto +closepath +fill +0.404 0.667 0.545 nodecolor +newpath 451 180 moveto +185 180 lineto +185 144 lineto +451 144 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +192 157 moveto +(InnerEvalable\(a:SetCategory,b:SetCategory\)) +[4.56 6.96 6.96 6.24 4.8 8.64 6.72 6.24 3.84 6.24 6.96 3.84 6.24 4.56 6.24 3.84 7.68 6 3.84 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6 3.6 6.96 3.84 7.68 6 3.84 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6.96 4.56] +xshow +end grestore +end grestore +% Evalable(a:SetCategory)->InnerEvalable(a:SetCategory,b:SetCategory) +newpath 320 216 moveto +319 208 319 199 319 190 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 323 190 moveto +319 180 lineto +316 190 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 323 190 moveto +319 180 lineto +316 190 lineto +closepath +stroke +end grestore +% Eltable(a:SetCategory,b:Type)->Category +newpath 169 72 moveto +207 60 257 44 292 32 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 293 35 moveto +302 29 lineto +291 29 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 293 35 moveto +302 29 lineto +291 29 lineto +closepath +stroke +end grestore +% InnerEvalable(a:SetCategory,b:Type) +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 448 108 moveto +224 108 lineto +224 72 lineto +448 72 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 448 108 moveto +224 108 lineto +224 72 lineto +448 72 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +231 85 moveto +(InnerEvalable\(a:SetCategory,b:Type\)) +[4.56 6.96 6.96 6.24 4.8 8.64 6.72 6.24 3.84 6.24 6.96 3.84 6.24 4.56 6.24 3.84 7.68 6 3.84 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6 3.6 6.96 3.84 7.2 6.96 6.96 6.24 4.56] +xshow +end grestore +end grestore +% InnerEvalable(a:SetCategory,b:SetCategory)->InnerEvalable(a:SetCategory,b:Type) +newpath 323 144 moveto +325 136 327 127 329 118 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 332 119 moveto +332 108 lineto +326 117 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 332 119 moveto +332 108 lineto +326 117 lineto +closepath +stroke +end grestore +% InnerEvalable(a:SetCategory,b:Type)->Category +newpath 336 72 moveto +336 64 336 55 336 46 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 340 46 moveto +336 36 lineto +333 46 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 340 46 moveto +336 36 lineto +333 46 lineto +closepath +stroke +end grestore +endpage +showpage +grestore +%%PageTrailer +%%EndPage: 1 +%%Trailer +%%Pages: 1 +end +restore +%%EOF diff --git a/books/ps/v102lazystreamaggregate.ps b/books/ps/v102lazystreamaggregate.ps new file mode 100644 index 0000000..bef5787 --- /dev/null +++ b/books/ps/v102lazystreamaggregate.ps @@ -0,0 +1,652 @@ +%!PS-Adobe-2.0 +%%Creator: dot version 2.8 (Thu Sep 14 20:34:11 UTC 2006) +%%For: (root) root +%%Title: pic +%%Pages: (atend) +%%BoundingBox: 36 36 598 440 +%%EndComments +save +%%BeginProlog +/DotDict 200 dict def +DotDict begin + +/setupLatin1 { +mark +/EncodingVector 256 array def + EncodingVector 0 + +ISOLatin1Encoding 0 255 getinterval putinterval +EncodingVector 45 /hyphen put + +% Set up ISO Latin 1 character encoding +/starnetISO { + dup dup findfont dup length dict begin + { 1 index /FID ne { def }{ pop pop } ifelse + } forall + /Encoding EncodingVector def + currentdict end definefont +} def +/Times-Roman starnetISO def +/Times-Italic starnetISO def +/Times-Bold starnetISO def +/Times-BoldItalic starnetISO def +/Helvetica starnetISO def +/Helvetica-Oblique starnetISO def +/Helvetica-Bold starnetISO def +/Helvetica-BoldOblique starnetISO def +/Courier starnetISO def +/Courier-Oblique starnetISO def +/Courier-Bold starnetISO def +/Courier-BoldOblique starnetISO def +cleartomark +} bind def + +%%BeginResource: procset graphviz 0 0 +/coord-font-family /Times-Roman def +/default-font-family /Times-Roman def +/coordfont coord-font-family findfont 8 scalefont def + +/InvScaleFactor 1.0 def +/set_scale { + dup 1 exch div /InvScaleFactor exch def + dup scale +} bind def + +% styles +/solid { [] 0 setdash } bind def +/dashed { [9 InvScaleFactor mul dup ] 0 setdash } bind def +/dotted { [1 InvScaleFactor mul 6 InvScaleFactor mul] 0 setdash } bind def +/invis {/fill {newpath} def /stroke {newpath} def /show {pop newpath} def} bind def +/bold { 2 setlinewidth } bind def +/filled { } bind def +/unfilled { } bind def +/rounded { } bind def +/diagonals { } bind def + +% hooks for setting color +/nodecolor { sethsbcolor } bind def +/edgecolor { sethsbcolor } bind def +/graphcolor { sethsbcolor } bind def +/nopcolor {pop pop pop} bind def + +/beginpage { % i j npages + /npages exch def + /j exch def + /i exch def + /str 10 string def + npages 1 gt { + gsave + coordfont setfont + 0 0 moveto + (\() show i str cvs show (,) show j str cvs show (\)) show + grestore + } if +} bind def + +/set_font { + findfont exch + scalefont setfont +} def + +% draw aligned label in bounding box aligned to current point +/alignedtext { % width adj text + /text exch def + /adj exch def + /width exch def + gsave + width 0 gt { + text stringwidth pop adj mul 0 rmoveto + } if + [] 0 setdash + text show + grestore +} def + +/boxprim { % xcorner ycorner xsize ysize + 4 2 roll + moveto + 2 copy + exch 0 rlineto + 0 exch rlineto + pop neg 0 rlineto + closepath +} bind def + +/ellipse_path { + /ry exch def + /rx exch def + /y exch def + /x exch def + matrix currentmatrix + newpath + x y translate + rx ry scale + 0 0 1 0 360 arc + setmatrix +} bind def + +/endpage { showpage } bind def +/showpage { } def + +/layercolorseq + [ % layer color sequence - darkest to lightest + [0 0 0] + [.2 .8 .8] + [.4 .8 .8] + [.6 .8 .8] + [.8 .8 .8] + ] +def + +/layerlen layercolorseq length def + +/setlayer {/maxlayer exch def /curlayer exch def + layercolorseq curlayer 1 sub layerlen mod get + aload pop sethsbcolor + /nodecolor {nopcolor} def + /edgecolor {nopcolor} def + /graphcolor {nopcolor} def +} bind def + +/onlayer { curlayer ne {invis} if } def + +/onlayers { + /myupper exch def + /mylower exch def + curlayer mylower lt + curlayer myupper gt + or + {invis} if +} def + +/curlayer 0 def + +%%EndResource +%%EndProlog +%%BeginSetup +14 default-font-family set_font +1 setmiterlimit +% /arrowlength 10 def +% /arrowwidth 5 def + +% make sure pdfmark is harmless for PS-interpreters other than Distiller +/pdfmark where {pop} {userdict /pdfmark /cleartomark load put} ifelse +% make '<<' and '>>' safe on PS Level 1 devices +/languagelevel where {pop languagelevel}{1} ifelse +2 lt { + userdict (<<) cvn ([) cvn load put + userdict (>>) cvn ([) cvn load put +} if + +%%EndSetup +%%Page: 1 1 +%%PageBoundingBox: 36 36 598 440 +%%PageOrientation: Portrait +gsave +36 36 562 404 boxprim clip newpath +36 36 translate +0 0 1 beginpage +1.0000 set_scale +4 4 translate 0 rotate +0.167 0.600 1.000 graphcolor +0.167 0.600 1.000 graphcolor +newpath -6 -6 moveto +-6 402 lineto +560 402 lineto +560 -6 lineto +closepath +fill +0.167 0.600 1.000 graphcolor +newpath -6 -6 moveto +-6 402 lineto +560 402 lineto +560 -6 lineto +closepath +stroke +0.000 0.000 0.000 graphcolor +14.00 /Times-Roman set_font +% LazyStreamAggregate(a:Type) +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 301 396 moveto +113 396 lineto +113 360 lineto +301 360 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 301 396 moveto +113 396 lineto +113 360 lineto +301 360 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +120 373 moveto +(LazyStreamAggregate\(a:Type\)) +[8.64 6.24 6.24 6.96 7.44 3.84 4.8 6.24 6.24 10.8 9.84 6.96 7.2 4.8 6.24 6.72 6.24 3.84 6.24 4.56 6.24 3.84 7.2 6.96 6.96 6.24 4.56] +xshow +end grestore +end grestore +% StreamAggregate(a:Type) +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 287 324 moveto +127 324 lineto +127 288 lineto +287 288 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 287 324 moveto +127 324 lineto +127 288 lineto +287 288 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +134 301 moveto +(StreamAggregate\(a:Type\)) +[7.44 3.84 4.8 6.24 6.24 10.8 9.84 6.96 7.2 4.8 6.24 6.72 6.24 3.84 6.24 4.56 6.24 3.84 7.2 6.96 6.96 6.24 4.56] +xshow +end grestore +end grestore +% LazyStreamAggregate(a:Type)->StreamAggregate(a:Type) +newpath 207 360 moveto +207 352 207 343 207 334 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 211 334 moveto +207 324 lineto +204 334 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 211 334 moveto +207 324 lineto +204 334 lineto +closepath +stroke +end grestore +% UnaryRecursiveAggregate(a:Type) +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 212 252 moveto +0 252 lineto +0 216 lineto +212 216 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 212 252 moveto +0 252 lineto +0 216 lineto +212 216 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +7 229 moveto +(UnaryRecursiveAggregate\(a:Type\)) +[9.6 6.96 6.24 5.04 6.96 9.12 6.24 6.24 6.96 4.8 5.52 3.84 6.48 6.24 9.84 6.96 7.2 4.8 6.24 6.72 6.24 3.84 6.24 4.56 6.24 3.84 7.2 6.96 6.96 6.24 4.56] +xshow +end grestore +end grestore +% StreamAggregate(a:Type)->UnaryRecursiveAggregate(a:Type) +newpath 182 288 moveto +170 279 154 268 140 258 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 141 255 moveto +131 252 lineto +137 260 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 141 255 moveto +131 252 lineto +137 260 lineto +closepath +stroke +end grestore +% LinearAggregate(a:Type) +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 388 252 moveto +230 252 lineto +230 216 lineto +388 216 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 388 252 moveto +230 252 lineto +230 216 lineto +388 216 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +238 229 moveto +(LinearAggregate\(a:Type\)) +[8.64 3.84 6.96 6.24 6.24 4.8 9.84 6.96 7.2 4.8 6.24 6.72 6.24 3.84 6.24 4.56 6.24 3.84 7.2 6.96 6.96 6.24 4.56] +xshow +end grestore +end grestore +% StreamAggregate(a:Type)->LinearAggregate(a:Type) +newpath 233 288 moveto +245 279 261 268 275 258 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 278 260 moveto +284 252 lineto +274 255 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 278 260 moveto +284 252 lineto +274 255 lineto +closepath +stroke +end grestore +% RecursiveAggregate(a:Type) +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 194 108 moveto +18 108 lineto +18 72 lineto +194 72 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 194 108 moveto +18 108 lineto +18 72 lineto +194 72 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +25 85 moveto +(RecursiveAggregate\(a:Type\)) +[9.12 6.24 6.24 6.96 4.8 5.52 3.84 6.48 6.24 9.84 6.96 7.2 4.8 6.24 6.72 6.24 3.84 6.24 4.56 6.24 3.84 7.2 6.96 6.96 6.24 4.56] +xshow +end grestore +end grestore +% UnaryRecursiveAggregate(a:Type)->RecursiveAggregate(a:Type) +newpath 106 216 moveto +106 191 106 147 106 118 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 110 118 moveto +106 108 lineto +103 118 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 110 118 moveto +106 108 lineto +103 118 lineto +closepath +stroke +end grestore +% IndexedAggregate(b:Integer,a:Type) +gsave 10 dict begin +filled +0.404 0.667 0.545 nodecolor +0.404 0.667 0.545 nodecolor +newpath 416 180 moveto +198 180 lineto +198 144 lineto +416 144 lineto +closepath +fill +0.404 0.667 0.545 nodecolor +newpath 416 180 moveto +198 180 lineto +198 144 lineto +416 144 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +205 157 moveto +(IndexedAggregate\(b:Integer,a:Type\)) +[4.56 6.96 6.96 5.76 6.48 6.24 6.96 9.84 6.96 7.2 4.8 6.24 6.72 6.24 3.84 6.24 4.56 6.96 3.84 4.56 6.96 3.84 6.24 6.72 6.24 4.32 3.6 6.24 3.84 7.2 6.96 6.96 6.24 4.56] +xshow +end grestore +end grestore +% LinearAggregate(a:Type)->IndexedAggregate(b:Integer,a:Type) +newpath 308 216 moveto +308 208 308 199 308 190 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 311 190 moveto +307 180 lineto +305 190 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 311 190 moveto +307 180 lineto +305 190 lineto +closepath +stroke +end grestore +% Collection(a:Type) +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 554 180 moveto +434 180 lineto +434 144 lineto +554 144 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 554 180 moveto +434 180 lineto +434 144 lineto +554 144 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +441 157 moveto +(Collection\(a:Type\)) +[9.36 6.96 3.84 3.84 6.24 6.24 3.84 3.84 6.96 6.96 4.56 6.24 3.84 7.2 6.96 6.96 6.24 4.56] +xshow +end grestore +end grestore +% LinearAggregate(a:Type)->Collection(a:Type) +newpath 356 216 moveto +381 206 412 194 439 184 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 440 187 moveto +448 180 lineto +437 181 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 440 187 moveto +448 180 lineto +437 181 lineto +closepath +stroke +end grestore +% HOAGG... +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 374 36 moveto +298 36 lineto +298 0 lineto +374 0 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 374 36 moveto +298 36 lineto +298 0 lineto +374 0 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +305 13 moveto +(HOAGG...) +[10.08 9.36 9.36 10.08 10.08 3.6 3.6 3.6] +xshow +end grestore +end grestore +% RecursiveAggregate(a:Type)->HOAGG... +newpath 164 72 moveto +202 60 252 45 288 33 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 289 36 moveto +298 30 lineto +287 30 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 289 36 moveto +298 30 lineto +287 30 lineto +closepath +stroke +end grestore +% IndexedAggregate(a:SetCategory,b:Type) +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 460 108 moveto +212 108 lineto +212 72 lineto +460 72 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 460 108 moveto +212 108 lineto +212 72 lineto +460 72 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +219 85 moveto +(IndexedAggregate\(a:SetCategory,b:Type\)) +[4.56 6.96 6.96 5.76 6.48 6.24 6.96 9.84 6.96 7.2 4.8 6.24 6.72 6.24 3.84 6.24 4.56 6.24 3.84 7.68 6 3.84 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6 3.6 6.96 3.84 7.2 6.96 6.96 6.24 4.56] +xshow +end grestore +end grestore +% IndexedAggregate(b:Integer,a:Type)->IndexedAggregate(a:SetCategory,b:Type) +newpath 314 144 moveto +318 136 321 126 325 117 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 328 119 moveto +329 108 lineto +322 116 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 328 119 moveto +329 108 lineto +322 116 lineto +closepath +stroke +end grestore +% Collection(a:Type)->HOAGG... +newpath 493 144 moveto +492 124 487 91 469 72 curveto +447 47 412 34 384 26 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 384 23 moveto +374 24 lineto +383 29 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 384 23 moveto +374 24 lineto +383 29 lineto +closepath +stroke +end grestore +% IndexedAggregate(a:SetCategory,b:Type)->HOAGG... +newpath 336 72 moveto +336 64 336 55 336 46 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 340 46 moveto +336 36 lineto +333 46 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 340 46 moveto +336 36 lineto +333 46 lineto +closepath +stroke +end grestore +endpage +showpage +grestore +%%PageTrailer +%%EndPage: 1 +%%Trailer +%%Pages: 1 +end +restore +%%EOF diff --git a/books/ps/v102segmentcategory.ps b/books/ps/v102segmentcategory.ps new file mode 100644 index 0000000..850ee57 --- /dev/null +++ b/books/ps/v102segmentcategory.ps @@ -0,0 +1,335 @@ +%!PS-Adobe-2.0 +%%Creator: dot version 2.8 (Thu Sep 14 20:34:11 UTC 2006) +%%For: (root) root +%%Title: pic +%%Pages: (atend) +%%BoundingBox: 36 36 170 224 +%%EndComments +save +%%BeginProlog +/DotDict 200 dict def +DotDict begin + +/setupLatin1 { +mark +/EncodingVector 256 array def + EncodingVector 0 + +ISOLatin1Encoding 0 255 getinterval putinterval +EncodingVector 45 /hyphen put + +% Set up ISO Latin 1 character encoding +/starnetISO { + dup dup findfont dup length dict begin + { 1 index /FID ne { def }{ pop pop } ifelse + } forall + /Encoding EncodingVector def + currentdict end definefont +} def +/Times-Roman starnetISO def +/Times-Italic starnetISO def +/Times-Bold starnetISO def +/Times-BoldItalic starnetISO def +/Helvetica starnetISO def +/Helvetica-Oblique starnetISO def +/Helvetica-Bold starnetISO def +/Helvetica-BoldOblique starnetISO def +/Courier starnetISO def +/Courier-Oblique starnetISO def +/Courier-Bold starnetISO def +/Courier-BoldOblique starnetISO def +cleartomark +} bind def + +%%BeginResource: procset graphviz 0 0 +/coord-font-family /Times-Roman def +/default-font-family /Times-Roman def +/coordfont coord-font-family findfont 8 scalefont def + +/InvScaleFactor 1.0 def +/set_scale { + dup 1 exch div /InvScaleFactor exch def + dup scale +} bind def + +% styles +/solid { [] 0 setdash } bind def +/dashed { [9 InvScaleFactor mul dup ] 0 setdash } bind def +/dotted { [1 InvScaleFactor mul 6 InvScaleFactor mul] 0 setdash } bind def +/invis {/fill {newpath} def /stroke {newpath} def /show {pop newpath} def} bind def +/bold { 2 setlinewidth } bind def +/filled { } bind def +/unfilled { } bind def +/rounded { } bind def +/diagonals { } bind def + +% hooks for setting color +/nodecolor { sethsbcolor } bind def +/edgecolor { sethsbcolor } bind def +/graphcolor { sethsbcolor } bind def +/nopcolor {pop pop pop} bind def + +/beginpage { % i j npages + /npages exch def + /j exch def + /i exch def + /str 10 string def + npages 1 gt { + gsave + coordfont setfont + 0 0 moveto + (\() show i str cvs show (,) show j str cvs show (\)) show + grestore + } if +} bind def + +/set_font { + findfont exch + scalefont setfont +} def + +% draw aligned label in bounding box aligned to current point +/alignedtext { % width adj text + /text exch def + /adj exch def + /width exch def + gsave + width 0 gt { + text stringwidth pop adj mul 0 rmoveto + } if + [] 0 setdash + text show + grestore +} def + +/boxprim { % xcorner ycorner xsize ysize + 4 2 roll + moveto + 2 copy + exch 0 rlineto + 0 exch rlineto + pop neg 0 rlineto + closepath +} bind def + +/ellipse_path { + /ry exch def + /rx exch def + /y exch def + /x exch def + matrix currentmatrix + newpath + x y translate + rx ry scale + 0 0 1 0 360 arc + setmatrix +} bind def + +/endpage { showpage } bind def +/showpage { } def + +/layercolorseq + [ % layer color sequence - darkest to lightest + [0 0 0] + [.2 .8 .8] + [.4 .8 .8] + [.6 .8 .8] + [.8 .8 .8] + ] +def + +/layerlen layercolorseq length def + +/setlayer {/maxlayer exch def /curlayer exch def + layercolorseq curlayer 1 sub layerlen mod get + aload pop sethsbcolor + /nodecolor {nopcolor} def + /edgecolor {nopcolor} def + /graphcolor {nopcolor} def +} bind def + +/onlayer { curlayer ne {invis} if } def + +/onlayers { + /myupper exch def + /mylower exch def + curlayer mylower lt + curlayer myupper gt + or + {invis} if +} def + +/curlayer 0 def + +%%EndResource +%%EndProlog +%%BeginSetup +14 default-font-family set_font +1 setmiterlimit +% /arrowlength 10 def +% /arrowwidth 5 def + +% make sure pdfmark is harmless for PS-interpreters other than Distiller +/pdfmark where {pop} {userdict /pdfmark /cleartomark load put} ifelse +% make '<<' and '>>' safe on PS Level 1 devices +/languagelevel where {pop languagelevel}{1} ifelse +2 lt { + userdict (<<) cvn ([) cvn load put + userdict (>>) cvn ([) cvn load put +} if + +%%EndSetup +%%Page: 1 1 +%%PageBoundingBox: 36 36 170 224 +%%PageOrientation: Portrait +gsave +36 36 134 188 boxprim clip newpath +36 36 translate +0 0 1 beginpage +1.0000 set_scale +4 4 translate 0 rotate +0.167 0.600 1.000 graphcolor +0.167 0.600 1.000 graphcolor +newpath -6 -6 moveto +-6 186 lineto +132 186 lineto +132 -6 lineto +closepath +fill +0.167 0.600 1.000 graphcolor +newpath -6 -6 moveto +-6 186 lineto +132 186 lineto +132 -6 lineto +closepath +stroke +0.000 0.000 0.000 graphcolor +14.00 /Times-Roman set_font +% SegmentCategory() +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 126 180 moveto +0 180 lineto +0 144 lineto +126 144 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 126 180 moveto +0 180 lineto +0 144 lineto +126 144 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +8 157 moveto +(SegmentCategory\(\)) +[7.68 6.24 6.96 10.8 6.24 6.96 3.84 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6.96 4.56 4.56] +xshow +end grestore +end grestore +% Type() +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 90 108 moveto +36 108 lineto +36 72 lineto +90 72 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 90 108 moveto +36 108 lineto +36 72 lineto +90 72 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +44 85 moveto +(Type\(\)) +[7.2 6.96 6.96 6.24 4.56 4.56] +xshow +end grestore +end grestore +% SegmentCategory()->Type() +newpath 63 144 moveto +63 136 63 127 63 118 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 67 118 moveto +63 108 lineto +60 118 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 67 118 moveto +63 108 lineto +60 118 lineto +closepath +stroke +end grestore +% Category +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 97 36 moveto +29 36 lineto +29 0 lineto +97 0 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 97 36 moveto +29 36 lineto +29 0 lineto +97 0 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +37 13 moveto +(Category) +[9.36 6.24 3.84 6.24 6.96 6.96 5.04 6.96] +xshow +end grestore +end grestore +% Type()->Category +newpath 63 72 moveto +63 64 63 55 63 46 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 67 46 moveto +63 36 lineto +60 46 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 67 46 moveto +63 36 lineto +60 46 lineto +closepath +stroke +end grestore +endpage +showpage +grestore +%%PageTrailer +%%EndPage: 1 +%%Trailer +%%Pages: 1 +end +restore +%%EOF diff --git a/books/ps/v102segmentexpansioncategory.ps b/books/ps/v102segmentexpansioncategory.ps new file mode 100644 index 0000000..13bfac4 --- /dev/null +++ b/books/ps/v102segmentexpansioncategory.ps @@ -0,0 +1,586 @@ +%!PS-Adobe-2.0 +%%Creator: dot version 2.8 (Thu Sep 14 20:34:11 UTC 2006) +%%For: (root) root +%%Title: pic +%%Pages: (atend) +%%BoundingBox: 36 36 506 368 +%%EndComments +save +%%BeginProlog +/DotDict 200 dict def +DotDict begin + +/setupLatin1 { +mark +/EncodingVector 256 array def + EncodingVector 0 + +ISOLatin1Encoding 0 255 getinterval putinterval +EncodingVector 45 /hyphen put + +% Set up ISO Latin 1 character encoding +/starnetISO { + dup dup findfont dup length dict begin + { 1 index /FID ne { def }{ pop pop } ifelse + } forall + /Encoding EncodingVector def + currentdict end definefont +} def +/Times-Roman starnetISO def +/Times-Italic starnetISO def +/Times-Bold starnetISO def +/Times-BoldItalic starnetISO def +/Helvetica starnetISO def +/Helvetica-Oblique starnetISO def +/Helvetica-Bold starnetISO def +/Helvetica-BoldOblique starnetISO def +/Courier starnetISO def +/Courier-Oblique starnetISO def +/Courier-Bold starnetISO def +/Courier-BoldOblique starnetISO def +cleartomark +} bind def + +%%BeginResource: procset graphviz 0 0 +/coord-font-family /Times-Roman def +/default-font-family /Times-Roman def +/coordfont coord-font-family findfont 8 scalefont def + +/InvScaleFactor 1.0 def +/set_scale { + dup 1 exch div /InvScaleFactor exch def + dup scale +} bind def + +% styles +/solid { [] 0 setdash } bind def +/dashed { [9 InvScaleFactor mul dup ] 0 setdash } bind def +/dotted { [1 InvScaleFactor mul 6 InvScaleFactor mul] 0 setdash } bind def +/invis {/fill {newpath} def /stroke {newpath} def /show {pop newpath} def} bind def +/bold { 2 setlinewidth } bind def +/filled { } bind def +/unfilled { } bind def +/rounded { } bind def +/diagonals { } bind def + +% hooks for setting color +/nodecolor { sethsbcolor } bind def +/edgecolor { sethsbcolor } bind def +/graphcolor { sethsbcolor } bind def +/nopcolor {pop pop pop} bind def + +/beginpage { % i j npages + /npages exch def + /j exch def + /i exch def + /str 10 string def + npages 1 gt { + gsave + coordfont setfont + 0 0 moveto + (\() show i str cvs show (,) show j str cvs show (\)) show + grestore + } if +} bind def + +/set_font { + findfont exch + scalefont setfont +} def + +% draw aligned label in bounding box aligned to current point +/alignedtext { % width adj text + /text exch def + /adj exch def + /width exch def + gsave + width 0 gt { + text stringwidth pop adj mul 0 rmoveto + } if + [] 0 setdash + text show + grestore +} def + +/boxprim { % xcorner ycorner xsize ysize + 4 2 roll + moveto + 2 copy + exch 0 rlineto + 0 exch rlineto + pop neg 0 rlineto + closepath +} bind def + +/ellipse_path { + /ry exch def + /rx exch def + /y exch def + /x exch def + matrix currentmatrix + newpath + x y translate + rx ry scale + 0 0 1 0 360 arc + setmatrix +} bind def + +/endpage { showpage } bind def +/showpage { } def + +/layercolorseq + [ % layer color sequence - darkest to lightest + [0 0 0] + [.2 .8 .8] + [.4 .8 .8] + [.6 .8 .8] + [.8 .8 .8] + ] +def + +/layerlen layercolorseq length def + +/setlayer {/maxlayer exch def /curlayer exch def + layercolorseq curlayer 1 sub layerlen mod get + aload pop sethsbcolor + /nodecolor {nopcolor} def + /edgecolor {nopcolor} def + /graphcolor {nopcolor} def +} bind def + +/onlayer { curlayer ne {invis} if } def + +/onlayers { + /myupper exch def + /mylower exch def + curlayer mylower lt + curlayer myupper gt + or + {invis} if +} def + +/curlayer 0 def + +%%EndResource +%%EndProlog +%%BeginSetup +14 default-font-family set_font +1 setmiterlimit +% /arrowlength 10 def +% /arrowwidth 5 def + +% make sure pdfmark is harmless for PS-interpreters other than Distiller +/pdfmark where {pop} {userdict /pdfmark /cleartomark load put} ifelse +% make '<<' and '>>' safe on PS Level 1 devices +/languagelevel where {pop languagelevel}{1} ifelse +2 lt { + userdict (<<) cvn ([) cvn load put + userdict (>>) cvn ([) cvn load put +} if + +%%EndSetup +%%Page: 1 1 +%%PageBoundingBox: 36 36 506 368 +%%PageOrientation: Portrait +gsave +36 36 470 332 boxprim clip newpath +36 36 translate +0 0 1 beginpage +1.0000 set_scale +4 4 translate 0 rotate +0.167 0.600 1.000 graphcolor +0.167 0.600 1.000 graphcolor +newpath -6 -6 moveto +-6 330 lineto +468 330 lineto +468 -6 lineto +closepath +fill +0.167 0.600 1.000 graphcolor +newpath -6 -6 moveto +-6 330 lineto +468 330 lineto +468 -6 lineto +closepath +stroke +0.000 0.000 0.000 graphcolor +14.00 /Times-Roman set_font +% SegmentExpansionCategory(a:OrderedRing,b:StreamAggregate(OrderedRing)) +[ /Rect [ 0 288 462 324 ] + /Border [ 0 0 0 ] + /Action << /Subtype /URI /URI (bookvol10.2.pdf#nameddest=SEGXCAT) >> + /Subtype /Link +/ANN pdfmark +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 462 324 moveto +0 324 lineto +0 288 lineto +462 288 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 462 324 moveto +0 324 lineto +0 288 lineto +462 288 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +8 301 moveto +(SegmentExpansionCategory\(a:OrderedRing,b:StreamAggregate\(OrderedRing\)\)) +[7.68 6.24 6.96 10.8 6.24 6.96 3.84 8.64 6.96 6.96 6.24 6.96 5.52 3.84 6.96 6.96 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6.96 4.56 6.24 3.84 10.08 4.56 6.96 6.24 4.8 6.24 6.96 9.36 3.84 6.96 6.96 3.6 6.96 3.84 7.44 3.84 4.8 6.24 6.24 10.8 9.84 6.96 7.2 4.8 6.24 6.72 6.24 3.84 6.24 4.56 10.08 4.56 6.96 6.24 4.8 6.24 6.96 9.36 3.84 6.96 6.96 4.56 4.56] +xshow +end grestore +end grestore +% SegmentCategory(OrderedRing) +[ /Rect [ 132 216 330 252 ] + /Border [ 0 0 0 ] + /Action << /Subtype /URI /URI (bookvol10.2.pdf#nameddest=SEGCAT) >> + /Subtype /Link +/ANN pdfmark +gsave 10 dict begin +filled +0.404 0.667 0.545 nodecolor +0.404 0.667 0.545 nodecolor +newpath 330 252 moveto +132 252 lineto +132 216 lineto +330 216 lineto +closepath +fill +0.404 0.667 0.545 nodecolor +newpath 330 252 moveto +132 252 lineto +132 216 lineto +330 216 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +139 229 moveto +(SegmentCategory\(OrderedRing\)) +[7.68 6.24 6.96 10.8 6.24 6.96 3.84 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6.96 4.56 10.08 4.56 6.96 6.24 4.8 6.24 6.96 9.36 3.84 6.96 6.96 4.56] +xshow +end grestore +end grestore +% SegmentExpansionCategory(a:OrderedRing,b:StreamAggregate(OrderedRing))->SegmentCategory(OrderedRing) +newpath 231 288 moveto +231 280 231 271 231 262 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 235 262 moveto +231 252 lineto +228 262 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 235 262 moveto +231 252 lineto +228 262 lineto +closepath +stroke +end grestore +% SegmentCategory(a:Type) +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 313 180 moveto +149 180 lineto +149 144 lineto +313 144 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 313 180 moveto +149 180 lineto +149 144 lineto +313 144 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +157 157 moveto +(SegmentCategory\(a:Type\)) +[7.68 6.24 6.96 10.8 6.24 6.96 3.84 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6.96 4.56 6.24 3.84 7.2 6.96 6.96 6.24 4.56] +xshow +end grestore +end grestore +% SegmentCategory(OrderedRing)->SegmentCategory(a:Type) +newpath 231 216 moveto +231 208 231 199 231 190 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 235 190 moveto +231 180 lineto +228 190 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 235 190 moveto +231 180 lineto +228 190 lineto +closepath +stroke +end grestore +% Type() +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 258 108 moveto +204 108 lineto +204 72 lineto +258 72 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 258 108 moveto +204 108 lineto +204 72 lineto +258 72 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +212 85 moveto +(Type\(\)) +[7.2 6.96 6.96 6.24 4.56 4.56] +xshow +end grestore +end grestore +% SegmentCategory(a:Type)->Type() +newpath 231 144 moveto +231 136 231 127 231 118 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 235 118 moveto +231 108 lineto +228 118 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 235 118 moveto +231 108 lineto +228 118 lineto +closepath +stroke +end grestore +% Category +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 265 36 moveto +197 36 lineto +197 0 lineto +265 0 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 265 36 moveto +197 36 lineto +197 0 lineto +265 0 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +205 13 moveto +(Category) +[9.36 6.24 3.84 6.24 6.96 6.96 5.04 6.96] +xshow +end grestore +end grestore +% Type()->Category +newpath 231 72 moveto +231 64 231 55 231 46 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 235 46 moveto +231 36 lineto +228 46 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 235 46 moveto +231 36 lineto +228 46 lineto +closepath +stroke +end grestore +endpage +showpage +grestore +%%PageTrailer +%%EndPage: 1 +%%Page: 2 2 +%%PageBoundingBox: 36 36 170 224 +%%PageOrientation: Portrait +gsave +36 36 134 188 boxprim clip newpath +36 36 translate +0 0 1 beginpage +1.0000 set_scale +4 4 translate 0 rotate +0.167 0.600 1.000 graphcolor +0.167 0.600 1.000 graphcolor +newpath -6 -6 moveto +-6 186 lineto +132 186 lineto +132 -6 lineto +closepath +fill +0.167 0.600 1.000 graphcolor +newpath -6 -6 moveto +-6 186 lineto +132 186 lineto +132 -6 lineto +closepath +stroke +0.000 0.000 0.000 graphcolor +14.00 /Times-Roman set_font +% SegmentCategory() +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 126 180 moveto +0 180 lineto +0 144 lineto +126 144 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 126 180 moveto +0 180 lineto +0 144 lineto +126 144 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +8 157 moveto +(SegmentCategory\(\)) +[7.68 6.24 6.96 10.8 6.24 6.96 3.84 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6.96 4.56 4.56] +xshow +end grestore +end grestore +% Type() +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 90 108 moveto +36 108 lineto +36 72 lineto +90 72 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 90 108 moveto +36 108 lineto +36 72 lineto +90 72 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +44 85 moveto +(Type\(\)) +[7.2 6.96 6.96 6.24 4.56 4.56] +xshow +end grestore +end grestore +% SegmentCategory()->Type() +newpath 63 144 moveto +63 136 63 127 63 118 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 67 118 moveto +63 108 lineto +60 118 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 67 118 moveto +63 108 lineto +60 118 lineto +closepath +stroke +end grestore +% Category +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 97 36 moveto +29 36 lineto +29 0 lineto +97 0 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 97 36 moveto +29 36 lineto +29 0 lineto +97 0 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +37 13 moveto +(Category) +[9.36 6.24 3.84 6.24 6.96 6.96 5.04 6.96] +xshow +end grestore +end grestore +% Type()->Category +newpath 63 72 moveto +63 64 63 55 63 46 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 67 46 moveto +63 36 lineto +60 46 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 67 46 moveto +63 36 lineto +60 46 lineto +closepath +stroke +end grestore +endpage +showpage +grestore +%%PageTrailer +%%EndPage: 2 +%%Trailer +%%Pages: 2 +end +restore +%%EOF diff --git a/books/ps/v102sexpressioncategory.ps b/books/ps/v102sexpressioncategory.ps new file mode 100644 index 0000000..8c80a6c --- /dev/null +++ b/books/ps/v102sexpressioncategory.ps @@ -0,0 +1,494 @@ +%!PS-Adobe-2.0 +%%Creator: dot version 2.8 (Thu Sep 14 20:34:11 UTC 2006) +%%For: (root) root +%%Title: pic +%%Pages: (atend) +%%BoundingBox: 36 36 598 368 +%%EndComments +save +%%BeginProlog +/DotDict 200 dict def +DotDict begin + +/setupLatin1 { +mark +/EncodingVector 256 array def + EncodingVector 0 + +ISOLatin1Encoding 0 255 getinterval putinterval +EncodingVector 45 /hyphen put + +% Set up ISO Latin 1 character encoding +/starnetISO { + dup dup findfont dup length dict begin + { 1 index /FID ne { def }{ pop pop } ifelse + } forall + /Encoding EncodingVector def + currentdict end definefont +} def +/Times-Roman starnetISO def +/Times-Italic starnetISO def +/Times-Bold starnetISO def +/Times-BoldItalic starnetISO def +/Helvetica starnetISO def +/Helvetica-Oblique starnetISO def +/Helvetica-Bold starnetISO def +/Helvetica-BoldOblique starnetISO def +/Courier starnetISO def +/Courier-Oblique starnetISO def +/Courier-Bold starnetISO def +/Courier-BoldOblique starnetISO def +cleartomark +} bind def + +%%BeginResource: procset graphviz 0 0 +/coord-font-family /Times-Roman def +/default-font-family /Times-Roman def +/coordfont coord-font-family findfont 8 scalefont def + +/InvScaleFactor 1.0 def +/set_scale { + dup 1 exch div /InvScaleFactor exch def + dup scale +} bind def + +% styles +/solid { [] 0 setdash } bind def +/dashed { [9 InvScaleFactor mul dup ] 0 setdash } bind def +/dotted { [1 InvScaleFactor mul 6 InvScaleFactor mul] 0 setdash } bind def +/invis {/fill {newpath} def /stroke {newpath} def /show {pop newpath} def} bind def +/bold { 2 setlinewidth } bind def +/filled { } bind def +/unfilled { } bind def +/rounded { } bind def +/diagonals { } bind def + +% hooks for setting color +/nodecolor { sethsbcolor } bind def +/edgecolor { sethsbcolor } bind def +/graphcolor { sethsbcolor } bind def +/nopcolor {pop pop pop} bind def + +/beginpage { % i j npages + /npages exch def + /j exch def + /i exch def + /str 10 string def + npages 1 gt { + gsave + coordfont setfont + 0 0 moveto + (\() show i str cvs show (,) show j str cvs show (\)) show + grestore + } if +} bind def + +/set_font { + findfont exch + scalefont setfont +} def + +% draw aligned label in bounding box aligned to current point +/alignedtext { % width adj text + /text exch def + /adj exch def + /width exch def + gsave + width 0 gt { + text stringwidth pop adj mul 0 rmoveto + } if + [] 0 setdash + text show + grestore +} def + +/boxprim { % xcorner ycorner xsize ysize + 4 2 roll + moveto + 2 copy + exch 0 rlineto + 0 exch rlineto + pop neg 0 rlineto + closepath +} bind def + +/ellipse_path { + /ry exch def + /rx exch def + /y exch def + /x exch def + matrix currentmatrix + newpath + x y translate + rx ry scale + 0 0 1 0 360 arc + setmatrix +} bind def + +/endpage { showpage } bind def +/showpage { } def + +/layercolorseq + [ % layer color sequence - darkest to lightest + [0 0 0] + [.2 .8 .8] + [.4 .8 .8] + [.6 .8 .8] + [.8 .8 .8] + ] +def + +/layerlen layercolorseq length def + +/setlayer {/maxlayer exch def /curlayer exch def + layercolorseq curlayer 1 sub layerlen mod get + aload pop sethsbcolor + /nodecolor {nopcolor} def + /edgecolor {nopcolor} def + /graphcolor {nopcolor} def +} bind def + +/onlayer { curlayer ne {invis} if } def + +/onlayers { + /myupper exch def + /mylower exch def + curlayer mylower lt + curlayer myupper gt + or + {invis} if +} def + +/curlayer 0 def + +%%EndResource +%%EndProlog +%%BeginSetup +14 default-font-family set_font +1 setmiterlimit +% /arrowlength 10 def +% /arrowwidth 5 def + +% make sure pdfmark is harmless for PS-interpreters other than Distiller +/pdfmark where {pop} {userdict /pdfmark /cleartomark load put} ifelse +% make '<<' and '>>' safe on PS Level 1 devices +/languagelevel where {pop languagelevel}{1} ifelse +2 lt { + userdict (<<) cvn ([) cvn load put + userdict (>>) cvn ([) cvn load put +} if + +%%EndSetup +%%Page: 1 1 +%%PageBoundingBox: 36 36 598 368 +%%PageOrientation: Portrait +gsave +36 36 562 332 boxprim clip newpath +36 36 translate +0 0 1 beginpage +1.0000 set_scale +4 4 translate 0 rotate +0.167 0.600 1.000 graphcolor +0.167 0.600 1.000 graphcolor +newpath -6 -6 moveto +-6 330 lineto +560 330 lineto +560 -6 lineto +closepath +fill +0.167 0.600 1.000 graphcolor +newpath -6 -6 moveto +-6 330 lineto +560 330 lineto +560 -6 lineto +closepath +stroke +0.000 0.000 0.000 graphcolor +14.00 /Times-Roman set_font +% SExpressionCategory(a:SetCategory,b:SetCategory,c:SetCategory,d:SetCategory,e:SetCategory) +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 554 324 moveto +0 324 lineto +0 288 lineto +554 288 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 554 324 moveto +0 324 lineto +0 288 lineto +554 288 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +7 301 moveto +(SExpressionCategory\(a:SetCategory,b:SetCategory,c:SetCategory,d:SetCategory,e:SetCategory\)) +[7.68 8.64 6.96 6.96 4.8 6.24 5.52 5.52 3.84 6.96 6.96 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6.96 4.56 6.24 3.84 7.68 6 3.84 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6 3.6 6.96 3.84 7.68 6 3.84 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6 3.6 6.24 3.84 7.68 6 3.84 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6 3.6 6.96 3.84 7.68 6 3.84 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6 3.6 6.24 3.84 7.68 6 3.84 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6.96 4.56] +xshow +end grestore +end grestore +% SetCategory() +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 324 252 moveto +230 252 lineto +230 216 lineto +324 216 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 324 252 moveto +230 252 lineto +230 216 lineto +324 216 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +237 229 moveto +(SetCategory\(\)) +[7.68 6 3.84 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6.96 4.56 4.56] +xshow +end grestore +end grestore +% SExpressionCategory(a:SetCategory,b:SetCategory,c:SetCategory,d:SetCategory,e:SetCategory)->SetCategory() +newpath 277 288 moveto +277 280 277 271 277 262 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 281 262 moveto +277 252 lineto +274 262 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 281 262 moveto +277 252 lineto +274 262 lineto +closepath +stroke +end grestore +% BasicType() +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 256 108 moveto +172 108 lineto +172 72 lineto +256 72 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 256 108 moveto +172 108 lineto +172 72 lineto +256 72 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +179 85 moveto +(BasicType\(\)) +[9.36 6.24 5.52 3.84 6.24 7.2 6.96 6.96 6.24 4.56 4.56] +xshow +end grestore +end grestore +% SetCategory()->BasicType() +newpath 265 216 moveto +258 206 250 192 245 180 curveto +236 160 227 136 222 118 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 225 117 moveto +219 108 lineto +219 119 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 225 117 moveto +219 108 lineto +219 119 lineto +closepath +stroke +end grestore +% CoercibleTo(OutputForm) +gsave 10 dict begin +filled +0.404 0.667 0.545 nodecolor +0.404 0.667 0.545 nodecolor +newpath 418 180 moveto +254 180 lineto +254 144 lineto +418 144 lineto +closepath +fill +0.404 0.667 0.545 nodecolor +newpath 418 180 moveto +254 180 lineto +254 144 lineto +418 144 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +262 157 moveto +(CoercibleTo\(OutputForm\)) +[9.36 6.96 6.24 4.8 6.24 3.84 6.96 3.84 6.24 7.44 6.96 4.56 10.08 6.96 3.84 6.96 6.96 3.84 7.44 6.96 5.04 10.8 4.56] +xshow +end grestore +end grestore +% SetCategory()->CoercibleTo(OutputForm) +newpath 292 216 moveto +299 207 307 197 315 188 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 318 190 moveto +321 180 lineto +312 186 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 318 190 moveto +321 180 lineto +312 186 lineto +closepath +stroke +end grestore +% Category +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 311 36 moveto +243 36 lineto +243 0 lineto +311 0 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 311 36 moveto +243 36 lineto +243 0 lineto +311 0 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +251 13 moveto +(Category) +[9.36 6.24 3.84 6.24 6.96 6.96 5.04 6.96] +xshow +end grestore +end grestore +% BasicType()->Category +newpath 230 72 moveto +238 63 247 53 254 44 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 257 46 moveto +261 36 lineto +252 41 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 257 46 moveto +261 36 lineto +252 41 lineto +closepath +stroke +end grestore +% CoercibleTo(a:Type) +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 406 108 moveto +274 108 lineto +274 72 lineto +406 72 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 406 108 moveto +274 108 lineto +274 72 lineto +406 72 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +282 85 moveto +(CoercibleTo\(a:Type\)) +[9.36 6.96 6.24 4.8 6.24 3.84 6.96 3.84 6.24 7.44 6.96 4.56 6.24 3.84 7.2 6.96 6.96 6.24 4.56] +xshow +end grestore +end grestore +% CoercibleTo(OutputForm)->CoercibleTo(a:Type) +newpath 337 144 moveto +338 136 338 127 338 118 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 341 118 moveto +339 108 lineto +335 118 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 341 118 moveto +339 108 lineto +335 118 lineto +closepath +stroke +end grestore +% CoercibleTo(a:Type)->Category +newpath 324 72 moveto +316 63 307 53 300 44 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 302 41 moveto +293 36 lineto +297 46 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 302 41 moveto +293 36 lineto +297 46 lineto +closepath +stroke +end grestore +endpage +showpage +grestore +%%PageTrailer +%%EndPage: 1 +%%Trailer +%%Pages: 1 +end +restore +%%EOF diff --git a/books/ps/v102threespacecategory.ps b/books/ps/v102threespacecategory.ps new file mode 100644 index 0000000..bc98150 --- /dev/null +++ b/books/ps/v102threespacecategory.ps @@ -0,0 +1,494 @@ +%!PS-Adobe-2.0 +%%Creator: dot version 2.8 (Thu Sep 14 20:34:11 UTC 2006) +%%For: (root) root +%%Title: pic +%%Pages: (atend) +%%BoundingBox: 36 36 290 368 +%%EndComments +save +%%BeginProlog +/DotDict 200 dict def +DotDict begin + +/setupLatin1 { +mark +/EncodingVector 256 array def + EncodingVector 0 + +ISOLatin1Encoding 0 255 getinterval putinterval +EncodingVector 45 /hyphen put + +% Set up ISO Latin 1 character encoding +/starnetISO { + dup dup findfont dup length dict begin + { 1 index /FID ne { def }{ pop pop } ifelse + } forall + /Encoding EncodingVector def + currentdict end definefont +} def +/Times-Roman starnetISO def +/Times-Italic starnetISO def +/Times-Bold starnetISO def +/Times-BoldItalic starnetISO def +/Helvetica starnetISO def +/Helvetica-Oblique starnetISO def +/Helvetica-Bold starnetISO def +/Helvetica-BoldOblique starnetISO def +/Courier starnetISO def +/Courier-Oblique starnetISO def +/Courier-Bold starnetISO def +/Courier-BoldOblique starnetISO def +cleartomark +} bind def + +%%BeginResource: procset graphviz 0 0 +/coord-font-family /Times-Roman def +/default-font-family /Times-Roman def +/coordfont coord-font-family findfont 8 scalefont def + +/InvScaleFactor 1.0 def +/set_scale { + dup 1 exch div /InvScaleFactor exch def + dup scale +} bind def + +% styles +/solid { [] 0 setdash } bind def +/dashed { [9 InvScaleFactor mul dup ] 0 setdash } bind def +/dotted { [1 InvScaleFactor mul 6 InvScaleFactor mul] 0 setdash } bind def +/invis {/fill {newpath} def /stroke {newpath} def /show {pop newpath} def} bind def +/bold { 2 setlinewidth } bind def +/filled { } bind def +/unfilled { } bind def +/rounded { } bind def +/diagonals { } bind def + +% hooks for setting color +/nodecolor { sethsbcolor } bind def +/edgecolor { sethsbcolor } bind def +/graphcolor { sethsbcolor } bind def +/nopcolor {pop pop pop} bind def + +/beginpage { % i j npages + /npages exch def + /j exch def + /i exch def + /str 10 string def + npages 1 gt { + gsave + coordfont setfont + 0 0 moveto + (\() show i str cvs show (,) show j str cvs show (\)) show + grestore + } if +} bind def + +/set_font { + findfont exch + scalefont setfont +} def + +% draw aligned label in bounding box aligned to current point +/alignedtext { % width adj text + /text exch def + /adj exch def + /width exch def + gsave + width 0 gt { + text stringwidth pop adj mul 0 rmoveto + } if + [] 0 setdash + text show + grestore +} def + +/boxprim { % xcorner ycorner xsize ysize + 4 2 roll + moveto + 2 copy + exch 0 rlineto + 0 exch rlineto + pop neg 0 rlineto + closepath +} bind def + +/ellipse_path { + /ry exch def + /rx exch def + /y exch def + /x exch def + matrix currentmatrix + newpath + x y translate + rx ry scale + 0 0 1 0 360 arc + setmatrix +} bind def + +/endpage { showpage } bind def +/showpage { } def + +/layercolorseq + [ % layer color sequence - darkest to lightest + [0 0 0] + [.2 .8 .8] + [.4 .8 .8] + [.6 .8 .8] + [.8 .8 .8] + ] +def + +/layerlen layercolorseq length def + +/setlayer {/maxlayer exch def /curlayer exch def + layercolorseq curlayer 1 sub layerlen mod get + aload pop sethsbcolor + /nodecolor {nopcolor} def + /edgecolor {nopcolor} def + /graphcolor {nopcolor} def +} bind def + +/onlayer { curlayer ne {invis} if } def + +/onlayers { + /myupper exch def + /mylower exch def + curlayer mylower lt + curlayer myupper gt + or + {invis} if +} def + +/curlayer 0 def + +%%EndResource +%%EndProlog +%%BeginSetup +14 default-font-family set_font +1 setmiterlimit +% /arrowlength 10 def +% /arrowwidth 5 def + +% make sure pdfmark is harmless for PS-interpreters other than Distiller +/pdfmark where {pop} {userdict /pdfmark /cleartomark load put} ifelse +% make '<<' and '>>' safe on PS Level 1 devices +/languagelevel where {pop languagelevel}{1} ifelse +2 lt { + userdict (<<) cvn ([) cvn load put + userdict (>>) cvn ([) cvn load put +} if + +%%EndSetup +%%Page: 1 1 +%%PageBoundingBox: 36 36 290 368 +%%PageOrientation: Portrait +gsave +36 36 254 332 boxprim clip newpath +36 36 translate +0 0 1 beginpage +1.0000 set_scale +4 4 translate 0 rotate +0.167 0.600 1.000 graphcolor +0.167 0.600 1.000 graphcolor +newpath -6 -6 moveto +-6 330 lineto +252 330 lineto +252 -6 lineto +closepath +fill +0.167 0.600 1.000 graphcolor +newpath -6 -6 moveto +-6 330 lineto +252 330 lineto +252 -6 lineto +closepath +stroke +0.000 0.000 0.000 graphcolor +14.00 /Times-Roman set_font +% ThreeSpaceCategory(a:Ring) +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 195 324 moveto +15 324 lineto +15 288 lineto +195 288 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 195 324 moveto +15 324 lineto +15 288 lineto +195 288 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +22 301 moveto +(ThreeSpaceCategory\(a:Ring\)) +[8.64 6.96 4.8 6.24 6.24 7.68 6.96 6.24 6.24 6.24 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6.96 4.56 6.24 3.84 9.36 3.84 6.96 6.96 4.56] +xshow +end grestore +end grestore +% SetCategory() +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 152 252 moveto +58 252 lineto +58 216 lineto +152 216 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 152 252 moveto +58 252 lineto +58 216 lineto +152 216 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +65 229 moveto +(SetCategory\(\)) +[7.68 6 3.84 9.36 6.24 3.84 6.24 6.96 6.96 5.04 6.96 4.56 4.56] +xshow +end grestore +end grestore +% ThreeSpaceCategory(a:Ring)->SetCategory() +newpath 105 288 moveto +105 280 105 271 105 262 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 109 262 moveto +105 252 lineto +102 262 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 109 262 moveto +105 252 lineto +102 262 lineto +closepath +stroke +end grestore +% BasicType() +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 84 108 moveto +0 108 lineto +0 72 lineto +84 72 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 84 108 moveto +0 108 lineto +0 72 lineto +84 72 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +7 85 moveto +(BasicType\(\)) +[9.36 6.24 5.52 3.84 6.24 7.2 6.96 6.96 6.24 4.56 4.56] +xshow +end grestore +end grestore +% SetCategory()->BasicType() +newpath 93 216 moveto +86 206 78 192 73 180 curveto +64 160 55 136 50 118 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 53 117 moveto +47 108 lineto +47 119 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 53 117 moveto +47 108 lineto +47 119 lineto +closepath +stroke +end grestore +% CoercibleTo(OutputForm) +gsave 10 dict begin +filled +0.404 0.667 0.545 nodecolor +0.404 0.667 0.545 nodecolor +newpath 246 180 moveto +82 180 lineto +82 144 lineto +246 144 lineto +closepath +fill +0.404 0.667 0.545 nodecolor +newpath 246 180 moveto +82 180 lineto +82 144 lineto +246 144 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +90 157 moveto +(CoercibleTo\(OutputForm\)) +[9.36 6.96 6.24 4.8 6.24 3.84 6.96 3.84 6.24 7.44 6.96 4.56 10.08 6.96 3.84 6.96 6.96 3.84 7.44 6.96 5.04 10.8 4.56] +xshow +end grestore +end grestore +% SetCategory()->CoercibleTo(OutputForm) +newpath 120 216 moveto +127 207 135 197 143 188 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 146 190 moveto +149 180 lineto +140 186 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 146 190 moveto +149 180 lineto +140 186 lineto +closepath +stroke +end grestore +% Category +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 139 36 moveto +71 36 lineto +71 0 lineto +139 0 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 139 36 moveto +71 36 lineto +71 0 lineto +139 0 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +79 13 moveto +(Category) +[9.36 6.24 3.84 6.24 6.96 6.96 5.04 6.96] +xshow +end grestore +end grestore +% BasicType()->Category +newpath 58 72 moveto +66 63 75 53 82 44 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 85 46 moveto +89 36 lineto +80 41 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 85 46 moveto +89 36 lineto +80 41 lineto +closepath +stroke +end grestore +% CoercibleTo(a:Type) +gsave 10 dict begin +filled +0.537 0.247 0.902 nodecolor +0.537 0.247 0.902 nodecolor +newpath 234 108 moveto +102 108 lineto +102 72 lineto +234 72 lineto +closepath +fill +0.537 0.247 0.902 nodecolor +newpath 234 108 moveto +102 108 lineto +102 72 lineto +234 72 lineto +closepath +stroke +gsave 10 dict begin +0.000 0.000 0.000 nodecolor +110 85 moveto +(CoercibleTo\(a:Type\)) +[9.36 6.96 6.24 4.8 6.24 3.84 6.96 3.84 6.24 7.44 6.96 4.56 6.24 3.84 7.2 6.96 6.96 6.24 4.56] +xshow +end grestore +end grestore +% CoercibleTo(OutputForm)->CoercibleTo(a:Type) +newpath 165 144 moveto +166 136 166 127 166 118 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 169 118 moveto +167 108 lineto +163 118 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 169 118 moveto +167 108 lineto +163 118 lineto +closepath +stroke +end grestore +% CoercibleTo(a:Type)->Category +newpath 152 72 moveto +144 63 135 53 128 44 curveto +stroke +gsave 10 dict begin +solid +1 setlinewidth +0.000 0.000 0.000 edgecolor +newpath 130 41 moveto +121 36 lineto +125 46 lineto +closepath +fill +0.000 0.000 0.000 edgecolor +newpath 130 41 moveto +121 36 lineto +125 46 lineto +closepath +stroke +end grestore +endpage +showpage +grestore +%%PageTrailer +%%EndPage: 1 +%%Trailer +%%Pages: 1 +end +restore +%%EOF diff --git a/changelog b/changelog index deeb50b..b906a78 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,17 @@ +20081005 tpd books/bookvol10.2 add categores +20081005 tpd books/ps/v102fullyevalableover.ps added +20081005 tpd src/algebra/equation2.spad move FEVALAB to bookvol10.2 +20081005 tpd books/ps/v102threespacecategory.ps added +20081005 tpd src/algebra/space.spad move SPACEC to bookvol10.2 +20081005 tpd books/ps/v102binarytreecategory.ps added +20081005 tpd src/algebra/tree.spad move BTCAT to bookvol10.2 +20081005 tpd books/ps/v102lazystreamaggregate.ps added +20081005 tpd src/algebra/stream.spad.pamphlet move LZSTAGG to bookvol10.2 +20081005 tpd books/ps/v102sexpressioncategory.ps added +20081005 tpd src/algebra/sex.spad move SEXCAT to bookvol10.2 +20081005 tpd books/ps/v102segmentexpansioncategory.ps added +20081005 tpd books/ps/v102segmentcategory.ps added +20081005 tpd src/algebra/seg.spad move SEGCAT, SEGXCAT to bookvol10.2 20081003 tpd books/bookvol10.2 add UPOLYC, update attributes 20081003 tpd books/ps/v102univariatepolynomialcategory.ps added 20081003 tpd src/algebra/polycat.spad move UPOLYC diff --git a/src/algebra/equation2.spad.pamphlet b/src/algebra/equation2.spad.pamphlet index d84e1ad..d29c808 100644 --- a/src/algebra/equation2.spad.pamphlet +++ b/src/algebra/equation2.spad.pamphlet @@ -435,39 +435,6 @@ EquationFunctions2(S: Type, R: Type): with map(fn, eqn) == equation(fn lhs eqn, fn rhs eqn) @ -\section{category FEVALAB FullyEvalableOver} -<>= -)abbrev category FEVALAB FullyEvalableOver -++ Author: -++ Date Created: -++ Date Last Updated: June 3, 1991 -++ Basic Operations: -++ Related Domains: Equation -++ Also See: -++ AMS Classifications: -++ Keywords: equation -++ Examples: -++ References: -++ Description: -++ This category provides a selection of evaluation operations -++ depending on what the argument type R provides. -FullyEvalableOver(R:SetCategory): Category == with - map: (R -> R, $) -> $ - ++ map(f, ex) evaluates ex, applying f to values of type R in ex. - if R has Eltable(R, R) then Eltable(R, $) - if R has Evalable(R) then Evalable(R) - if R has InnerEvalable(Symbol, R) then InnerEvalable(Symbol, R) - add - if R has Eltable(R, R) then - elt(x:$, r:R) == map(#1.r, x) - - if R has Evalable(R) then - eval(x:$, l:List Equation R) == map(eval(#1, l), x) - - if R has InnerEvalable(Symbol, R) then - eval(x:$, ls:List Symbol, lv:List R) == map(eval(#1, ls, lv), x) - -@ \section{License} <>= --Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. @@ -506,7 +473,6 @@ FullyEvalableOver(R:SetCategory): Category == with <> <> -<> @ \eject \begin{thebibliography}{99} diff --git a/src/algebra/seg.spad.pamphlet b/src/algebra/seg.spad.pamphlet index 31740f6..a56e519 100644 --- a/src/algebra/seg.spad.pamphlet +++ b/src/algebra/seg.spad.pamphlet @@ -9,84 +9,6 @@ \eject \tableofcontents \eject -\section{category SEGCAT SegmentCategory} -<>= -)abbrev category SEGCAT SegmentCategory -++ Author: Stephen M. Watt -++ Date Created: December 1986 -++ Date Last Updated: June 3, 1991 -++ Basic Operations: -++ Related Domains: -++ Also See: -++ AMS Classifications: -++ Keywords: range, segment -++ Examples: -++ References: -++ Description: -++ This category provides operations on ranges, or {\em segments} -++ as they are called. - -SegmentCategory(S:Type): Category == Type with - SEGMENT: (S, S) -> % - ++ \spad{l..h} creates a segment with l and h as the endpoints. - BY: (%, Integer) -> % - ++ \spad{s by n} creates a new segment in which only every \spad{n}-th - ++ element is used. - lo: % -> S - ++ lo(s) returns the first endpoint of s. - ++ Note: \spad{lo(l..h) = l}. - hi: % -> S - ++ hi(s) returns the second endpoint of s. - ++ Note: \spad{hi(l..h) = h}. - low: % -> S - ++ low(s) returns the first endpoint of s. - ++ Note: \spad{low(l..h) = l}. - high: % -> S - ++ high(s) returns the second endpoint of s. - ++ Note: \spad{high(l..h) = h}. - incr: % -> Integer - ++ incr(s) returns \spad{n}, where s is a segment in which every - ++ \spad{n}-th element is used. - ++ Note: \spad{incr(l..h by n) = n}. - segment: (S, S) -> % - ++ segment(i,j) is an alternate way to create the segment \spad{i..j}. - convert: S -> % - ++ convert(i) creates the segment \spad{i..i}. - -@ -\section{category SEGXCAT SegmentExpansionCategory} -<>= -)abbrev category SEGXCAT SegmentExpansionCategory -++ Author: Stephen M. Watt -++ Date Created: June 5, 1991 -++ Date Last Updated: -++ Basic Operations: -++ Related Domains: Segment, UniversalSegment -++ Also See: -++ AMS Classifications: -++ Keywords: -++ Examples: -++ References: -++ Description: -++ This category provides an interface for expanding segments to -++ a stream of elements. -SegmentExpansionCategory(S: OrderedRing, L: StreamAggregate(S)): Category == - SegmentCategory(S) with - expand: List % -> L - ++ expand(l) creates a new value of type L in which each segment - ++ \spad{l..h by k} is replaced with \spad{l, l+k, ... lN}, - ++ where \spad{lN <= h < lN+k}. - ++ For example, \spad{expand [1..4, 7..9] = [1,2,3,4,7,8,9]}. - expand: % -> L - ++ expand(l..h by k) creates value of type L with elements - ++ \spad{l, l+k, ... lN} where \spad{lN <= h < lN+k}. - ++ For example, \spad{expand(1..5 by 2) = [1,3,5]}. - map: (S -> S, %) -> L - ++ map(f,l..h by k) produces a value of type L by applying f - ++ to each of the succesive elements of the segment, that is, - ++ \spad{[f(l), f(l+k), ..., f(lN)]}, where \spad{lN <= h < lN+k}. - -@ \section{domain SEG Segment} <>= -- seg.spad.pamphlet Segment.input @@ -938,8 +860,6 @@ IncrementingMaps(R:Join(Monoid, AbelianSemiGroup)): with <<*>>= <> -<> -<> <> <> <> diff --git a/src/algebra/sex.spad.pamphlet b/src/algebra/sex.spad.pamphlet index 90fdea7..554af3c 100644 --- a/src/algebra/sex.spad.pamphlet +++ b/src/algebra/sex.spad.pamphlet @@ -9,84 +9,6 @@ \eject \tableofcontents \eject -\section{category SEXCAT SExpressionCategory} -<>= -)abbrev category SEXCAT SExpressionCategory -++ Category for Lisp values -++ Author: S.M.Watt -++ Date Created: July 1987 -++ Date Last Modified: 23 May 1991 -++ Description: -++ This category allows the manipulation of Lisp values while keeping -++ the grunge fairly localized. --- The coerce to expression lets the --- values be displayed in the usual parenthesized way (displaying --- them as type Expression can cause the formatter to die, since --- certain magic cookies are in unexpected places). --- SMW July 87 -SExpressionCategory(Str, Sym, Int, Flt, Expr): Category == Decl where - Str, Sym, Int, Flt, Expr: SetCategory - - Decl ==> SetCategory with - eq: (%,%) -> Boolean - ++ eq(s, t) is true if EQ(s,t) is true in Lisp. - null?: % -> Boolean - ++ null?(s) is true if s is the S-expression (). - atom?: % -> Boolean - ++ atom?(s) is true if s is a Lisp atom. - pair?: % -> Boolean - ++ pair?(s) is true if s has is a non-null Lisp list. - list?: % -> Boolean - ++ list?(s) is true if s is a Lisp list, possibly (). - string?: % -> Boolean - ++ string?(s) is true if s is an atom and belong to Str. - symbol?: % -> Boolean - ++ symbol?(s) is true if s is an atom and belong to Sym. - integer?: % -> Boolean - ++ integer?(s) is true if s is an atom and belong to Int. - float?: % -> Boolean - ++ float?(s) is true if s is an atom and belong to Flt. - destruct: % -> List % - ++ destruct((a1,...,an)) returns the list [a1,...,an]. - string: % -> Str - ++ string(s) returns s as an element of Str. - ++ Error: if s is not an atom that also belongs to Str. - symbol: % -> Sym - ++ symbol(s) returns s as an element of Sym. - ++ Error: if s is not an atom that also belongs to Sym. - integer: % -> Int - ++ integer(s) returns s as an element of Int. - ++ Error: if s is not an atom that also belongs to Int. - float: % -> Flt - ++ float(s) returns s as an element of Flt; - ++ Error: if s is not an atom that also belongs to Flt. - expr: % -> Expr - ++ expr(s) returns s as an element of Expr; - ++ Error: if s is not an atom that also belongs to Expr. - convert: List % -> % - ++ convert([a1,...,an]) returns the S-expression \spad{(a1,...,an)}. - convert: Str -> % - ++ convert(x) returns the Lisp atom x; - convert: Sym -> % - ++ convert(x) returns the Lisp atom x. - convert: Int -> % - ++ convert(x) returns the Lisp atom x. - convert: Flt -> % - ++ convert(x) returns the Lisp atom x. - convert: Expr -> % - ++ convert(x) returns the Lisp atom x. - car: % -> % - ++ car((a1,...,an)) returns a1. - cdr: % -> % - ++ cdr((a1,...,an)) returns \spad{(a2,...,an)}. - "#": % -> Integer - ++ #((a1,...,an)) returns n. - elt: (%, Integer) -> % - ++ elt((a1,...,an), i) returns \spad{ai}. - elt: (%, List Integer) -> % - ++ elt((a1,...,an), [i1,...,im]) returns \spad{(a_i1,...,a_im)}. - -@ \section{domain SEXOF SExpressionOf} <>= )abbrev domain SEXOF SExpressionOf @@ -206,7 +128,6 @@ SExpression() <<*>>= <> -<> <> <> @ diff --git a/src/algebra/space.spad.pamphlet b/src/algebra/space.spad.pamphlet index 1f1235d..bf4b19f 100644 --- a/src/algebra/space.spad.pamphlet +++ b/src/algebra/space.spad.pamphlet @@ -9,288 +9,6 @@ \eject \tableofcontents \eject -\section{category SPACEC ThreeSpaceCategory} -<>= -)abbrev category SPACEC ThreeSpaceCategory -++ Author: -++ Date Created: -++ Date Last Updated: -++ Basic Operations: create3Space, numberOfComponents, numberOfComposites, -++ merge, composite, components, copy, enterPointData, modifyPointData, point, -++ point?, curve, curve?, closedCurve, closedCurve?, polygon, polygon? mesh, -++ mesh?, lp, lllip, lllp, llprop, lprop, objects, check, subspace, coerce -++ Related Constructors: -++ Also See: -++ AMS Classifications: -++ Keywords: -++ References: -++ Description: The category ThreeSpaceCategory is used for creating -++ three dimensional objects using functions for defining points, curves, -++ polygons, constructs and the subspaces containing them. - -ThreeSpaceCategory(R:Ring): Exports == Implementation where - I ==> Integer - PI ==> PositiveInteger - NNI ==> NonNegativeInteger - L ==> List - B ==> Boolean - O ==> OutputForm - SUBSPACE ==> SubSpace(3,R) - POINT ==> Point(R) - PROP ==> SubSpaceComponentProperty() - REP3D ==> Record(lp:L POINT,llliPt:L L L NNI, llProp:L L PROP, lProp:L PROP) - OBJ3D ==> Record(points:NNI, curves:NNI, polygons:NNI, constructs:NNI) - - Exports ==> Category - Implementation ==> - SetCategory with - create3Space : () -> % - ++ create3Space() creates a \spadtype{ThreeSpace} object capable of - ++ holding point, curve, mesh components and any combination. - create3Space : SUBSPACE -> % - ++ create3Space(s) creates a \spadtype{ThreeSpace} object containing - ++ objects pre-defined within some \spadtype{SubSpace} s. - numberOfComponents : % -> NNI - ++ numberOfComponents(s) returns the number of distinct - ++ object components in the indicated \spadtype{ThreeSpace}, s, such - ++ as points, curves, polygons, and constructs. - numberOfComposites : % -> NNI - ++ numberOfComposites(s) returns the number of supercomponents, - ++ or composites, in the \spadtype{ThreeSpace}, s; Composites are - ++ arbitrary groupings of otherwise distinct and unrelated components; - ++ A \spadtype{ThreeSpace} need not have any composites defined at all - ++ and, outside of the requirement that no component can belong - ++ to more than one composite at a time, the definition and - ++ interpretation of composites are unrestricted. - merge : L % -> % - ++ merge([s1,s2,...,sn]) will create a new \spadtype{ThreeSpace} that has - ++ the components of all the ones in the list; Groupings of components - ++ into composites are maintained. - merge : (%,%) -> % - ++ merge(s1,s2) will create a new \spadtype{ThreeSpace} that has the - ++ components of \spad{s1} and \spad{s2}; Groupings of components - ++ into composites are maintained. - composite : L % -> % - ++ composite([s1,s2,...,sn]) will create a new \spadtype{ThreeSpace} that - ++ is a union of all the components from each \spadtype{ThreeSpace} in - ++ the parameter list, grouped as a composite. - components : % -> L % - ++ components(s) takes the \spadtype{ThreeSpace} s, and creates a list - ++ containing a unique \spadtype{ThreeSpace} for each single component - ++ of s. If s has no components defined, the list returned is empty. - composites : % -> L % - ++ composites(s) takes the \spadtype{ThreeSpace} s, and creates a list - ++ containing a unique \spadtype{ThreeSpace} for each single composite - ++ of s. If s has no composites defined (composites need to be explicitly - ++ created), the list returned is empty. Note that not all the components - ++ need to be part of a composite. - copy : % -> % - ++ copy(s) returns a new \spadtype{ThreeSpace} that is an exact copy of s. - enterPointData : (%,L POINT) -> NNI - ++ enterPointData(s,[p0,p1,...,pn]) adds a list of points from p0 through - ++ pn to the \spadtype{ThreeSpace}, s, and returns the index, to the - ++ starting point of the list; - modifyPointData : (%,NNI,POINT) -> % - ++ modifyPointData(s,i,p) changes the point at the indexed - ++ location i in the \spadtype{ThreeSpace}, s, to that of point p. - ++ This is useful for making changes to a point which has been - ++ transformed. - - -- 3D primitives - point : (%,POINT) -> % - ++ point(s,p) adds a point component defined by the point, p, specified as - ++ a list from \spad{List(R)}, to the \spadtype{ThreeSpace}, s, - ++ where R is the \spadtype{Ring} over which the point is defined. - point : (%,L R) -> % - ++ point(s,[x,y,z]) adds a point component defined by a list of elements - ++ which are from the \spad{PointDomain(R)} to the \spadtype{ThreeSpace}, - ++ s, where R is the \spadtype{Ring} over which the point elements are - ++ defined. - point : (%,NNI) -> % - ++ point(s,i) adds a point component which is placed into a component - ++ list of the \spadtype{ThreeSpace}, s, at the index given by i. - point : POINT -> % - ++ point(p) returns a \spadtype{ThreeSpace} object which is composed of - ++ one component, the point p. - point : % -> POINT - ++ point(s) checks to see if the \spadtype{ThreeSpace}, s, is composed of - ++ only a single point and if so, returns the point. An error - ++ is signaled otherwise. - point? : % -> B - ++ point?(s) queries whether the \spadtype{ThreeSpace}, s, is composed of - ++ a single component which is a point and returns the boolean result. - curve : (%,L POINT) -> % - ++ curve(s,[p0,p1,...,pn]) adds a space curve component defined by a - ++ list of points \spad{p0} through \spad{pn}, to the \spadtype{ThreeSpace} s. - curve : (%,L L R) -> % - ++ curve(s,[[p0],[p1],...,[pn]]) adds a space curve which is a list of - ++ points p0 through pn defined by lists of elements from the domain - ++ \spad{PointDomain(m,R)}, where R is the \spadtype{Ring} over which the - ++ point elements are defined and m is the dimension of the points, to - ++ the \spadtype{ThreeSpace} s. - curve : L POINT -> % - ++ curve([p0,p1,p2,...,pn]) creates a space curve defined - ++ by the list of points \spad{p0} through \spad{pn}, and returns the - ++ \spadtype{ThreeSpace} whose component is the curve. - curve : % -> L POINT - ++ curve(s) checks to see if the \spadtype{ThreeSpace}, s, is composed of - ++ a single curve defined by a list of points and if so, returns the - ++ curve, i.e., list of points. An error is signaled otherwise. - curve? : % -> B - ++ curve?(s) queries whether the \spadtype{ThreeSpace}, s, is a curve, - ++ i.e., has one component, a list of list of points, and returns true if - ++ it is, or false otherwise. - closedCurve : (%,L POINT) -> % - ++ closedCurve(s,[p0,p1,...,pn,p0]) adds a closed curve component which is - ++ a list of points defined by the first element p0 through the last - ++ element pn and back to the first element p0 again, to the - ++ \spadtype{ThreeSpace} s. - closedCurve : (%,L L R) -> % - ++ closedCurve(s,[[lr0],[lr1],...,[lrn],[lr0]]) adds a closed curve - ++ component defined by a list of points \spad{lr0} through \spad{lrn}, - ++ which are lists of elements from the domain \spad{PointDomain(m,R)}, - ++ where R is the \spadtype{Ring} over which the point elements are - ++ defined and m is the dimension of the points, in which the last element - ++ of the list of points contains a copy of the first element list, lr0. - ++ The closed curve is added to the \spadtype{ThreeSpace}, s. - closedCurve : L POINT -> % - ++ closedCurve(lp) sets a list of points defined by the first element - ++ of lp through the last element of lp and back to the first elelment - ++ again and returns a \spadtype{ThreeSpace} whose component is the - ++ closed curve defined by lp. - closedCurve : % -> L POINT - ++ closedCurve(s) checks to see if the \spadtype{ThreeSpace}, s, is - ++ composed of a single closed curve component defined by a list of - ++ points in which the first point is also the last point, all of which - ++ are from the domain \spad{PointDomain(m,R)} and if so, returns the - ++ list of points. An error is signaled otherwise. - closedCurve? : % -> B - ++ closedCurve?(s) returns true if the \spadtype{ThreeSpace} s contains - ++ a single closed curve component, i.e., the first element of the curve - ++ is also the last element, or false otherwise. - polygon : (%,L POINT) -> % - ++ polygon(s,[p0,p1,...,pn]) adds a polygon component defined by a list of - ++ points, p0 throught pn, to the \spadtype{ThreeSpace} s. - polygon : (%,L L R) -> % - ++ polygon(s,[[r0],[r1],...,[rn]]) adds a polygon component defined - ++ by a list of points \spad{r0} through \spad{rn}, which are lists of - ++ elements from the domain \spad{PointDomain(m,R)} to the - ++ \spadtype{ThreeSpace} s, where m is the dimension of the points - ++ and R is the \spadtype{Ring} over which the points are defined. - polygon : L POINT -> % - ++ polygon([p0,p1,...,pn]) creates a polygon defined by a list of points, - ++ p0 through pn, and returns a \spadtype{ThreeSpace} whose component - ++ is the polygon. - polygon : % -> L POINT - ++ polygon(s) checks to see if the \spadtype{ThreeSpace}, s, is - ++ composed of a single polygon component defined by a list of - ++ points, and if so, returns the list of points; An error is signaled - ++ otherwise. - polygon? : % -> B - ++ polygon?(s) returns true if the \spadtype{ThreeSpace} s contains - ++ a single polygon component, or false otherwise. - mesh : (%,L L POINT,L PROP,PROP) -> % - ++ mesh(s,[[p0],[p1],...,[pn]],[props],prop) adds a surface component, - ++ defined over a list curves which contains lists of points, to the - ++ \spadtype{ThreeSpace} s; props is a list which contains the subspace - ++ component properties for each surface parameter, and prop is the - ++ subspace component property by which the points are defined. - mesh : (%,L L L R,L PROP,PROP) -> % - ++ mesh(s,[ [[r10]...,[r1m]], [[r20]...,[r2m]],..., [[rn0]...,[rnm]] ], [props], prop) - ++ adds a surface component to the \spadtype{ThreeSpace} s, which is - ++ defined over a rectangular domain of size WxH where W is the number - ++ of lists of points from the domain \spad{PointDomain(R)} and H is the - ++ number of elements in each of those lists; lprops is the list of the - ++ subspace component properties for each curve list, and prop is - ++ the subspace component property by which the points are defined. - mesh : (%,L L POINT,B,B) -> % - ++ mesh(s,[[p0],[p1],...,[pn]], close1, close2) adds a surface component to - ++ the \spadtype{ThreeSpace}, which is defined over a list of curves, - ++ in which each of these curves is a list of points. - ++ The boolean arguments close1 and close2 indicate how the surface - ++ is to be closed. Argument close1 equal true - ++ means that each individual list (a curve) is to be closed, i.e. the - ++ last point of the list is to be connected to the first point. - ++ Argument close2 equal true - ++ means that the boundary at one end of the surface is to be - ++ connected to the boundary at the other end, i.e. the boundaries - ++ are defined as the first list of points (curve) and - ++ the last list of points (curve). - mesh : (%,L L L R,B,B) -> % - ++ mesh(s,[ [[r10]...,[r1m]], [[r20]...,[r2m]],..., [[rn0]...,[rnm]] ], close1, close2) - ++ adds a surface component to the \spadtype{ThreeSpace} s, which is - ++ defined over a rectangular domain of size WxH where W is the number - ++ of lists of points from the domain \spad{PointDomain(R)} and H is the - ++ number of elements in each of those lists; the booleans close1 and - ++ close2 indicate how the surface is to be closed: if close1 is true - ++ this means that each individual list (a curve) is to be closed (i.e., - ++ the last point of the list is to be connected to the first point); - ++ if close2 is true, this means that the boundary at one end of the - ++ surface is to be connected to the boundary at the other end - ++ (the boundaries are defined as the first list of points (curve) - ++ and the last list of points (curve)). - mesh : L L POINT -> % - ++ mesh([[p0],[p1],...,[pn]]) creates a surface defined by a list of - ++ curves which are lists, p0 through pn, of points, and returns a - ++ \spadtype{ThreeSpace} whose component is the surface. - mesh : (L L POINT,B,B) -> % - ++ mesh([[p0],[p1],...,[pn]], close1, close2) creates a surface defined - ++ over a list of curves, p0 through pn, which are lists of points; - ++ the booleans close1 and close2 indicate how the surface is to be - ++ closed: close1 set to true means that each individual list (a curve) - ++ is to be closed (that is, the last point of the list is to be - ++ connected to the first point); close2 set to true means that the - ++ boundary at one end of the surface is to be connected to the boundary - ++ at the other end (the boundaries are defined as the first list of - ++ points (curve) and the last list of points (curve)); the - ++ \spadtype{ThreeSpace} containing this surface is returned. - mesh : % -> L L POINT - ++ mesh(s) checks to see if the \spadtype{ThreeSpace}, s, is - ++ composed of a single surface component defined by a list curves which - ++ contain lists of points, and if so, returns the list of lists of - ++ points; An error is signaled otherwise. - mesh? : % -> B - ++ mesh?(s) returns true if the \spadtype{ThreeSpace} s is composed of one - ++ component, a mesh comprising a list of curves which are lists - ++ of points, or returns false if otherwise - lp : % -> L POINT - ++ lp(s) returns the list of points component which the - ++ \spadtype{ThreeSpace}, s, contains; these points are used by reference, - ++ i.e., the component holds indices referring to the points rather - ++ than the points themselves. This allows for sharing of the points. - lllip : % -> L L L NNI - ++ lllip(s) checks to see if the \spadtype{ThreeSpace}, s, is - ++ composed of a list of components, which are lists of curves, - ++ which are lists of indices to points, and if so, returns the list of - ++ lists of lists; An error is signaled otherwise. - lllp : % -> L L L POINT -- used by view3D - ++ lllp(s) checks to see if the \spadtype{ThreeSpace}, s, is - ++ composed of a list of components, which are lists of curves, - ++ which are lists of points, and if so, returns the list of - ++ lists of lists; An error is signaled otherwise. - llprop : % -> L L PROP -- used by view3D - ++ llprop(s) checks to see if the \spadtype{ThreeSpace}, s, is - ++ composed of a list of curves which are lists of the - ++ subspace component properties of the curves, and if so, returns the - ++ list of lists; An error is signaled otherwise. - lprop : % -> L PROP -- used by view3D - ++ lprop(s) checks to see if the \spadtype{ThreeSpace}, s, is - ++ composed of a list of subspace component properties, and if so, - ++ returns the list; An error is signaled otherwise. - objects : % -> OBJ3D - ++ objects(s) returns the \spadtype{ThreeSpace}, s, in the form of a - ++ 3D object record containing information on the number of points, - ++ curves, polygons and constructs comprising the \spadtype{ThreeSpace}.. - check : % -> % -- used by mesh - ++ check(s) returns lllpt, list of lists of lists of point information - ++ about the \spadtype{ThreeSpace} s. - subspace : % -> SUBSPACE - ++ subspace(s) returns the \spadtype{SubSpace} which holds all the point - ++ information in the \spadtype{ThreeSpace}, s. - coerce : % -> O - ++ coerce(s) returns the \spadtype{ThreeSpace} s to Output format. - -@ \section{domain SPACE3 ThreeSpace} <>= )abbrev domain SPACE3 ThreeSpace @@ -689,7 +407,6 @@ TopLevelThreeSpace(): with <<*>>= <> -<> <> <> @ diff --git a/src/algebra/stream.spad.pamphlet b/src/algebra/stream.spad.pamphlet index e30e3b4..b3e1e18 100644 --- a/src/algebra/stream.spad.pamphlet +++ b/src/algebra/stream.spad.pamphlet @@ -9,528 +9,6 @@ \eject \tableofcontents \eject -\section{category LZSTAGG LazyStreamAggregate} -<>= -)abbrev category LZSTAGG LazyStreamAggregate -++ Category of streams with lazy evaluation -++ Author: Clifton J. Williamson -++ Date Created: 22 November 1989 -++ Date Last Updated: 20 July 1990 -++ Keywords: stream, infinite list, infinite sequence -++ Description: -++ LazyStreamAggregate is the category of streams with lazy -++ evaluation. It is understood that the function 'empty?' will -++ cause lazy evaluation if necessary to determine if there are -++ entries. Functions which call 'empty?', e.g. 'first' and 'rest', -++ will also cause lazy evaluation if necessary. - -LazyStreamAggregate(S:Type): Category == StreamAggregate(S) with - remove: (S -> Boolean,%) -> % - ++ remove(f,st) returns a stream consisting of those elements of stream - ++ st which do not satisfy the predicate f. - ++ Note: \spad{remove(f,st) = [x for x in st | not f(x)]}. - ++ - ++X m:=[i for i in 1..] - ++X f(i:PositiveInteger):Boolean == even? i - ++X remove(f,m) - - select: (S -> Boolean,%) -> % - ++ select(f,st) returns a stream consisting of those elements of stream - ++ st satisfying the predicate f. - ++ Note: \spad{select(f,st) = [x for x in st | f(x)]}. - ++ - ++X m:=[i for i in 0..] - ++X select(x+->prime? x,m) - - explicitEntries?: % -> Boolean - ++ explicitEntries?(s) returns true if the stream s has - ++ explicitly computed entries, and false otherwise. - ++ - ++X m:=[i for i in 0..] - ++X explicitEntries? m - - explicitlyEmpty?: % -> Boolean - ++ explicitlyEmpty?(s) returns true if the stream is an - ++ (explicitly) empty stream. - ++ Note: this is a null test which will not cause lazy evaluation. - ++ - ++X m:=[i for i in 0..] - ++X explicitlyEmpty? m - - lazy?: % -> Boolean - ++ lazy?(s) returns true if the first node of the stream s - ++ is a lazy evaluation mechanism which could produce an - ++ additional entry to s. - ++ - ++X m:=[i for i in 0..] - ++X lazy? m - - lazyEvaluate: % -> % - ++ lazyEvaluate(s) causes one lazy evaluation of stream s. - ++ Caution: the first node must be a lazy evaluation mechanism - ++ (satisfies \spad{lazy?(s) = true}) as there is no error check. - ++ Note: a call to this function may - ++ or may not produce an explicit first entry - frst: % -> S - ++ frst(s) returns the first element of stream s. - ++ Caution: this function should only be called after a \spad{empty?} test - ++ has been made since there no error check. - ++ - ++X m:=[i for i in 0..] - ++X frst m - - rst: % -> % - ++ rst(s) returns a pointer to the next node of stream s. - ++ Caution: this function should only be called after a \spad{empty?} test - ++ has been made since there no error check. - ++ - ++X m:=[i for i in 0..] - ++X rst m - - numberOfComputedEntries: % -> NonNegativeInteger - ++ numberOfComputedEntries(st) returns the number of explicitly - ++ computed entries of stream st which exist immediately prior to the time - ++ this function is called. - ++ - ++X m:=[i for i in 0..] - ++X numberOfComputedEntries m - - extend: (%,Integer) -> % - ++ extend(st,n) causes entries to be computed, if necessary, - ++ so that 'st' will have at least 'n' explicit entries or so - ++ that all entries of 'st' will be computed if 'st' is finite - ++ with length <= n. - ++ - ++X m:=[i for i in 0..] - ++X numberOfComputedEntries m - ++X extend(m,20) - ++X numberOfComputedEntries m - - complete: % -> % - ++ complete(st) causes all entries of 'st' to be computed. - ++ this function should only be called on streams which are - ++ known to be finite. - ++ - ++X m:=[i for i in 1..] - ++X n:=filterUntil(i+->i>100,m) - ++X numberOfComputedEntries n - ++X complete n - ++X numberOfComputedEntries n - - add - - MIN ==> 1 -- minimal stream index - - I ==> Integer - NNI ==> NonNegativeInteger - L ==> List - U ==> UniversalSegment Integer - - indexx? : (Integer,%) -> Boolean - cycleElt : % -> Union(%,"failed") - computeCycleLength : % -> NNI - computeCycleEntry : (%,%) -> % - ---% SETCAT functions - - if S has SetCategory then - - x = y == - eq?(x,y) => true - explicitlyFinite? x and explicitlyFinite? y => - entries x = entries y - explicitEntries? x and explicitEntries? y => - frst x = frst y and EQ(rst x, rst y)$Lisp - -- treat cyclic streams - false - ---% HOAGG functions - - --null x == empty? x - - less?(x,n) == - n = 0 => false - empty? x => true - less?(rst x,(n-1) :: NNI) - - more?(x,n) == - empty? x => false - n = 0 => true - more?(rst x,(n-1) :: NNI) - - size?(x,n) == - empty? x => n = 0 - size?(rst x,(n-1) :: NNI) - - # x == - -- error if stream is not finite - y := x - for i in 0.. repeat - explicitlyEmpty? y => return i - lazy? y => error "#: infinite stream" - y := rst y - if odd? i then x := rst x - eq?(x,y) => error "#: infinite stream" - ---% CLAGG functions - - any?(f,x) == - -- error message only when x is a stream with lazy - -- evaluation and f(s) = false for all stream elements - -- 's' which have been computed when the function is - -- called - y := x - for i in 0.. repeat - explicitlyEmpty? y => return false - lazy? y => error "any?: infinite stream" - f frst y => return true - y := rst y - if odd? i then x := rst x - eq?(x,y) => return false - - every?(f,x) == - -- error message only when x is a stream with lazy - -- evaluation and f(s) = true for all stream elements - -- 's' which have been computed when the function is - -- called - y := x - for i in 0.. repeat - explicitlyEmpty? y => return true - lazy? y => error "every?: infinite stream" - not f frst y => return false - y := rst y - if odd? i then x := rst x - eq?(x,y) => return true - --- following ops count and member? are only exported if $ has finiteAggregate - --- count(f:S -> Boolean,x:%) == --- -- error if stream is not finite --- count : NNI := 0 --- y := x --- for i in 0.. repeat --- explicitlyEmpty? y => return count --- lazy? y => error "count: infinite stream" --- if f frst y then count := count + 1 --- y := rst y --- if odd? i then x := rst x --- eq?(x,y) => error "count: infinite stream" - - --- if S has SetCategory then - --- count(s:S,x:%) == count(#1 = s,x) --- -- error if stream is not finite - --- member?(s,x) == --- -- error message only when x is a stream with lazy --- -- evaluation and 's' is not among the stream elements --- -- which have been computed when the function is called --- y := x --- for i in 0.. repeat --- explicitlyEmpty? y => return false --- lazy? y => error "member?: infinite stream" --- frst y = s => return true --- y := rst y --- if odd? i then x := rst x --- eq?(x,y) => return false - - entries x == - -- returns a list of elements which have been computed - -- error if infinite - y := x - l : L S := empty() - for i in 0.. repeat - explicitlyEmpty? y => return reverse_! l - lazy? y => error "infinite stream" - l := concat(frst y,l) - y := rst y - if odd? i then x := rst x - eq?(x,y) => error "infinite stream" - ---% CNAGG functions - - construct l == - empty? l => empty() - concat(first l, construct rest l) - - --entries x == - -- returns a list of the stream elements - -- error if the stream is not finite - --members x - ---% ELTAGG functions - - elt(x:%,n:I) == - n < MIN or empty? x => error "elt: no such element" - n = MIN => frst x - elt(rst x,n - 1) - - elt(x:%,n:I,s:S) == - n < MIN or empty? x => s - n = MIN => frst x - elt(rst x,n - 1) - ---% IXAGG functions - --- following assumes % has finiteAggregate and S has SetCategory --- entry?(s,x) == --- -- error message only when x is a stream with lazy --- -- evaluation and 's' is not among the stream elements --- -- which have been computed when the function is called --- member?(s,x) - - --entries x == - -- error if the stream is not finite - --members x - - indexx?(n,x) == - empty? x => false - n = MIN => true - indexx?(n-1,rst x) - - index?(n,x) == - -- returns 'true' iff 'n' is the index of an entry which - -- may or may not have been computed when the function is - -- called - -- additional entries are computed if necessary - n < MIN => false - indexx?(n,x) - - indices x == - -- error if stream is not finite - y := x - l : L I := empty() - for i in MIN.. repeat - explicitlyEmpty? y => return reverse_! l - lazy? y => error "indices: infinite stream" - l := concat(i,l) - y := rst y - if odd? i then x := rst x - eq?(x,y) => error "indices: infinite stream" - - maxIndex x == - -- error if stream is not finite - empty? x => - error "maxIndex: no maximal index for empty stream" - y := rst x - for i in MIN.. repeat - explicitlyEmpty? y => return i - lazy? y => error "maxIndex: infinite stream" - y := rst y - if odd? i then x := rst x - eq?(x,y) => error "maxIndex: infinite stream" - - minIndex x == - empty? x => error "minIndex: no minimal index for empty stream" - MIN - ---% LNAGG functions - - delete(x:%,n:I) == - -- non-destructive - not index?(n,x) => error "delete: index out of range" - concat(first(x,(n - MIN) :: NNI), rest(x,(n - MIN + 1) :: NNI)) - - delete(x:%,seg:U) == - low := lo seg - hasHi seg => - high := hi seg - high < low => copy x - (not index?(low,x)) or (not index?(high,x)) => - error "delete: index out of range" - concat(first(x,(low - MIN) :: NNI),rest(x,(high - MIN + 1) :: NNI)) - not index?(low,x) => error "delete: index out of range" - first(x,(low - MIN) :: NNI) - - elt(x:%,seg:U) == - low := lo seg - hasHi seg => - high := hi seg - high < low => empty() - (not index?(low,x)) or (not index?(high,x)) => - error "elt: index out of range" - first(rest(x,(low - MIN) :: NNI),(high - low + 1) :: NNI) - not index?(low,x) => error "elt: index out of range" - rest(x,(low - MIN) :: NNI) - - insert(s:S,x:%,n:I) == - not index?(n,x) => error "insert: index out of range" - nn := (n - MIN) :: NNI - concat([first(x,nn), concat(s, empty()), rest(x,nn)]) - - insert(y:%,x:%,n:I) == - not index?(n,x) => error "insert: index out of range" - nn := (n - MIN) :: NNI - concat([first(x,nn), y, rest(x,nn)]) - ---% RCAGG functions - - cycleElt x == cycleElt(x)$CyclicStreamTools(S,%) - - cyclic? x == - cycleElt(x) case "failed" => false - true - - if S has SetCategory then - child?(x,y) == - empty? y => error "child: no children" - x = rst y - - children x == - empty? x => error "children: no children" - [rst x] - - distance(x,z) == - y := x - for i in 0.. repeat - eq?(y,z) => return i - (explicitlyEmpty? y) or (lazy? y) => - error "distance: 2nd arg not a descendent of the 1st" - y := rst y - if odd? i then x := rst x - eq?(x,y) => - error "distance: 2nd arg not a descendent of the 1st" - - if S has SetCategory then - node?(z,x) == - -- error message only when x is a stream with lazy - -- evaluation and 'y' is not a node of 'x' - -- which has been computed when the function is called - y := x - for i in 0.. repeat - z = y => return true - explicitlyEmpty? y => return false - lazy? y => error "node?: infinite stream" - y := rst y - if odd? i then x := rst x - eq?(x,y) => return false - - nodes x == - y := x - l : L % := [] - for i in 0.. repeat - explicitlyEmpty? y => return reverse_! l - lazy? y => error "nodes: infinite stream" - l := concat(y,l) - y := rst y - if odd? i then x := rst x - eq?(x,y) => error "nodes: infinite stream" - l -- @#$%^& compiler - - leaf? x == empty? rest x - - value x == first x - ---% URAGG functions - - computeCycleLength cycElt == - computeCycleLength(cycElt)$CyclicStreamTools(S,%) - - computeCycleEntry(x,cycElt) == - computeCycleEntry(x,cycElt)$CyclicStreamTools(S,%) - - cycleEntry x == - cycElt := cycleElt x - cycElt case "failed" => - error "cycleEntry: non-cyclic stream" - computeCycleEntry(x,cycElt::%) - - cycleLength x == - cycElt := cycleElt x - cycElt case "failed" => - error "cycleLength: non-cyclic stream" - computeCycleLength(cycElt::%) - - cycleTail x == - cycElt := cycleElt x - cycElt case "failed" => - error "cycleTail: non-cyclic stream" - y := x := computeCycleEntry(x,cycElt::%) - z := rst x - repeat - eq?(x,z) => return y - y := z ; z := rst z - - elt(x,"first") == first x - - first(x,n) == - -- former name: take - n = 0 or empty? x => empty() - concat(frst x, first(rst x,(n-1) :: NNI)) - - rest x == - empty? x => error "Can't take the rest of an empty stream." - rst x - - elt(x,"rest") == rest x - - rest(x,n) == - -- former name: drop - n = 0 or empty? x => x - rest(rst x,(n-1) :: NNI) - - last x == - -- error if stream is not finite - empty? x => error "last: empty stream" - y1 := x - y2 := rst x - for i in 0.. repeat - explicitlyEmpty? y2 => return frst y1 - lazy? y2 => error "last: infinite stream" - y1 := y2 - y2 := rst y2 - if odd? i then x := rst x - eq?(x,y2) => error "last: infinite stream" - - if % has finiteAggregate then -- # is only defined for finiteAggregates - last(x,n) == - possiblyInfinite? x => error "last: infinite stream" - m := # x - m < n => error "last: index out of range" - copy rest(x,(m-n)::NNI) - - elt(x,"last") == last x - - tail x == - -- error if stream is not finite - empty? x => error "tail: empty stream" - y1 := x - y2 := rst x - for i in 0.. repeat - explicitlyEmpty? y2 => return y1 - lazy? y2 => error "tail: infinite stream" - y1 := y2 - y2 := rst y2 - if odd? i then x := rst x - eq?(x,y2) => error "tail: infinite stream" - ---% STAGG functions - - possiblyInfinite? x == - y := x - for i in 0.. repeat - explicitlyEmpty? y => return false - lazy? y => return true - if odd? i then x := rst x - y := rst y - eq?(x,y) => return true - - explicitlyFinite? x == not possiblyInfinite? x - ---% LZSTAGG functions - - extend(x,n) == - y := x - for i in 1..n while not empty? y repeat y := rst y - x - - complete x == - y := x - while not empty? y repeat y := rst y - x - -@ \section{package CSTTOOLS CyclicStreamTools} <>= )abbrev package CSTTOOLS CyclicStreamTools @@ -1610,7 +1088,6 @@ StreamFunctions3(A,B,C): Exports == Implementation where <<*>>= <> -<> <> <> <> diff --git a/src/algebra/tree.spad.pamphlet b/src/algebra/tree.spad.pamphlet index ab2e87d..8208245 100644 --- a/src/algebra/tree.spad.pamphlet +++ b/src/algebra/tree.spad.pamphlet @@ -345,55 +345,6 @@ Tree(S: SetCategory): T==C where eqUnion(rest u, newV) @ -\section{category BTCAT BinaryTreeCategory} -<>= -)abbrev category BTCAT BinaryTreeCategory -++ Author:W. H. Burge -++ Date Created:17 Feb 1992 -++ Date Last Updated: -++ Basic Operations: -++ Related Domains: -++ Also See: -++ AMS Classifications: -++ Keywords: -++ Examples: -++ References: -++ Description: \spadtype{BinaryTreeCategory(S)} is the category of -++ binary trees: a tree which is either empty or else is a \spadfun{node} consisting -++ of a value and a \spadfun{left} and \spadfun{right}, both binary trees. -BinaryTreeCategory(S: SetCategory): Category == BinaryRecursiveAggregate(S) with - shallowlyMutable - ++ Binary trees have updateable components - finiteAggregate - ++ Binary trees have a finite number of components - node: (%,S,%) -> % - ++ node(left,v,right) creates a binary tree with value \spad{v}, a binary - ++ tree \spad{left}, and a binary tree \spad{right}. - ++ - add - cycleTreeMax ==> 5 - - copy t == - empty? t => empty() - node(copy left t, value t, copy right t) - if % has shallowlyMutable then - map_!(f,t) == - empty? t => t - t.value := f(t.value) - map_!(f,left t) - map_!(f,right t) - t - if % has finiteAggregate then - treeCount : (%, NonNegativeInteger) -> NonNegativeInteger - #t == treeCount(t,0) - treeCount(t,k) == - empty? t => k - k := k + 1 - k = cycleTreeMax and cyclic? t => error "cyclic binary tree" - k := treeCount(left t,k) - treeCount(right t,k) - -@ \section{domain BTREE BinaryTree} <>= )abbrev domain BTREE BinaryTree @@ -1185,7 +1136,6 @@ PendantTree(S: SetCategory): T == C where <<*>>= <> -<> <> <> <>