您的位置:首页 > 其它

【SICP练习】89 练习2.62

2015-09-08 00:00 253 查看

练习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

版权声明:本文为 NoMasp柯于旺 原创文章,未经许可严禁转载!欢迎访问我的博客:http://blog.csdn.net/nomasp
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  define set union cond 程序