1 (define (test-case actual expected)
11 (define (element-of-set? x set)
12 (cond ((null? set) false)
13 ((equal? x (car set)) true)
14 (else (element-of-set? x (cdr set)))))
15 (define (adjoin-set x set)
16 (if (element-of-set? x set)
19 (define (intersection-set set1 set2)
20 (cond ((or (null? set1) (null? set2)) '())
21 ((element-of-set? (car set1) set2)
23 (intersection-set (cdr set1) set2)))
24 (else (intersection-set (cdr set1) set2))))
25 (define (union-set set1 set2)
26 (cond ((null? set1) set2)
28 ((element-of-set? (car set1) set2) (union-set (cdr set1) set2))
29 (else (cons (car set1) (union-set (cdr set1) set2)))))
31 (test-case (union-set '(1 2 3 4 5) '(1 3 4)) '(2 5 1 3 4))