My first attempt, the iterative one, is pretty easy:
- Code: Select all
(defun member-of (elem the-list)
(if (eql elem (car (member elem the-list)))
'T
'NIL)
Now I want to make the recursive version.
- Code: Select all
(defun member-of (elem the-list)
(if (eql elem (car the-list))
'T
(member-of elem (cdr the-list))))
Of course that only works if the element is indeed a member of the list.
If the element isn't, this function will not terminate.
How to fix this?
