Define a function contains that takes two parameters, a symbol A and a list of symbols L, and returns t only if L contains A as one of its elements.
That is the original question. I am very new to LISP and would like some code along with an explanation of the syntax. Coming from a java and C++ background LISP is very different in nature. Please help.
So far my code successfully takes two inputs as an parameter.
Pseudocode: I compare the value in A with the first Value of the List then pass the list and variable A back into the function with a recursive call until the the List is empty. If the List is empty return null.
The issue with this is if List contains the a nested List how do i recognize the nested loop.
Such as: (contains #\b '(a (((b))) c)) -> must print true.
So Far What I Have Code:
(defun contains (a list)
(if (eq a(car list))
(princ "t")
(contains a (cdr list))))
(contains #\B '(B a c d e f g))
I need a way for detecting at the end of the list. And a way to search inside nested lists.
MEMBERfunction? - BarmarLis a list of symbols.(a (((b))) c)is not a list of symbols, it's a list of a symbol, a list, and another symbol. - Barmar