I’m stuck on a homework question. I’m trying to define a function that checks if an element exist in a list using recursion. Below is what I have.
(defun is-member2 (X S)
"Check if a X is a member of S"
(if (and (atom X) (not (null S)) (lisp S) (> (length S) 0))
;X- is a value, not a set
(if (equal X (car S))
;Located
(equal 'a 'a)
;NotLocated
(is-memeber2 X (cdr S))
)
;No- X is not a value
()
);end if
)
However, I keep on getting that is-memeber2 is undefined. This leads me to believe that either X is no longer a valid element or that (cdr S) is sending nul, but shouldn’t my if statement catch this?
is-member2does not equalis-memeber2. Check your spelling.