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: split

  • To: mathgroup at smc.vnet.net
  • Subject: [mg73621] Re: [mg73572] split
  • From: "Maarten van der Burgt" <maarten.vanderburgt at icos.be>
  • Date: Fri, 23 Feb 2007 04:35:28 -0500 (EST)

Arkadiusz,


Split[z,#1<=3 && #2<=3 || #1>3 && #2>3 &]

gives the result you are after.

The test in the 2nd argument should result in true when subsequent elements
(#1 and #2) should belong to the same sublist.

regards,

Maarten


                                                                                                                                                
                    Arkadiusz.Majka                                                                                                             
                    @gmail.com             To:     mathgroup at smc.vnet.net                                                                       
                                           cc:                                                                                                  
                    22/02/2007             Subject:     [mg73572] split                                                                         
                    10:30                                                                                                                       
                                                                                                                                                
                                                                                                                                                




Hi,

I want to split a list, say

z = {1, 3, 2, 6, 4, 7, 5,1,7};

into sublist of elements that are less or equal 3.

so I want to obtain

{{1,3,2},{6,4,7,5},{1},{7}}

How to do it? Probably by applying Split, but what to put in Test?

Split[z,#<=3&] gives :

{{1, 3, 2, 6}, {4}, {7}, {5}, {1, 7}}

Why 6 was put in first sublist together with 1, 3, and 2 since 6>3 and
should be together with 4 in the second sublist?

Thanks,

Arek








  • Prev by Date: Re: ArcCosh[x] (1)
  • Next by Date: Re: ReplaceList and //.
  • Previous by thread: Re: split
  • Next by thread: Re: split