Re: Re: position of sequence of numbers in
- To: mathgroup at smc.vnet.net
- Subject: [mg107018] Re: [mg107005] Re: [mg106976] position of sequence of numbers in
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Sun, 31 Jan 2010 08:18:38 -0500 (EST)
- Reply-to: hanlonr at cox.net
This is wrong. I obviously didn't test this. Instead, use myList = {3, 1, 2, 5, 3, 4, 6, 2, 8, 9, 3, 4} {3,1,2,5,3,4,6,2,8,9,3,4} Select[Position[myList, 3], MemberQ[Position[myList, 4] - 1, #] &] {{5}, {11}} Bob Hanlon ---- Bob Hanlon <hanlonr at cox.net> wrote: ============= Position[list, Sequence[3, 4]] Bob Hanlon ---- JB <jkerrb at gmail.com> 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