【SICP练习】88 练习2.60

练习2.60

这里的adjoin-set通过遍历后使用cons将表进行不断的组合,并在组合的过程中将x加到集合中去。

(define (adjoin-set x set)
  (if (null? set)
       (list x)
       (let ((current-element (car set))
            (remain-element (cdr set)))
    (cond ((= x current-element)
                set)
              ((> x current-element)
                (cons current-element
                      (adjoin-set x remain-set)))
               ((< x current-element)
                 (cons x set))))))



感谢访问,希望对您有所帮助。 欢迎关注或收藏、评论或点赞。


为使本文得到斧正和提问,转载请注明出处:
http://blog.csdn.net/nomasp


版权声明:本文为 NoMasp柯于旺 原创文章,如需转载请联系本人。

posted @ 2015-03-05 10:43  nomasp  阅读(102)  评论(0编辑  收藏  举报