MathGroup Archive 2010

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

Search the Archive

Re: position of sequence of numbers in list


Sorry for so many posts - apparently I did not include the code for
<myPosition> function mentioned in my second post, while inluded the timings
for it. Here it is:

myPosition =
    Module[{i=1,len = Length[lst],positions =
        lcnresults = If[nresults!=-1,nresults,Length[lst]]},


On Sat, Jan 30, 2010 at 4:12 AM, JB <jkerrb at> wrote:

> Hi,
> 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?
> Thanks,
> JB

  • Prev by Date: Partition prime list into equal k sublists. How to write code for
  • Next by Date: Prime Rotating Diagram
  • Previous by thread: Re: position of sequence of numbers in list
  • Next by thread: Re: position of sequence of numbers in list