MathGroup Archive 2006

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

Search the Archive

Re: finding the position of a pattern in list


> and 1. For example, {0,0,1,1,1,0,0,1,1,1,0}. I want to find the
> positions of all the pattern of {0,1}.

This will work, and seems to be faster than loop solutions though there is 
a space tradeoff.

f = Random[Integer] & /@ Range[1000000];
Timing[res = Position[Partition[f, 2, 1], {0, 1}];]



  • Prev by Date: Plot -> axes inversion
  • Next by Date: Re: finding the position of a pattern in list
  • Previous by thread: finding the position of a pattern in list
  • Next by thread: Re: finding the position of a pattern in list