#lang scheme/base

(define set-1 (λ (v) (and (integer? v) (odd? v))))
(define set-2 (λ (v) (and (integer? v) (even? v))))
(define set-3 (λ (v) (= 0 (remainder v 3))))

(define (union . sets)
  (λ (v) (ormap (lambda (set) (set v)) sets)))

(define (intersect . sets)
  (λ (v) (andmap (lambda (set) (set v)) sets)))

(define (is-member-of? set v) (set v))

(is-member-of? set-1 2) ; #f
(is-member-of? set-1 3) ; #t
(is-member-of? set-2 3) ; #f

(is-member-of? (union set-1 set-2) 2) ; #t
(is-member-of? (union set-1 set-2) 3) ; #t
(is-member-of? (union set-1 set-2) 3+2i) ; #f

(is-member-of? (intersect set-1 set-3) 3) ; #t
(is-member-of? (intersect set-2 set-3) 6) ; #t
(is-member-of? (intersect set-2 set-3) 10) ; #f
