Prev: load-foreign-library (sbcl), clapack, undefined symbol
Next: returning multiple values from macro
From: Paul Reiners on 26 May 2010 19:56 In the following Lisp REPL interaction: CL-USER> (defparameter *unison* 0) *UNISON* CL-USER> (member *unison* '(*unison*)) NIL why is nil returned?
From: Zach Beane on 26 May 2010 19:58 Paul Reiners <paul.reiners(a)gmail.com> writes: > In the following Lisp REPL interaction: > > CL-USER> (defparameter *unison* 0) > *UNISON* > CL-USER> (member *unison* '(*unison*)) > NIL > > why is nil returned? The two values you have passed to MEMBER are 0 and a list with one element, the symbol *UNISON*. Since 0 is not the symbol *UNISON*, it is not a member of the list. If you wanted to pass a list with one element, 0, you could do this: (member *unison* (list *unison*)) => t Zach
From: Joshua Taylor on 26 May 2010 20:04 On 2010.05.26 7:56 PM, Paul Reiners wrote: > In the following Lisp REPL interaction: > > CL-USER> (defparameter *unison* 0) > *UNISON* > CL-USER> (member *unison* '(*unison*)) > NIL > > why is nil returned? 0 isn't a member of the list containing just the symbol named "*UNISON*". Your code above is similar to: CL-USER > (member '*unison* '(*unison*)) (*UNISON*) But you should also compare with: CL-USER 19 > (member *unison* '(*unison*)) NIL CL-USER 20 > (member *unison* (list *unison*)) (0) CL-USER 22 > (member '*unison* (list *unison*)) NIL CL-USER 23 > (member '*unison* (list '*unison*)) (*UNISON*)
From: Joshua Taylor on 26 May 2010 20:43 On 2010.05.26 8:04 PM, Joshua Taylor wrote: > On 2010.05.26 7:56 PM, Paul Reiners wrote: >> In the following Lisp REPL interaction: >> >> CL-USER> (defparameter *unison* 0) >> *UNISON* >> CL-USER> (member *unison* '(*unison*)) >> NIL >> >> why is nil returned? > > 0 isn't a member of the list containing just the symbol named > "*UNISON*". Your code above is similar to: > > CL-USER > (member '*unison* '(*unison*)) > (*UNISON*) Well that was a typo---the original code is similar to: CL-USER > (member *unison* (list '*unison*)) NIL or CL-USER > (member 0 (list '*unison*)) NIL
From: Andrew Philpot on 27 May 2010 01:49 On 05/26/10 16:56, Paul Reiners wrote: > In the following Lisp REPL interaction: > > CL-USER> (defparameter *unison* 0) > *UNISON* > CL-USER> (member *unison* '(*unison*)) > NIL > > why is nil returned? Did you mean (member '*unison* '(*unison*)) ;; symbol or perhaps (member *unison* (list *unison*)) ;; value A
|
Next
|
Last
Pages: 1 2 Prev: load-foreign-library (sbcl), clapack, undefined symbol Next: returning multiple values from macro |