You should probably read On Lisp, or ANSI Common Lisp. They (I'm guessing both of them) go over the function in detail. You could also try grepping the source of your favorite Common Lisp implementation for "defun member" to see a real-life example.
But, it's good to figure these things out for yourself, too. Since you didn't post an attempt at solving it, I'm going to show you a simple way to write a recursive
list copy function:
- Code: Select all
CL-USER> (defun my-copy (list &optional acc)
(cond ((null list) (reverse acc))
(t (my-copy (cdr list) (cons (car list) acc)))))
Member might work almost the same way, except that it doesn't accumulate a list, and has an extra case for testing EQUALity of a given value.
I think that's enough of a hint; give it a try.
Edit: With regards to atoms, you might want to make sure you're using the right
equality predicate.
"If you want to improve, be content to be thought foolish and stupid." -Epictetus