Re: Re: Re: position of sequence

• To: mathgroup at smc.vnet.net
• Subject: [mg107022] Re: [mg107012] Re: [mg106993] Re: [mg106976] position of sequence
• From: Patrick Scheibe <pscheibe at trm.uni-leipzig.de>
• Date: Mon, 1 Feb 2010 06:09:18 -0500 (EST)
• References: <201001301212.HAA25132@smc.vnet.net>

```Hi,

> Please educate me if I am misunderstanding, but Position is not SequenceHold

yes, you're right. It's a pity that "my written down idea" + "ocam's
razor" + "it worked on the sample" failed it this case.
I don't like "iterations" since I have enough of them in other languages
and therefore, my next guess would have been something like

pos[l_List, what_List] :=
ReplaceList[
l, {head___, Sequence @@ what, ___} :> Length[{head}] + 1]

pos[RandomInteger[{0, 10}, 10000], {4, 5, 6}]

Sorry, for the confusion.

Cheers
Patrick

> and therefore, your constructs don't seem to work for me. They seem to work
> only because you provided length - 2 or length- 3 sequences (try length-4
> and I am getting en error for v7), which Position interprets as 2 or 3
> additional arguments. Thus,
>
> Position[list, Sequence[11, 12, 13]] is equivalent to
>
> Position[list, 11,12,13], which means:
>
> find position of element <11> in the first 12 levels of expression (<list>),
> stopping with at most 13 results. By accident (or luck), this gives correct
> result on the toy example that you have. The same situation with Bob's
> example Position[list, Sequence[3, 4]].
> Or is this an extension of v.7.1, that I am not aware of?
>
> Regards,
> Leonid
>
> On Sun, Jan 31, 2010 at 2:55 AM, Patrick Scheibe <
> pscheibe at trm.uni-leipzig.de> wrote:
>
> > Hi,
> >
> > I assume the only thing you miss is how to express a "sequence of
> > numbers"? Just use Sequence[] :-)
> >
> > list=Range[20];
> > Position[list, Sequence[11, 12, 13]]
> >
> > Cheers
> > Patrick
> >
> > On Sat, 2010-01-30 at 07:12 -0500, JB 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: Re: Partition prime list into equal k sublists. How to
• Next by Date: Re: How to combine graphics pimitives and Plot function?
• Previous by thread: Re: Partition prime list into equal k sublists. How to
• Next by thread: Re: position of sequence of numbers in