previous | index | next

Node Mutation

Pushing and popping require the ability to modify the parts of a node.

So define the following node mutators:

     (define node-set-element!
       (lambda (node new-element)
	 (vector-set! node 0 new-element)))

     (define node-set-rest!
       (lambda (node new-rest)
	 (vector-set! node 1 new-rest)))
To decrement a stack's height:
     (node-set-element! ra-stack (- (height ra-stack) 1))
To "jump around" a stack's top node:
     (node-set-rest! ra-stack (nodes-down 2 ra-stack))

previous | index | next