Subject: Re: member function...
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 12 Sep 2000 03:23:50 GMT
Newsgroups: comp.lang.lisp
Message-ID: <8pk7k6$rjipm$1@fido.engr.sgi.com>
Irma <fsumera@cs.rmit.edu.au> wrote:
+---------------
| I have a problem using a member function  ...
| ? (setf testlist (cons "Two" testlist))
| ("Two" "One")
| ? (member testword testlist)
| NIL
| 
| Shouldn't it return T since "One" is in the testlist or I should
| another function for this situation?
+---------------

The problem is not "member" per se, but an interaction between
your choice of list element data type (string) and the function
"eql", which is the default two-argument test that "member" uses
if you don't specify a different one. That is:

	> (eql 1 1)
	T
	> (member 1 '(2 1))
	(1)
	> (eql 'one 'one)
	T
	> (member 'one '(two one))
	(ONE)
	> (eql "one" "one")
	NIL
	> (member "one" '("two" "one"))
	NIL
	> (equal "one" "one")	; or any of equalp, string-equal, or string=
	T
	> (member "one" '("two" "one") :test #'equal)
	("one")
	> 

Does that help?


-Rob

-----
Rob Warnock, 41L-955		rpw3@sgi.com
Network Engineering		http://reality.sgi.com/rpw3/
Silicon Graphics, Inc.		Phone: 650-933-1673
1600 Amphitheatre Pkwy.		PP-ASEL-IA
Mountain View, CA  94043