Re: Select and Cases Give Different Answers
- To: mathgroup at smc.vnet.net
- Subject: [mg99157] Re: Select and Cases Give Different Answers
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Wed, 29 Apr 2009 03:47:28 -0400 (EDT)
On 4/28/09 at 4:42 AM, gregory.lypny at videotron.ca (Gregory Lypny) wrote: <snip> >But I don't understand why Unequal, when used as the criterion for >Select as in >Select[theList, # != "NA" &], >fails to return the rationals, and I get only three elements >{-0.01315, 0.0120957, 0.00625}. I'd appreciate any clarification on >the difference between UnsameQ and Unequal because my inclination in >most circumstances is to use an equal sign or an unequal sign to >make simple comparisons yet it doesn't give me the answer I expect, >and I'd hate to make a costly mistake somewhere down the road! Consider In[8]:= 1/4 != "NA" Out[8]= 1/4!=NA That is Mathematica cannot determine whether the rational 1/4 is equal or not to the string "NA". Since, this comparison doesn't return True, the rationals in the list are not returned To me the real surprise here is Mathematica returns true when comparing the string "NA" to a real.