我试图确定一个符号列表是否有重复项,如果是这样,我希望foldr给我一个新列表,每个符号只出现一次
这个想法是这样的:
(define schema2 '(aa bb cc))
(define (schema? schema)
(foldr (lambda (obj lst)
(if (contains? lst obj)
(lst)
((cons obj lst)))
) (list) schema))
(define (contains? list obj)
(cond
((empty? list) #f)
((eq? (car list) obj) #t)
(else (contains? (cdr list) obj)))
)
(schema? schema2)
但出于某种原因,我收到错误
application: not a procedure;
expected a procedure that can be applied to arguments
given: '(aa)
arguments...: [none]