MathGroup Archive 2009

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

Search the Archive

Re: Select All Lists Where Any Element is a Given Value


Hello Gregory,

You'll probably receive many good solutions. Does this do what you want?

In[14]:= mylst={{1,2,3},{8,NA,20},{-7,9,NA},{NA,3,5}};

In[15]:= Cases[mylst,{___,PatternSequence[NA],___}]

Out[15]= {{8,NA,20},{-7,9,NA},{NA,3,5}}

Richard Hofler

________________________________

From: Gregory Lypny [mailto:gregory.lypny at videotron.ca]
Sent: Mon 2/16/2009 4:40 PM
To: mathgroup at smc.vnet.net
Subject: [mg96645] [mg96586] Select All Lists Where Any Element is a Given Value



Hello everyone,

Suppose I have the list

        X = {{1, 2, 3}, {8, NA, 20}, {-7, 9, NA}},

where NA is a string, although it need not be.  How can I use Select
to pull out all lists in X where NA appears in any element?  In this
example, I want to pull out the second and third list.

                Regards,

                        Gregory
              



  • Prev by Date: Re: Using VerticalSlider controls for Manipulate
  • Next by Date: Re: Re: Re: Scalar plot in 3D
  • Previous by thread: Re: Select All Lists Where Any Element is a Given Value
  • Next by thread: Re: Select All Lists Where Any Element is a Given Value