我已经写了这段代码
(define (in-list? val ls)
(if (null? ls) #f
(if
(= (car ls) val) #t
(in-list? val (cdr ls))
)
)
)
(define (intersect ls1 ls2)
(if (null? ls1)
'()
(if (in-list? (car ls1) ls2)
(cons (car ls1) (intersect (cdr ls1) ls2))
(intersect (cdr ls1) ls2)
)
)
)
如果我问(相交'(1 2 3)'(1 4 7))它正常工作但是当我尝试时它返回空列表(相交'(abc)&#39 ;(ABD))