Welcome to the CHICKEN Scheme pasting service

Weird unwind pasted by elderK on Mon Feb 6 00:44:31 2012

(define (avl-tree-traverse origin stack key cont)
  (let loop ((parent '() ) (child origin) )
    (if (not (null? child) )
        (let ((child-key (avl-node-key child) )
              (loop-helper
               (lambda (subtree)
                 (if (not (null? parent) )
                     (avl-stack-push! stack
                                      (cons parent subtree) ) )
                 (loop child (avl-node-subtree child subtree) ) ) ) )
          (cond ((< key child-key) (loop-helper *l-subtree*) )
                ((> key child-key) (loop-helper *r-subtree*) ) ) ) )
    (cont stack parent child) ) )

It seems to continually call the continuation function - it climbs
up the "layers of the named-let". If you get my drift there.

It should only escape to the cont call at the end.

The idea is the child is either null (no subtree at this point)
or equal - it's not greater or less than. We only loop in the
condition that it's less than or greater.

Fixed! added by elderK on Mon Feb 6 01:07:21 2012

(define (avl-tree-traverse origin stack key cont)
  (let loop ((parent '() ) (child origin) )
    (if (null? child)
        (cont stack parent child)
        (let ((child-key (avl-node-key child) )
              (loop-helper
               (lambda (subtree)
                 (if (not (null? parent) )
                     (avl-stack-push! stack (cons parent subtree) ) )
                 (loop child (avl-node-subtree child subtree) ) ) ) )
          (cond ((< key child-key) (loop-helper *l-subtree*) )
                ((> key child-key) (loop-helper *r-subtree*) )
                (else (cont stack parent child) ) ) ) ) ) )

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
What's the result of `(let ((- +)) (- 4 3 8))'?
Visually impaired? Let me spell it for you (wav file) download WAV