I’m experiencing a very curious problem. I have a list named “theorems” that has exactly one item. Here’s proof:
[]> theorems
(((ROSES ARE RED) ^ (~ (ROSES ARE RED))))
[]> (car theorems)
((ROSES ARE RED) ^ (~ (ROSES ARE RED)))
Clearly ((ROSES ARE RED) ^ (~ (ROSES ARE RED))) is a member of the list “theorems.” But when I test it for membership, it fails:
[]> (member '((ROSES ARE RED) ^ (~ (ROSES ARE RED))) theorems)
NIL
But if I call it explicitly, it works:
[]> (member (car theorems) theorems)
(((ROSES ARE RED) ^ (~ (ROSES ARE RED))))
Why is this happening, and how can I fix it?
Common Lisp uses
EQLas the default test function.EQLchecks whether the items are the same identical items. You want to test whether the items have the same structure. So you need to useEQUALorEQUALP.Tell
MEMBERto useEQUAL: