当前位置: 首页> 游戏> 攻略 > 如何做网站排名第一_东莞建设网招标信息_b2b外贸接单平台_2022知名品牌营销案例100例

如何做网站排名第一_东莞建设网招标信息_b2b外贸接单平台_2022知名品牌营销案例100例

时间:2025/7/10 4:24:15来源:https://blog.csdn.net/ilongchaos/article/details/143279226 浏览次数:0次
如何做网站排名第一_东莞建设网招标信息_b2b外贸接单平台_2022知名品牌营销案例100例

Exercise2.60

We specified that a set would be represented as a list with no duplicates. Now suppose we allow duplicates. For instance, the set {1, 2, 3} could be represented as the list (2 3 2 1 3 2 2). Design procedures element of-set?, adjoin-set, union-set, and intersection-set that operate on this representation. How does the efficiency of each compare with the corresponding procedure for the non-duplicate representation? Are there applications for which you would use this representation in preference to the nonduplicate one?


这道题目我有点没理解,如果允许重复的话,交集该怎么处理?所以最后交集我没有改变,element-of-set? 也没有修改。

(define (element-of-set? x set)(cond ((null? set) false)((equal? x (car set)) true)(else (element-of-set? x (cdr set)))))(define (adjoin-set x set)(cons x set))(define (union-set set1 set2)(append set1 set2))(define (intersection-set set1 set2)(cond ((or (null? set1) (null? set2)) '())((element-of-set? (car set1) set2)(cons (car set1) (intersection-set (cdr set1) set2)))(else (intersection-set (cdr set1) set2))))(define set1 (list 1 3 5 'a 'b 'c))
(define set2 (list 2 4 6 'a 'd 'c))(adjoin-set 'a set1)
(union-set set1 set2)
(intersection-set set1 set2); 执行结果
'{a 1 3 5 a b c}
'{1 3 5 a b c 2 4 6 a d c}
'{a c}
关键字:如何做网站排名第一_东莞建设网招标信息_b2b外贸接单平台_2022知名品牌营销案例100例

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: