; 只需要定义两个基本元素的交 inter
; 单个元素的值 value
; 用到两个公式
; A ∪ B = A + B - A ∩ B
; A ∩ (B1 ∪ B2 ... Bn) = (A ∩ B1) ∪ (A ∩ B2) ... ∪ (A ∩ Bn)
(define (unions items)
(if (null? (cdr iems))
(value (car items))
(let ((a (car items))
(b (cdr items)))
(+ (value a) (unions b)
(- (unions (map (lambda (x) (inter a x)) b)))))))
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |