我遇到了我的方案计划问题。我试着拿两份名单并比较它们的大小,并且返回true表示大小相等,如果不是,则返回false。每个原子的价值并不重要。方案:比较列表尺寸
例子:
(structeq '(a (b(c))) '(1(2(3)))) => #t
(structeq '(x) '(()) => #f
这里是我的代码:
(define (structeq list1 list2)
(cond ((null? list1) list2)
(eq? (length list1) (length list2))))
(structeq '(a b c d) '(a b c))
然而,这种返回最后一个列表的大小。我哪里错了?
编辑:取消此问题。我想通了,我只需要删除cond语句。