previous | index | next

Back to the Expression Evaluator

None of the shift/reduce expression evaluator code needs to be changed to accommodate this new stack ADT.

Application Advertised ADT Unadvertised
evaluate make-ra-stack make-node
process height node-element
shift? empty-ra-stack? node-rest
reduce? top-minus nodes-down
accept? pop! node-set-element!
tokenize push! node-set-rest!
reduce!
operator?
lower-precedence?
look-up-value

Just load the linked-list implementation of stacks (the unadvertised procedures).

Then evaluate can be used:

     (evaluate "(1+(2+(3+(4+(5+(6+(7+(8+9))))))))") ⇒ 45

previous | index | next