MathGroup Archive 2006

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

Search the Archive

Re: Conditional drop of list elements

  • To: mathgroup at smc.vnet.net
  • Subject: [mg63579] Re: [mg63557] Conditional drop of list elements
  • From: János <janos.lobb at yale.edu>
  • Date: Fri, 6 Jan 2006 05:24:22 -0500 (EST)
  • References: <200601050812.DAA19845@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On Jan 5, 2006, at 3:12 AM, LectorZ wrote:

> Hi guys,
>
> I need your assistance by the following problem:
>
> list1 = {{0,A,A,A}, {1,B,B,B}, {0,C,C,C}, {1,D,D,D}, {1,F,F,F},
> {0,G,G,G}, {0,H,H,H}}
>
> Every 1st element of the each sublist should be checked. Is the first
> element a ZERO, this sublist should be removed from the list. If it is
> a ONE - this sublist remains in the list.
>
> In this example the output should be:
>
> {{1,B,B,B}, {1,D,D,D},{1,F,F,F}}
>
> Thanks for your help!
>
> LZ

Here is a newbie approach:

In[3]:=
Pick[list1,
   (#1[[1]] == 1 & ) /@ list1]
Out[3]=
{{1, B, B, B}, {1, D, D, D},
   {1, F, F, F}}

János


----------------------------------------------------------
"A cyber virgin has never had intercourse outside of virtual reality,  
whereas a virtual virgin has never had intercourse with a real person  
even in virtual reality"

-Ray Kurzweil - "The age of spiritual machines"


  • Prev by Date: trouble with NDSolve
  • Next by Date: Re: Plot a function on Time Scales
  • Previous by thread: Re: Conditional drop of list elements
  • Next by thread: Re: Conditional drop of list elements