【SICP练习】89 练习2.62

简介:

练习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练习】145 练习4.1
版权声明:转载请联系本人,感谢配合!本站地址:http://blog.csdn.net/nomasp https://blog.csdn.net/NoMasp/article/details/44728049 练习4-1 原文 Exercise 4.
894 0