title: The Seasoned Schemer: Intersectall (page 49)
body: <p>At page 49 of <em>The Seasoned Schemer</em>, I can't understand what is going on in the following code (lines 14-16):</p>
  
  <pre><code>(define intersectall
    (lambda (lset)
      (letcc hop
        (letrec
          ((A (lambda (lset)
                (cond ((null? (car lset)) (hop '()))
                      ((null? (cdr lset)) (car lset))
                      (else (I (car lset)
                               (A (cdr lset)))))))
           (I (lambda (s1 s2)
                (letrec
                  ((J (lambda (s1)
                        (cond ((null? s1) '())
                              ((member? (car s1) s2) (J (cdr s1)))  ; (14)
                              (else (cons (car s1)                  ; (15)
                                          (J (cdr s1))))))))        ; (16)
                   (cond ((null? s2) '())
                         (else (J s1)))))))
           (cond ((null? lset) '())
                 (else (A lset)))))))
  </code></pre>
  
  <p>My doubt is at line 14:</p>
  
  <pre><code>((member? (car s1) s2) (J (cdr s1)))
  </code></pre>
  
  <p>If <code>(car s1)</code> is a member of <code>s2</code>, shouldn't it be consed into the result? Similarly, at lines 15 and 17:</p>
  
  <pre><code>(else (cons (car s1) (J (cdr s1))))))))
  </code></pre>
  
  <p>If it's <em>not</em> a member of <code>s2</code>, shouldn't it be skipped <strong>not</strong> consed into the result?</p>