1

At page 49 of The Seasoned Schemer, I can't understand what is going on in the following code (lines 14-16):

(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)))))))

My doubt is at line 14:

((member? (car s1) s2) (J (cdr s1)))

If (car s1) is a member of s2, shouldn't it be consed into the result? Similarly, at lines 15 and 17:

(else (cons (car s1) (J (cdr s1))))))))

If it's not a member of s2, shouldn't it be skipped not consed into the result?

Flux
  • 9,805
  • 5
  • 46
  • 92
Victor Ribeiro
  • 577
  • 7
  • 20

1 Answers1

1

Nevermind... it was an error:

http://www.ccs.neu.edu/home/matthias/BTSS/errata.html

Chapter 13

Page 49: A4: Swap answers of the last two clauses of J's cond

Page 50: Q2: Swap answers of the last two clauses of J's cond

Victor Ribeiro
  • 577
  • 7
  • 20
  • 1
    This was a well formulated question, and you explained the confusion well, but since it was a simple error, it probably makes sense to remove the question, as it probably won't be all that helpful to other users. (If you don't remove it, though, be sure to accept your answer.) – Joshua Taylor Jun 21 '14 at 20:09
  • 1
    I've been relying on Stack Overflow as a study aid whenever I find difficult subjects on this book series. So I guess it will be helpful to others as well. I'll accept the answer. – Victor Ribeiro Jun 21 '14 at 23:29