Re: Selecting Sub-lists After Split
- To: mathgroup at smc.vnet.net
- Subject: [mg77446] Re: [mg77425] Selecting Sub-lists After Split
- From: János <janos.lobb at yale.edu>
- Date: Sat, 9 Jun 2007 05:27:42 -0400 (EDT)
- References: <200706080934.FAA03592@smc.vnet.net>
On Jun 8, 2007, at 5:34 AM, Gregory Lypny 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 Here is a newbie approach: First[Last[Reap[i = 1; While[i <= Length[newlst], If[First[newlst[[i]]] < 0, Sow[newlst[[i]]], Null]* i++; ]]]] newlst is your MyNewList. J=E1nos ======================== "I think I may need a bathroom break? Is this possible?" --G.W.Bush http://news.bbc.co.uk/2/hi/americas/4249646.stm
- References:
- Selecting Sub-lists After Split
- From: Gregory Lypny <gregory.lypny@videotron.ca>
- Selecting Sub-lists After Split