Re: Selecting Sub-lists After Split
- To: mathgroup at smc.vnet.net
- Subject: [mg77475] Re: [mg77425] Selecting Sub-lists After Split
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Sat, 9 Jun 2007 05:42:52 -0400 (EDT)
- Reply-to: hanlonr at cox.net
myList = Table[RandomReal[{-1, 1}], {10}]; myNewList = Split[myList, #1 #2 > 0 &]; Select[myNewList, #[[1]] < 0 &] {{-0.653948,-0.875564,-0.770361},{-0.240326}} Bob Hanlon ---- Gregory Lypny <gregory.lypny at videotron.ca> wrote: > Hello everyone, > > Suppose I have a list of real number called myList. I split it into > sub-lists of positive and negative numbers called myNewList by doing > this (there may be a more elegant way): > > myNewList = Split[myList, #1 #2 > 0 &] > > Now, how can I select all of the sub-lists of negative numbers from > myNewList? > > Any tips would be most appreciated. > > Regards, > > Gregory >