I am writing a recursive function that takes an element A and a list L and returns a list equal to L, but with every occurrence of A removed. Here is what I've written:
(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) '() )
)
)
When compiled and ran, I get the following error:
/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): ()