Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Picking Off Lists That Have No Numbers

  • To: mathgroup at smc.vnet.net
  • Subject: [mg99528] Re: Picking Off Lists That Have No Numbers
  • From: David Bailey <dave at removedbailey.co.uk>
  • Date: Thu, 7 May 2009 06:36:02 -0400 (EDT)
  • References: <gtrl29$1o5$1@smc.vnet.net>

nGregory Lypny wrote:
> Hi everyone,
> 
> In a previous thread, "Select and Cases Give Different Answers," I  
> discussed a bug, confirmed by others on the list and which Daniel  
> Lichtblau of Wolfram said has been fixed in the development kernel,  
> and I wonder whether we have the same problem here.
> 
> I want to know if a list has no numbers in it.  Here I get the wrong  
> answer for the first list.
> 
> FreeQ[#, _Number] & /@ {{"NA", 2.3, 3/8}, {"NA", "NA", "NA"}}
> 
> yields {True, True}
> And same here.
> 
First it is important to remember that the niggle to which Daniel
Lichtblau referred was peripheral to your problem because you really 
needed to use UnsameQ (=!=) in your tests.

Testing FreeQ[#, _Number]& is not correct, because it is testing an 
expression to determine if it is free of subexpressions with head 
Number!! Numbers in Mathematica have heads such as Integer, Real, 
Complex, Rational, etc.

Try this instead:

Map[FreeQ[#, _?NumericQ] &, {{"NA", 2.3, 3/8}, {"NA", "NA", "NA"}}]

David Bailey
http://www.dbaileyconsultancy.co.uk


  • Prev by Date: Re: Remove quotes from Cell Expression
  • Next by Date: Re: Reading csv with ;
  • Previous by thread: Re: Picking Off Lists That Have No Numbers
  • Next by thread: Re: Picking Off Lists That Have No Numbers