【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

你可能感兴趣的:(SICP,define)