【发布时间】:2016-03-03 14:46:59
【问题描述】:
我正在编写一个递归函数,它接受一个元素 A 和一个列表 L,并返回一个等于 L 的列表,但每次出现的 A 都会被删除。这是我写的:
(define (remove A L)
(cond ( (eq? A (car L)) (remove A (cdr L)) )
( (not(eq? A (car L))) (cons (car L) (remove A (cdr L))) )
( (null? L) '() )
)
)
编译运行时出现如下错误:
/tmp/compile/5c6515d8-e155-11e5-9605-aa00009baa05/input/main.scheme:2:21: In procedure remove:
/tmp/compile/5c6515d8-e155-11e5-9605-aa00009baa05/input/main.scheme:2:21: In procedure car: Wrong type argument in position 1 (expecting pair): ()
【问题讨论】:
标签: recursion scheme lisp cdr sisc