Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: position of sequence of numbers in list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg107007] Re: position of sequence of numbers in list
  • From: "Steve Luttrell" <steve at _removemefirst_luttrell.org.uk>
  • Date: Sun, 31 Jan 2010 05:58:23 -0500 (EST)
  • References: <hk17lo$ogf$1@smc.vnet.net>

I don't know about efficiency, but here is another way of doing what you 
want:

{1, 2, 3, 4, 5} /. {u___, 3, 4, ___} :> Length[{u}] + 1

-- 
Stephen Luttrell
West Malvern, UK

"JB" <jkerrb at gmail.com> wrote in message news:hk17lo$ogf$1 at smc.vnet.net...
> 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: newbe question about Sting Comparison
  • Next by Date: Re: Problem with ContourPlot3D
  • Previous by thread: Re: position of sequence of numbers in list
  • Next by thread: Re: Re: position of sequence of numbers in list