Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1999
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1999

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

Search the Archive

Re: Fast List-Selection

  • To: mathgroup at smc.vnet.net
  • Subject: [mg19899] Re: [mg19880] Fast List-Selection
  • From: Rob Pratt <rpratt at email.unc.edu>
  • Date: Mon, 20 Sep 1999 20:42:24 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Flatten[Position[Partition[s,7,1],Table[x_,{7}]]]

> I have a list 's' composed of a large number of (small) integers. I wish to
> search this list for instances of 7 consecutive, identical elements.
> 
> My approach is:
> 
> Do[If[Count[t = Take[s, {i, i + 6}], t[[1]]] == 7,
>     Print[i]], {i, 1, Length[s] - 6}]
> 
> Can anyone think of a *faster* way of doing this?

Rob Pratt
Department of Operations Research
The University of North Carolina at Chapel Hill

rpratt at email.unc.edu

http://www.unc.edu/~rpratt/






  • Prev by Date: Simplifying expressions containing units
  • Next by Date: RE: Fast List-Selection
  • Previous by thread: Re: Fast List-Selection
  • Next by thread: RE: Fast List-Selection