【SICP练习】88 练习2.60

来源:互联网 发布:智能水杯 知乎 编辑:程序博客网 时间:2024/05/20 17:59

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


5 0