【SICP练习】89 练习2.62
2015-03-05 10:44
302 查看
练习2.62
前面已经遇到过了,union-set是用来取并集的。我们要通过多种情况来完成这个程序。(define (union-set set1 set2) (cond ((and (null? set1) (null? set2)) '()) ((null? set1) set2) ((null? set2) set1) (else (let ((x (car set1)) (y (car set2))) (cond ((= x y) (cons x (union-set (cdr set1) (cdr set2)))) ((< x y) (cons x (union-set (cdr set1) set2))) ((> x y) (cons y (union-set set1 (cdr set2)))))))))
感谢访问,希望对您有所帮助。 欢迎关注或收藏、评论或点赞。
为使本文得到斧正和提问,转载请注明出处:
http://blog.csdn.net/nomasp
相关文章推荐
- 【SICP练习】89 练习2.62
- 【SICP练习】16 练习1.22
- SICP 练习1.28
- SICP 练习1.39 计算tan(x)
- 【SICP练习】29 练习1.35
- 【SICP练习】46 练习2.5
- 【SICP练习】54 练习2.22
- 【SICP练习】70 练习2.41
- SICP 练习2.12 make-interval-percent
- 【SICP练习】86 练习2.58
- 【SICP练习】103 练习2.81-2.97
- 【SICP练习】104 练习3.1-3.4
- 【SICP练习】106 练习3.7
- 【SICP练习】132 练习3.63
- 【SICP练习】150 练习4.6
- sicp 练习1.7
- 【SICP练习】138 练习3.69
- 【SICP练习】58 练习2.28
- 【SICP练习】116 练习3.42
- 【SICP练习】91 练习2.64