Re: MemberQ
- To: mathgroup at smc.vnet.net
- Subject: [mg68655] Re: MemberQ
- From: Peter Pein <petsie at dordos.net>
- Date: Mon, 14 Aug 2006 06:44:41 -0400 (EDT)
- References: <0533005404FE2E45B90AF737DE5A991A015312F3@de01exm67.ds.mot.com> <ebmt7i$6cj$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
leigh pascoe schrieb: ... > While we are talking about MemberQ, what about the following behavior? > In[15]:=Range[0,1,1/10] > MemberQ[Range[0,1,1/10],2/10] > > Out[15]=\!\({0, 1\/10, 1\/5, 3\/10, 2\/5, 1\/2, 3\/5, 7\/10, 4\/5, > 9\/10, 1}\) > > Out[16]=True > > Is the above result correct given that 2/10 doesn't appear in the list > produced by the range statement?? Mathematica automagically cancels 2/10. > On the other hand 0.5 can be > represented exactly as a binary number, but > In[29]:=MemberQ[Range[0,1,1/10],.5] > > Out[29]=False > 1/2 has head Rational, 0.5 has got head _Real. So they must not be the same. > LP > I wrote a (very) small package: http://people.freenet.de/Peter_Berlin/Mathe/NMemberQ/NMemberQ.m and http://people.freenet.de/Peter_Berlin/Mathe/NMemberQ/NMemberQ.nb Feel free to add the function NMemberQ to your own collection of utilities. Cheers, Peter
- Follow-Ups:
- Re: Re: MemberQ
- From: leigh pascoe <leigh@cephb.fr>
- Re: Re: MemberQ