>>654
なるほど…スタックを使うんですね。
ちなみに私が用意してた解答はこんなのです。consは(陽には)使いません。
define (compare-leaves tree1 tree2)
 (define (next-leaf tree next yield)
  (cond ((null? tree) (next yield))
     ((not (pair? tree))
      (yield tree next))
     (else (next-leaf (car tree)
              (lambda (y) (next-leaf (cdr tree) next y))
              yield))))
 (define end-of-list '(unique-pair))
 (define (compare process1 process2 exit)
  (process1
   (lambda (leaf1 cont1)
    (process2
    (lambda (leaf2 cont2)
     (cond ((eq? leaf1 end-of-list) (exit (eq? leaf2 end-of-list)))
        ((eq? leaf2 end-of-list) (exit #f))
        ((eqv? leaf1 leaf2) (compare cont1 cont2 exit))
        (else (exit #f))))))))
 (call/cc (lambda (exit)
       (let ((no-more (lambda (yield) (yield end-of-list 'never-call-me))))
        (compare (lambda (co) (next-leaf tree1 no-more co))
            (lambda (co) (next-leaf tree2 no-more co))
            exit)))))