Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

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 
> 



  • Prev by Date: Re: Trouble with TraditionalForm in Mathematica 6.0
  • Next by Date: Re: Re: Best practice for Mathematica package development
  • Previous by thread: Re: Selecting Sub-lists After Split
  • Next by thread: Re: Selecting Sub-lists After Split