MathGroup Archive 2010

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

Search the Archive

position of sequence of numbers in list


What is the most efficient way to find the position of the beginning
of a sequence of numbers from a list?

I found a couple of ways:

find 3,4 in list={1,2,3,4,5};

 1.   pos=Intersection[Position[list,3],(Position[list,4])+1]

 2.   pos=Position[Partition[list,2,1],{3,4}]

Are there other ways to do this?
What is the best way when dealing with large lists?


  • Prev by Date: Re: More memory-efficient inner product for large last
  • Next by Date: Problem with ContourPlot3D
  • Previous by thread: Re: Re: Re: Re: More /.{I->-1}
  • Next by thread: Re: position of sequence of numbers in list