2.59 Exercise 2.59
union-set is very similar to intersection-set, with two key differences:
If an element of the first set is already in the second, it is not added to the result, and vice versa. This is the opposite of how intersections work.
If either of the sets is empty, the other set is returned, not the empty set.
(define (union-set set1 set2) (cond ((null? set1) set2) ((null? set2) set1) ((element-of-set? (car set1) set2) (union-set (cdr set1) set2)) (else (cons (car set1) (union-set (cdr set1) set2)))))