       Re: split again

• To: mathgroup at smc.vnet.net
• Subject: [mg73693] Re: split again
• From: Bill Rowe <readnewsciv at sbcglobal.net>
• Date: Sat, 24 Feb 2007 02:30:10 -0500 (EST)

```On 2/23/07 at 4:36 AM, Arkadiusz.Majka at gmail.com wrote:

>Thank you very much for your help in my provious post. Now, consider

>z=Table[Random[],{1000}];

>zSplit=Split[z,#1<=0.7 === #2>=0.7];           (bulit thanks t=
o your
>help)

>I want to pick the first sublist of zSplit that consists of elements
><= 0.7 and whose length is greater than a certain number (say 5). I
>think that a good candidate would be using Cases and variations of _
>, but I don't know how.

What you posted doesn't seem to do what you describe. That is

In:=
Split[Table[Random[], {10}], #1 <= 0.7 === #2 >= 0.7 & ]

Out=
{{0.485581},{0.0582696},{0.0355538},{0.26509},{0.0298827,0.779148,0.0770904=
,
0.855232,0.0559297},{0.638716}}

Note with this test, the third sublist contains elements greater
than 0.7

Changing the test to:

In:=
Split[Table[Random[], {10}], #1 <= 0.7 && #2 <= 0.7 & ]

Out=
{{0.93307},{0.478675,0.145163,0.513827,0.526321,0.00400982},{0.740881},{0.\
759314},{0.904306},{0.59457}}
does what you say you want.

>What I want to do (and what my both posts are about) is to find the
>first sublist of z with all elements less than A and the length of
>this sublist must be greater than B. Maybe there exists better
>solution than to Split z in advance since what I need to do in my
>next step is to find ONLY the FIRST sublist of splitted z.

Either Cases or Select will work here. First with Cases:

In:=
z = Table[Random[], {1000}];
zSplit = Split[z, #1 <= 0.7 && #2 <= 0.7 & ];
Cases[zSplit, _?(Length[#1] > 5 & )][]

Out=
{0.255395,0.374394,0.402473,0.25127,0.197126,0.338841,0.137383,0.221387,
0.417978,0.26175,0.28215,0.165457}

or with Select

In:=
Select[zSplit,Length[#1]>5&][]

Out=
{0.255395,0.374394,0.402473,0.25127,0.197126,0.338841,0.137383,0.221387,
0.417978,0.26175,0.28215,0.165457}
--
To reply via email subtract one hundred and four

```

• Prev by Date: Re: split again
• Next by Date: simple question
• Previous by thread: Re: split again
• Next by thread: MatrixRank Modulus->8 - BUG