Re: finding the position of a pattern in list

• To: mathgroup at smc.vnet.net
• Subject: [mg64613] Re: finding the position of a pattern in list
• From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
• Date: Fri, 24 Feb 2006 00:18:08 -0500 (EST)
• Organization: Uni Leipzig
• References: <dtjjcv\$de7\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Hi,

lst = {0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0};

Position[Partition[lst, 2, 1], {0, 1}]

no loop, no pattern matching

Regards

Jens

"Gang Ma" <contactmagang at gmail.com> schrieb im
Newsbeitrag news:dtjjcv\$de7\$1 at smc.vnet.net...
| Hi,
| I am working on a program to do the following:
My data is a list of 0
| and 1. For example, {0,0,1,1,1,0,0,1,1,1,0}. I
want to find the
| positions of all the pattern of {0,1}.  In my
previous example, the
| first {0,1} is at 2 and and the second {0,1}
appears at 7. I can
| write a loop to do this, but I have several
thousands such lists,
| the computation will be time consuming using
loop.
|
| My question is whether it is possible to use the
pattern match to do
| this quickly.  If not for the list, do I need to
convert the list to
| string then use some pattern match for string?
Thank you very much.
|
| regards,
|
| Gang Ma
|
|
|

```

• Prev by Date: Re: finding the position of a pattern in list
• Next by Date: Re: finding the position of a pattern in list
• Previous by thread: Re: finding the position of a pattern in list
• Next by thread: Re: finding the position of a pattern in list