Racket 我想知道列表1是否包含在列表2中;也称为子列表,但我在代码的结尾部分遇到了问题

Racket 我想知道列表1是否包含在列表2中;也称为子列表,但我在代码的结尾部分遇到了问题,racket,sublist,Racket,Sublist,;;问题是,我想计算a-list是否包含在另一个列表中,而不考虑其大小 ;;(list=?(list 1234)(list 1234))应该生成true,但对于我的程序它不会 请解释/纠正我的错误 我的代码是: (define (list=? a-list another-list) (cond [(empty? a-list) (empty? another-list)] [(cons? a-list) (and (cons? a

;;问题是,我想计算a-list是否包含在另一个列表中,而不考虑其大小

;;(list=?(list 1234)(list 1234))
应该生成true,但对于我的程序它不会

请解释/纠正我的错误 我的代码是:

(define (list=? a-list another-list)
   (cond
       [(empty? a-list) (empty? another-list)]
       [(cons? a-list)
              (and (cons? another-list)
              (and (= (first a-list) (first another-list))
                   (list=? (rest a-list) (rest another-list))))]))

这在球拍中非常简单,只需使用以下步骤:

(define (list=? a-list another-list)
  (subset? a-list another-list))


(list=? (list 1 2 3) (list 2 2 2 2 3 1 2 3 4))
=> #t
可能重复的