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: [mg63574] Re: [mg63557] Conditional drop of list elements
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Thu, 5 Jan 2006 06:02:44 -0500 (EST)
  • Reply-to: hanlonr at cox.net
  • Sender: owner-wri-mathgroup at wolfram.com

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}};

Select[list1,#[[1]]==1&]

{{1, B, B, B}, {1, D, D, D}, {1, F, F, F}}

Cases[list1,{1,___}]

{{1, B, B, B}, {1, D, D, D}, {1, F, F, F}}

list1/.{0,___}:>Sequence[]

{{1, B, B, B}, {1, D, D, D}, {1, F, F, F}}


Bob Hanlon

> 
> From: "LectorZ" <lectorz at mail.ru>
To: mathgroup at smc.vnet.net
> Date: 2006/01/05 Thu AM 03:12:25 EST
> Subject: [mg63574] [mg63557] Conditional drop of list elements
> 
> 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
> 
> 


  • Prev by Date: Re: Conditional drop of list elements
  • Next by Date: Re: Batch Mode Output
  • Previous by thread: Re: Conditional drop of list elements
  • Next by thread: Re: Conditional drop of list elements