MathGroup Archive 2006

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

Search the Archive

Re: finding the position of a pattern in list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg64618] Re: [mg64583] finding the position of a pattern in list
  • From: "Jacob A. Siehler" <siehlerj at wlu.edu>
  • Date: Fri, 24 Feb 2006 00:18:13 -0500 (EST)
  • References: <200602230534.AAA13180@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

> 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