previous | index | next

RA-Stack Access

To implement top-minus, it will be helpful to have an operation analogous to "cdr-ing down" a list:
     (define nodes-down
       (lambda (n node-list)
	 (if (= n 0)
	     node-list
	     (nodes-down (- n 1) (node-rest node-list)))))

     (define top-minus
       (lambda (ra-stack offset)
	 (cond ((< offset 0)  ; Offset checking is same as before
		(error "TOP-MINUS: offset < 0" offset))
	       ((>= offset (height ra-stack))
		(error
		 "TOP-MINUS: offset too large for stack"
		 offset (height ra-stack)))
	       (else
		(node-element (nodes-down (+ offset 1) ra-stack))))))
                ; In first implementation this was a direct vector reference

previous | index | next