views:

44

answers:

1

In the following Lisp REPL interaction:

CL-USER> (defparameter *unison* 0)
*UNISON*
CL-USER> (member *unison* '(*unison*))
NIL

why is nil returned?

+5  A: 

Because the *unison* variable is bound to 0, and the list has only a *unison* symbol since it's quoted. Try this in comparison:

(member *unison* (list *unison*))

This will actually evaluate the second *unison* which returns 0, resulting in a (0) list.

Eli Barzilay
Or (less likely what he wants) (member '*unison* '(\*unison\*)).
Tim Schaeffer
(Yes, but given how quote can be confusing I avoided mentioning it too -- talking about it will require a separate answer, and I'd be surprised if there isn't such an answer around anyway...)
Eli Barzilay