MathGroup Archive 1999

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

Search the Archive

Re: harder parts of list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg15599] Re: [mg15570] harder parts of list
  • From: BobHanlon at aol.com
  • Date: Thu, 28 Jan 1999 04:23:28 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

In a message dated 1/26/99 3:47:55 PM, arnoldk at gauss.cam.wits.ac.za
writes:

>This seems to be a harder list parts problem. Given a list like 
>
>lst={{4,2,3,1},{3,1,5},{2,4,3}}
>
>I wish to select the elements in each sublist that are smaller than the
>first 
>  entry in that sublist.
>		So for the above lst the output should be {{2,3,1},{1},{}}. How can I
>do this  with Select or Cases?
>
>
>Using pattern matching this works
>
>rule1={a_,b___,c_,d___}:>{a,b,d} /;c>a
>
>
>(# //. rule1)& /@ lst
>
>{{4,2,3,1},{3,1},{2}}
>
>Rest /@ %
>
>{{2,3,1},{1},{}}
>

Arnold,

lst={{4,2,3,1},{3,1,5},{2,4,3}};
little[x_?VectorQ] := Select[Rest[x], # < First[x]&]; little[#]& /@ lst

{{2,3,1},{1},{}}

Bob Hanlon


  • Prev by Date: question
  • Next by Date: Re: background option
  • Previous by thread: harder parts of list
  • Next by thread: Re: harder parts of list