Re: harder parts of list
- To: mathgroup at smc.vnet.net
- Subject: [mg15600] Re: [mg15570] harder parts of list
- From: "Clemens Frey" <Clemens.Frey at uni-bayreuth.de>
- Date: Thu, 28 Jan 1999 04:23:29 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Dear Arnold, this is not so difficult as it seems at first. Just use one of the following Maps of pure functions to solve the problem restated below: Function[ sublst, Select[Rest[sublst],#<First[sublst]&] ] /@ lst Function[ sublst, Cases[Rest[sublst],x_/;x<First[sublst]] ] /@ lst Both of them gives the result you want. If you like it more explicit, you could write alternatively: sel[lst_] := Select[Rest[lst],#<First[lst]&]; sel /@ lst which is the same as above without the use of the outer pure function. Hope this helped Clemens ------------------------------------------------------------ Clemens Frey Doctoral Fellow at the Department of Mathematics/BITOEK University of Bayreuth(Germany) clemens.frey at uni-bayreuth.de http://www.bitoek.uni-bayreuth.de/~Clemens.Frey ------------------------------------------------------------ >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 > >