This is the member p method I tried. (Squash list is a method I made before that takes in the input of a list, and returns a list consisting of only atoms.)
(defun member-p (x y)
(squash-listr y)
(if (listp y)
(if (eq (cdr y) nil) nil)
(t (eq (car y) x) x)
)
(member-p x (cdr y))
)
Test cases (I'll add more, but this is my first one) (print(member-p '2 '(2 4 5))) ;this test case should return 2 (the first argument of member-p)
Right now I'm getting a stack overflow error. I've checked my parentheses but am unable to find any issues.


Note that member-p is called at the end in every case, even if y is nil. Thus the stack overflow. You should only call member-p in the case if y is not empty.
Further, the result of squash-listr is not used, thus you should ask yourself if it is really needed.