diff --git a/books/bookvol10.3.pamphlet b/books/bookvol10.3.pamphlet index 23ee487..c232fc0 100644 --- a/books/bookvol10.3.pamphlet +++ b/books/bookvol10.3.pamphlet @@ -1596,6 +1596,7 @@ Any(): SetCategory with %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{domain ASTACK ArrayStack} <>= +-- stack.spad.pamphlet Stack.input )sys rm -f ArrayStack.output )spool ArrayStack.output )set message test on @@ -1603,11 +1604,11 @@ Any(): SetCategory with )clear all --S 1 of 44 -a:Stack INT:= stack [1,2,3,4,5] +a:ArrayStack INT:= arrayStack [1,2,3,4,5] --R --R --R (1) [1,2,3,4,5] ---R Type: Stack Integer +--R Type: ArrayStack Integer --E 1 --S 2 of 44 @@ -1623,14 +1624,14 @@ a --R --R --R (3) [2,3,4,5] ---R Type: Stack Integer +--R Type: ArrayStack Integer --E 3 --S 4 of 44 -push!(9,a) +extract! a --R --R ---R (4) 9 +--R (4) 2 --R Type: PositiveInteger --E 4 @@ -1638,98 +1639,578 @@ push!(9,a) a --R --R ---R (5) [9,2,3,4,5] ---R Type: Stack Integer +--R (5) [3,4,5] +--R Type: ArrayStack Integer --E 5 --S 6 of 44 -empty? a +push!(9,a) --R --R ---R (6) false ---R Type: Boolean +--R (6) 9 +--R Type: PositiveInteger --E 6 --S 7 of 44 -b:=empty()$(Stack INT) +a --R --R ---R (7) [] ---R Type: Stack Integer +--R (7) [9,3,4,5] +--R Type: ArrayStack Integer --E 7 --S 8 of 44 +insert!(8,a) +--R +--R +--R (8) [8,9,3,4,5] +--R Type: ArrayStack Integer +--E 8 + +--S 9 of 44 +a +--R +--R +--R (9) [8,9,3,4,5] +--R Type: ArrayStack Integer +--E 9 + +--S 10 of 44 +inspect a +--R +--R +--R (10) 8 +--R Type: PositiveInteger +--E 10 + +--S 11 of 44 +empty? a +--R +--R +--R (11) false +--R Type: Boolean +--E 11 + +--S 12 of 44 +top a +--R +--R +--R (12) 8 +--R Type: PositiveInteger +--E 12 + +--S 13 of 44 +depth a +--R +--R +--R (13) 5 +--R Type: PositiveInteger +--E 13 + +--S 14 of 44 +#a +--R +--R +--R (14) 5 +--R Type: PositiveInteger +--E 14 + +--S 15 of 44 +less?(a,9) +--R +--R +--R (15) true +--R Type: Boolean +--E 15 + +--S 16 of 44 +more?(a,9) +--R +--R +--R (16) false +--R Type: Boolean +--E 16 + +--S 17 of 44 +size?(a,#a) +--R +--R +--R (17) true +--R Type: Boolean +--E 17 + +--S 18 of 44 +size?(a,9) +--R +--R +--R (18) false +--R Type: Boolean +--E 18 + +--S 19 of 44 +parts a +--R +--R +--R (19) [8,9,3,4,5] +--R Type: List Integer +--E 19 + +--S 20 of 44 +bag([1,2,3,4,5])$ArrayStack(INT) +--R +--R +--R (20) [5,4,3,2,1] +--R Type: ArrayStack Integer +--E 20 + +--S 21 of 44 +b:=empty()$(ArrayStack INT) +--R +--R +--R (21) [] +--R Type: ArrayStack Integer +--E 21 + +--S 22 of 44 empty? b --R --R ---R (8) true +--R (22) true --R Type: Boolean ---E 8 +--E 22 + +--S 23 of 44 +sample()$ArrayStack(INT) +--R +--R +--R (23) [] +--R Type: ArrayStack Integer +--E 23 + +--S 24 of 44 +c:=copy a +--R +--R +--R (24) [8,9,3,4,5] +--R Type: ArrayStack Integer +--E 24 + +--S 25 of 44 +eq?(a,c) +--R +--R +--R (25) false +--R Type: Boolean +--E 25 + +--S 26 of 44 +eq?(a,a) +--R +--R +--R (26) true +--R Type: Boolean +--E 26 + +--S 27 of 44 +(a=c)@Boolean +--R +--R +--R (27) true +--R Type: Boolean +--E 27 + +--S 28 of 44 +(a=a)@Boolean +--R +--R +--R (28) true +--R Type: Boolean +--E 28 + +--S 29 of 44 +a~=c +--R +--R +--R (29) false +--R Type: Boolean +--E 29 + +--S 30 of 44 +any?(x+->(x=4),a) +--R +--R +--R (30) true +--R Type: Boolean +--E 30 + +--S 31 of 44 +any?(x+->(x=11),a) +--R +--R +--R (31) false +--R Type: Boolean +--E 31 + +--S 32 of 44 +every?(x+->(x=11),a) +--R +--R +--R (32) false +--R Type: Boolean +--E 32 + +--S 33 of 44 +count(4,a) +--R +--R +--R (33) 1 +--R Type: PositiveInteger +--E 33 + +--S 34 of 44 +count(x+->(x>2),a) +--R +--R +--R (34) 5 +--R Type: PositiveInteger +--E 34 + +--S 35 of 44 +map(x+->x+10,a) +--R +--R +--R (35) [18,19,13,14,15] +--R Type: ArrayStack Integer +--E 35 + +--S 36 of 44 +a +--R +--R +--R (36) [8,9,3,4,5] +--R Type: ArrayStack Integer +--E 36 + +--S 37 of 44 +map!(x+->x+10,a) +--R +--R +--R (37) [18,19,13,14,15] +--R Type: ArrayStack Integer +--E 37 + +--S 38 of 44 +a +--R +--R +--R (38) [18,19,13,14,15] +--R Type: ArrayStack Integer +--E 38 + +--S 39 of 44 +members a +--R +--R +--R (39) [18,19,13,14,15] +--R Type: List Integer +--E 39 + +--S 40 of 44 +member?(14,a) +--R +--R +--R (40) true +--R Type: Boolean +--E 40 + +--S 41 of 44 +coerce a +--R +--R +--R (41) [18,19,13,14,15] +--R Type: OutputForm +--E 41 + +--S 42 of 44 +hash a +--R +--R +--R (42) 0 +--R Type: SingleInteger +--E 42 + +--S 43 of 44 +latex a +--R +--R +--R (43) "\mbox{\bf Unimplemented}" +--R Type: String +--E 43 + +--S 44 of 44 +)show ArrayStack +--R +--R ArrayStack S: SetCategory is a domain constructor +--R Abbreviation for ArrayStack is ASTACK +--R This constructor is exposed in this frame. +--R Issue )edit bookvol10.3.spad.pamphlet to see algebra source code for ASTACK +--R +--R------------------------------- Operations -------------------------------- +--R arrayStack : List S -> % bag : List S -> % +--R copy : % -> % depth : % -> NonNegativeInteger +--R empty : () -> % empty? : % -> Boolean +--R eq? : (%,%) -> Boolean extract! : % -> S +--R insert! : (S,%) -> % inspect : % -> S +--R map : ((S -> S),%) -> % pop! : % -> S +--R push! : (S,%) -> S sample : () -> % +--R top : % -> S +--R #? : % -> NonNegativeInteger if $ has finiteAggregate +--R ?=? : (%,%) -> Boolean if S has SETCAT +--R any? : ((S -> Boolean),%) -> Boolean if $ has finiteAggregate +--R coerce : % -> OutputForm if S has SETCAT +--R count : (S,%) -> NonNegativeInteger if $ has finiteAggregate and S has SETCAT +--R count : ((S -> Boolean),%) -> NonNegativeInteger if $ has finiteAggregate +--R eval : (%,List S,List S) -> % if S has EVALAB S and S has SETCAT +--R eval : (%,S,S) -> % if S has EVALAB S and S has SETCAT +--R eval : (%,Equation S) -> % if S has EVALAB S and S has SETCAT +--R eval : (%,List Equation S) -> % if S has EVALAB S and S has SETCAT +--R every? : ((S -> Boolean),%) -> Boolean if $ has finiteAggregate +--R hash : % -> SingleInteger if S has SETCAT +--R latex : % -> String if S has SETCAT +--R less? : (%,NonNegativeInteger) -> Boolean +--R map! : ((S -> S),%) -> % if $ has shallowlyMutable +--R member? : (S,%) -> Boolean if $ has finiteAggregate and S has SETCAT +--R members : % -> List S if $ has finiteAggregate +--R more? : (%,NonNegativeInteger) -> Boolean +--R parts : % -> List S if $ has finiteAggregate +--R size? : (%,NonNegativeInteger) -> Boolean +--R ?~=? : (%,%) -> Boolean if S has SETCAT +--R +--E 44 )spool )lisp (bye) @ -<>= +<>= ==================================================================== -Stack examples +ArrayStack examples ==================================================================== -A Stack object is represented as a list ordered by last-in, first-out. +An ArrayStack object is represented as a list ordered by last-in, first-out. It operates like a pile of books, where the "next" book is the one -on the top of the pile. +on the top of the pile. -Here we create a stack of integers from a list. Notice that the +Here we create an array stack of integers from a list. Notice that the order in the list is the order in the stack. - a:Stack INT:= stack [1,2,3,4,5] - - (1) [1,2,3,4,5] + a:ArrayStack INT:= arrayStack [1,2,3,4,5] + [1,2,3,4,5] We can remove the top of the stack using pop!: pop! a - - (2) 1 + 1 Notice that the use of pop! is destructive (destructive operations in Axiom usually end with ! to indicate that the underylying data structure is changed). a + [2,3,4,5] + +The extract! operation is another name for the pop! operation and +has the same effect. This operation treats the stack as a BagAggregate: + + extract! a + 2 + +and you can see that it also has destructively modified the stack: - (3) [2,3,4,5] + a + [3,4,5] Next we push a new element on top of the stack: push!(9,a) - - (4) 9 + 9 Again, the push! operation is destructive so the stack is changed: a + [9,3,4,5] - (5) [9,2,3,4,5] +Another name for push! is insert!, which treats the stack as a BagAggregate: -We can ask if the stack is empty (boolean predicates in Axiom -generally end in a question mark): + insert!(8,a) + [8,9,3,4,5] + +and it modifies the stack: + + a + [8,9,3,4,5] + +The inspect function returns the top of the stack without modification, +viewed as a BagAggregate: + + inspect a + 8 + +The empty? operation returns true only if there are no element on the +stack, otherwise it returns false: empty? a + false - (6) false +The top operation returns the top of stack without modification, viewed +as a Stack: -We can create a new, empty stack: + top a + 8 - b:=empty()$(Stack INT) +The depth operation returns the number of elements on the stack: + + depth a + 5 + +which is the same as the # (length) operation: + + #a + 5 - (7) [] +The less? predicate will compare the stack length to an integer: + + less?(a,9) + true + +The more? predicate will compare the stack length to an integer: -And we can ask if b is empty: + more?(a,9) + false + +The size? operation will compare the stack length to an integer: + + size?(a,#a) + true + +and since the last computation must alwasy be true we try: + + size?(a,9) + false + +The parts function will return the stack as a list of its elements: + + parts a + [8,9,3,4,5] + +If we have a BagAggregate of elements we can use it to construct a stack. +Notice that the elements are pushed in reverse order: + + bag([1,2,3,4,5])$ArrayStack(INT) + [5,4,3,2,1] + +The empty function will construct an empty stack of a given type: + + b:=empty()$(ArrayStack INT) + [] + +and the empty? predicate allows us to find out if a stack is empty: empty? b + true + +The sample function returns a sample, empty stack: - (8) true + sample()$ArrayStack(INT) + [] + +We can copy a stack and it does not share storage so subsequent +modifications of the original stack will not affect the copy: + + c:=copy a + [8,9,3,4,5] + +The eq? function is only true if the lists are the same reference, +so even though c is a copy of a, they are not the same: + + eq?(a,c) + false + +However, a clearly shares a reference with itself: + + eq?(a,a) + true + +But we can compare a and c for equality: + + (a=c)@Boolean + true + +and clearly a is equal to itself: + + (a=a)@Boolean + true + +and since a and c are equal, they are clearly NOT not-equal: + + a~=c + false + +We can use the any? function to see if a predicate is true for any element: + + any?(x+->(x=4),a) + true + +or false for every element: + + any?(x+->(x=11),a) + false + +We can use the every? function to check every element satisfies a predicate: + + every?(x+->(x=11),a) + false + +We can count the elements that are equal to an argument of this type: + + count(4,a) + 1 + +or we can count against a boolean function: + + count(x+->(x>2),a) + 5 + +You can also map a function over every element, returning a new stack: + + map(x+->x+10,a) + [18,19,13,14,15] + +Notice that the orignal stack is unchanged: + + a + [8,9,3,4,5] + +You can use map! to map a function over every element and change +the original stack since map! is destructive: + + map!(x+->x+10,a) + [18,19,13,14,15] +o +Notice that the orignal stack has been changed: + + a + [18,19,13,14,15] + +The member function can also get the element of the stack as a list: + + members a + [18,19,13,14,15] + +and using member? we can test if the stack holds a given element: + + member?(14,a) + true See Also: o )show Stack @@ -1737,6 +2218,7 @@ o )show ArrayStack o )show Queue o )show Dequeue o )show Heap +o )show BagAggregate @ \pagehead{ArrayStack}{ASTACK} @@ -1785,7 +2267,7 @@ o )show Heap <>= )abbrev domain ASTACK ArrayStack -++ Author: Michael Monagan and Stephen Watt +++ Author: Michael Monagan, Stephen Watt, Timothy Daly ++ Date Created:June 86 and July 87 ++ Date Last Updated:Feb 92 ++ Basic Operations: @@ -1807,6 +2289,143 @@ ArrayStack(S:SetCategory): StackAggregate(S) with ++ ++E c:ArrayStack INT:= arrayStack [1,2,3,4,5] + -- Inherited Signatures repeated for examples documentation + + pop_! : % -> S + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X pop! a + ++X a + extract_! : % -> S + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X extract! a + ++X a + push_! : (S,%) -> S + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X push! a + ++X a + insert_! : (S,%) -> % + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X insert! a + ++X a + inspect : % -> S + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X inspect a + top : % -> S + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X top a + depth : % -> NonNegativeInteger + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X depth a + less? : (%,NonNegativeInteger) -> Boolean + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X less?(a,9) + more? : (%,NonNegativeInteger) -> Boolean + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X more?(a,9) + size? : (%,NonNegativeInteger) -> Boolean + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X size?(a,5) + bag : List S -> % + ++ + ++X bag([1,2,3,4,5])$ArrayStack(INT) + empty? : % -> Boolean + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X empty? a + empty : () -> % + ++ + ++X b:=empty()$(ArrayStack INT) + sample : () -> % + ++ + ++X sample()$ArrayStack(INT) + copy : % -> % + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X copy a + eq? : (%,%) -> Boolean + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X b:=copy a + ++X eq?(a,b) + map : ((S -> S),%) -> % + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X map(x+->x+10,a) + ++X a + if $ has shallowlyMutable then + map! : ((S -> S),%) -> % + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X map!(x+->x+10,a) + ++X a + if S has SetCategory then + latex : % -> String + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X latex a + hash : % -> SingleInteger + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X hash a + coerce : % -> OutputForm + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X coerce a + "=": (%,%) -> Boolean + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X b:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X (a=b)@Boolean + "~=" : (%,%) -> Boolean + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X b:=copy a + ++X (a~=b) + if % has finiteAggregate then + every? : ((S -> Boolean),%) -> Boolean + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X every?(x+->(x=4),a) + any? : ((S -> Boolean),%) -> Boolean + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X any?(x+->(x=4),a) + count : ((S -> Boolean),%) -> NonNegativeInteger + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X count(x+->(x>2),a) + _# : % -> NonNegativeInteger + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X #a + parts : % -> List S + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X parts a + members : % -> List S + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X members a + if % has finiteAggregate and S has SetCategory then + member? : (S,%) -> Boolean + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X member?(3,a) + count : (S,%) -> NonNegativeInteger + ++ + ++X a:ArrayStack INT:= arrayStack [1,2,3,4,5] + ++X count(4,a) + == add Rep := IndexedFlexibleArray(S,0) @@ -1826,13 +2445,18 @@ ArrayStack(S:SetCategory): StackAggregate(S) with push_!(e,s) == (concat(e,s); e) pop_! s == if empty? s then error "empty stack" - m := maxIndex s - r := s.m - delete_!(s,m) + r := s.0 + delete_!(s,0) r - top s == if empty? s then error "empty stack" else s.maxIndex(s) + top s == if empty? s then error "empty stack" else s.0 arrayStack l == construct(l)$Rep empty() == new(0,0 pretend S) + parts s == [s.i for i in 0..#s-1]::List(S) + map(f,s) == construct [f(s.i) for i in 0..#s-1] + map!(f,s) == ( for i in 0..#s-1 repeat qsetelt!(s,i,f(s.i)) ; s ) + inspect(s) == + if empty? s then error "empty stack" + qelt(s,0) @ <>= @@ -89527,287 +90151,311 @@ SquareMatrix(ndim,R): Exports == Implementation where )set message auto off )clear all ---S 1 of 41 +--S 1 of 44 a:Stack INT:= stack [1,2,3,4,5] --R --R (1) [1,2,3,4,5] --R Type: Stack Integer --E 1 ---S 2 of 41 +--S 2 of 44 pop! a --R --R (2) 1 --R Type: PositiveInteger --E 2 ---S 3 of 41 +--S 3 of 44 a --R --R (3) [2,3,4,5] --R Type: Stack Integer --E 3 ---S 4 of 41 +--S 4 of 44 extract! a --R --R (4) 2 --R Type: PositiveInteger --E 4 ---S 5 of 41 +--S 5 of 44 a --R --R (5) [3,4,5] --R Type: Stack Integer --E 5 ---S 6 of 41 +--S 6 of 44 push!(9,a) --R --R (6) 9 --R Type: PositiveInteger --E 6 ---S 7 of 41 +--S 7 of 44 a --R --R (7) [9,3,4,5] --R Type: Stack Integer --E 7 ---S 8 of 41 +--S 8 of 44 insert!(8,a) --R --R (8) [8,9,3,4,5] --R Type: Stack Integer --E 8 ---S 9 of 41 +--S 9 of 44 a --R --R (9) [8,9,3,4,5] --R Type: Stack Integer --E 9 ---S 10 of 41 +--S 10 of 44 inspect a --R --R (10) 8 --R Type: PositiveInteger --E 10 ---S 11 of 41 +--S 11 of 44 empty? a --R --R (11) false --R Type: Boolean --E 11 ---S 12 of 41 +--S 12 of 44 top a --R --R (12) 8 --R Type: PositiveInteger --E 12 ---S 13 of 41 +--S 13 of 44 depth a --R --R (13) 5 --R Type: PositiveInteger --E 13 ---S 14 of 41 +--S 14 of 44 #a --R --R (14) 5 --R Type: PositiveInteger --E 14 ---S 15 of 41 +--S 15 of 44 less?(a,9) --R --R (15) true --R Type: Boolean --E 15 ---S 16 of 41 +--S 16 of 44 more?(a,9) --R --R (16) false --R Type: Boolean --E 16 ---S 17 of 41 +--S 17 of 44 size?(a,#a) --R --R (17) true --R Type: Boolean --E 17 ---S 18 of 41 +--S 18 of 44 size?(a,9) --R --R (18) false --R Type: Boolean --E 18 ---S 19 of 41 +--S 19 of 44 parts a --R --R (19) [8,9,3,4,5] --R Type: List Integer --E 19 ---S 20 of 41 +--S 20 of 44 bag([1,2,3,4,5])$Stack(INT) --R --R (20) [5,4,3,2,1] --R Type: Stack Integer --E 20 ---S 21 of 41 +--S 21 of 44 b:=empty()$(Stack INT) --R --R (21) [] --R Type: Stack Integer --E 21 ---S 22 of 41 +--S 22 of 44 empty? b --R --R (22) true --R Type: Boolean --E 22 ---S 23 of 41 +--S 23 of 44 sample()$Stack(INT) --R --R (23) [] --R Type: Stack Integer --E 23 ---S 24 of 41 +--S 24 of 44 c:=copy a --R --R (24) [8,9,3,4,5] --R Type: Stack Integer --E 24 ---S 25 of 41 +--S 25 of 44 eq?(a,c) --R --R (25) false --R Type: Boolean --E 25 ---S 26 of 41 +--S 26 of 44 eq?(a,a) --R --R (26) true --R Type: Boolean --E 26 ---S 27 of 41 +--S 27 of 44 (a=c)@Boolean --R --R (27) true --R Type: Boolean --E 27 ---S 28 of 41 +--S 28 of 44 (a=a)@Boolean --R --R (28) true --R Type: Boolean --E 28 ---S 29 of 41 +--S 29 of 44 a~=c --R --R (29) false --R Type: Boolean --E 29 ---S 30 of 41 +--S 30 of 44 any?(x+->(x=4),a) --R --R (30) true --R Type: Boolean --E 30 ---S 31 of 41 +--S 31 of 44 any?(x+->(x=11),a) --R --R (31) false --R Type: Boolean --E 31 ---S 32 of 41 +--S 32 of 44 every?(x+->(x=11),a) --R --R (32) false --R Type: Boolean --E 32 ---S 33 of 41 +--S 33 of 44 count(4,a) --R --R (33) 1 --R Type: PositiveInteger --E 33 ---S 34 of 41 +--S 34 of 44 count(x+->(x>2),a) --R --R (34) 5 --R Type: PositiveInteger --E 34 ---S 35 of 41 +--S 35 of 44 map(x+->x+10,a) --R --R (35) [18,19,13,14,15] --R Type: Stack Integer --E 35 ---S 36 of 41 +--S 36 of 44 a --R --R (36) [8,9,3,4,5] --R Type: Stack Integer --E 36 ---S 37 of 41 +--S 37 of 44 map!(x+->x+10,a) --R --R (37) [18,19,13,14,15] --R Type: Stack Integer --E 37 ---S 38 of 41 +--S 38 of 44 a --R --R (38) [18,19,13,14,15] --R Type: Stack Integer --E 38 ---S 39 of 41 +--S 39 of 44 members a --R --R (39) [18,19,13,14,15] --R Type: List Integer --E 39 ---S 40 of 41 +--S 40 of 44 member?(14,a) --R --R (40) true --R Type: Boolean --E 40 ---S 41 of 41 +--S 41 of 44 +coerce a +--R +--R +--R (41) [18,19,13,14,15] +--R Type: OutputForm +--E 41 + +--S 42 of 44 +hash a +--R +--R +--R (42) 0 +--R Type: SingleInteger +--E 42 + +--S 43 of 44 +latex a +--R +--R +--R (43) "\mbox{\bf Unimplemented}" +--R Type: String +--E 43 + +--S 44 of 44 )show Stack --R Stack S: SetCategory is a domain constructor --R Abbreviation for Stack is STACK @@ -89845,7 +90493,7 @@ member?(14,a) --R size? : (%,NonNegativeInteger) -> Boolean --R ?~=? : (%,%) -> Boolean if S has SETCAT --R ---E 41 +--E 44 )spool )lisp (bye) @@ -89880,7 +90528,7 @@ structure is changed). The extract! operation is another name for the pop! operation and has the same effect. This operation treats the stack as a BagAggregate: -o extract! a + extract! a 2 and you can see that it also has destructively modified the stack: @@ -90227,6 +90875,18 @@ Stack(S:SetCategory): StackAggregate S with ++X map!(x+->x+10,a) ++X a if S has SetCategory then + latex : % -> String + ++ + ++X a:Stack INT:= stack [1,2,3,4,5] + ++X latex a + hash : % -> SingleInteger + ++ + ++X a:Stack INT:= stack [1,2,3,4,5] + ++X hash a + coerce : % -> OutputForm + ++ + ++X a:Stack INT:= stack [1,2,3,4,5] + ++X coerce a "=": (%,%) -> Boolean ++ ++X a:Stack INT:= stack [1,2,3,4,5] diff --git a/changelog b/changelog index 53741f2..140b82f 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,7 @@ +20090222 tpd src/axiom-website/patches.html 20090222.04.tpd.patch +20090222 tpd src/interp/Makefile add regression, help for ArrayStack +20090222 tpd books/bookvol10.3 add regression, help, examples for ArrayStack +20090222 tpd books/bookvol10.3 fix bugs 7172-7178 20090222 tpd src/axiom-website/patches.html 20090222.03.tpd.patch 20090222 tpd books/bookvol10.2 add documentation 20090222 tpd books/ps/v102algebrahierarchy.ps added diff --git a/src/algebra/Makefile.pamphlet b/src/algebra/Makefile.pamphlet index 841a1c1..4ed8ac9 100644 --- a/src/algebra/Makefile.pamphlet +++ b/src/algebra/Makefile.pamphlet @@ -16411,6 +16411,7 @@ This keeps the regression test list in the algebra Makefile. HELPFILE=${INT}/doc/help.helplist SPADHELP=\ + ${HELP}/ArrayStack.help \ ${HELP}/AssociationList.help ${HELP}/BalancedBinaryTree.help \ ${HELP}/BasicOperator.help ${HELP}/BinaryExpansion.help \ ${HELP}/BinarySearchTree.help ${HELP}/CardinalNumber.help \ @@ -16479,6 +16480,7 @@ is put into a int/Makefile.algebra and then executed by make. TESTSYS= ${OBJ}/${SYS}/bin/interpsys REGRESS=\ + ArrayStack.regress \ AssociationList.regress BalancedBinaryTree.regress \ BasicOperator.regress BinaryExpansion.regress \ BinarySearchTree.regress CardinalNumber.regress \ @@ -16560,6 +16562,15 @@ all: ${REGRESS} @echo algebra test cases complete. @ <>= +${HELP}/ArrayStack.help: ${BOOKS}/bookvol10.3.pamphlet + @echo 7078 create ArrayStack.help from ${BOOKS}/bookvol10.3.pamphlet + @${TANGLE} -R"ArrayStack.help" ${BOOKS}/bookvol10.3.pamphlet \ + >${HELP}/ArrayStack.help + @cp ${HELP}/ArrayStack.help ${HELP}/ASTACK.help + @${TANGLE} -R"ArrayStack.input" ${BOOKS}/bookvol10.3.pamphlet \ + >${INPUT}/ArrayStack.input + @echo "ArrayStack (ASTACK)" >>${HELPFILE} + ${HELP}/AssociationList.help: ${BOOKS}/bookvol10.3.pamphlet @echo 7000 create AssociationList.help from \ ${BOOKS}/bookvol10.3.pamphlet @@ -17412,7 +17423,7 @@ ${HELP}/Stack.help: ${BOOKS}/bookvol10.3.pamphlet @echo 7078 create Stack.help from ${BOOKS}/bookvol10.3.pamphlet @${TANGLE} -R"Stack.help" ${BOOKS}/bookvol10.3.pamphlet \ >${HELP}/Stack.help - @-cp ${HELP}/Stack.help ${HELP}/STREAM.help + @-cp ${HELP}/Stack.help ${HELP}/STACK.help @${TANGLE} -R"Stack.input" ${BOOKS}/bookvol10.3.pamphlet \ >${INPUT}/Stack.input @echo "Stack (STACK)" >>${HELPFILE} diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html index eaaedd1..03f2830 100644 --- a/src/axiom-website/patches.html +++ b/src/axiom-website/patches.html @@ -959,5 +959,7 @@ add Stephen Buchwald to credits
bookvol10.3 add regression, help, examples for Stack
20090222.03.tpd.patch bookvol10.2 add documentation
+20090222.04.tpd.patch +bookvol10.3 add regression, help, examples for ArrayStack