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 again

  • To: mathgroup at smc.vnet.net
  • Subject: [mg73674] Re: split again
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Sat, 24 Feb 2007 02:19:51 -0500 (EST)
  • Organization: The Open University, Milton Keynes, UK
  • References: <ermd8n$hmd$1@smc.vnet.net>

Arkadiusz.Majka at gmail.com wrote:
> Hi,
> 
> Thank you very much for your help in my provious post. Now, consider
> please a list
> 
> z=Table[Random[],{1000}];
> 
> zSplit=Split[z,#1<=0.7 === #2>=0.7];           (bulit thanks to your
!!!---------------------------------^!!!
This is NOT a pure function: '&' is missing.

> 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 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.

Here is an example, with a smaller set of data, that illustrate the 
usage of Position. Adjust the values in In[5] as you wish.

In[1]:=
z = Table[Random[], {20}];

In[2]:=
zSplit = Split[z, #1 <= 0.7 === #2 >= 0.7 & ]

Out[2]=
{{0.0931438}, {0.682899},

   {0.281936, 0.834176, 0.364066},

   {0.437316, 0.992434, 0.236221}, {0.0318242},

   {0.210513}, {0.274683, 0.816371, 0.511568},

   {0.592908}, {0.0374695}, {0.237045}, {0.318043},

   {0.368736, 0.73596, 0.314188}}

In[5]:=
Position[zSplit, x_ /; Length[x] == 3 && Max[x] <= 0.9, {1}, 1]

Out[5]=
{{3}}

Regards,
Jean-Marc


  • Prev by Date: Re: is 3?
  • Next by Date: Re: split again
  • Previous by thread: Re: split again
  • Next by thread: Re: split again