Set Difference

(set-difference x y ) returns a list containing the elements of x that do not occur in y.

(define (set-difference x y)
  (if (pair? x)
      (if (memv (car x) y)
          (set-difference (cdr x) y)
          (cons (car x)
                (set-difference (cdr x) y)))

> (set-difference '(c a t) '(b a g)) (c t)

(copy-list lst ) copies the top level of list lst.

(define (copy-list lst)
  (if (pair? lst)
      (cons (car lst) (copy-list (cdr lst)))

Contents    Page-10    Prev    Next    Page+10    Index