What’s a simple way to check if an item is in a list?
Something like
(in item list)
might return true if item=1 and list=(5 9 1 2) and false if item=7
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Common Lisp
FINDis not a good idea:Above would mean that
NILis not in the list(NIL NIL)– which is wrong.The purpose of
FINDis not to check for membership, but to find an element, which satisfies a test (in the above example the test function is the usual defaultEQL).FINDreturns such an element.Use
MEMBER:or
POSITION: