Re: harder parts of list
- To: mathgroup at smc.vnet.net
- Subject: [mg15609] Re: [mg15570] harder parts of list
- From: Robert Pratt <rpratt at math.unc.edu>
- Date: Thu, 28 Jan 1999 04:23:35 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
trim[ls_]:=Select[ls,#<First[ls]&] Map[trim[#]&,lst] Rob Pratt Department of Mathematics The University of North Carolina at Chapel Hill CB# 3250, 331 Phillips Hall Chapel Hill, NC 27599-3250 rpratt at math.unc.edu http://www.math.unc.edu/Grads/rpratt/ On Tue, 26 Jan 1999, Arnold Knopfmacher wrote: > 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},{}} > > Thanks > Arnold Knopfmacher > Wiws University > South Africa > >