JJS
JJS

Reputation: 13

In Common Lisp how do I search for a sublist within a list

If I want to find whether (x 2) exists within a list containing ((x 2) (y 2) (z 2)) for example, how do I do this?

(member '(x 2) '((x 2) (y 2) (z 2))) 

returns NIL as does find

Thanks for the help

Upvotes: 0

Views: 2124

Answers (1)

uselpa
uselpa

Reputation: 18917

? (member '(x 2) '((x 2) (y 2) (z 2)) :test 'equal)
((X 2) (Y 2) (Z 2))

In Common Lisp, member uses eql as the default test, which does not work in this case.

See here for details regarding eq, eql, equal and equalp.

Upvotes: 5

Related Questions