我想查找list1是否包含在list2中;也称为子列表,但我在处理代码的结尾部分时遇到问题

I want to find whether list1 is contained in list2; also known as a sublist, but i am having trouble with the ending part of my code

;;问题是我想计算一个列表是否包含在另一个列表中,无论大小如何 ;;(list=? (list 1 2 3) (list 2 2 2 2 3 1 2 3 4)) 应该产生 true,但对于我的程序它不会。

请explain/fix哪里错了 我的代码是:

(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))))]))

这在 Racket 中非常简单,只需使用 subset? 过程:

(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