MathGroup Archive 2006

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

Search the Archive

Re: finding the position of a pattern in list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg64641] Re: finding the position of a pattern in list
  • From: "David Reiss" <dbreiss at gmail.com>
  • Date: Fri, 24 Feb 2006 00:19:52 -0500 (EST)
  • References: <dtjjcv$de7$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Here is one simple strategy:


In[1]:=
Find01Positions[list:{(0|1)..}]:=
  Module[{part},

    part=Partition[lis,2,1];

    Flatten[Position[part, {0,1}]]

    ]


In[2]:=
thelist={0,0,1,1,1,0,0,1,1,1,0};


(5.2) In[3]:=
Find01Positions[lis]

(5.2) Out[3]=
{2,7}

--David


  • Prev by Date: Re: finding the position of a pattern in list
  • Next by Date: Re: JLink, Double.NaN, and arrays
  • Previous by thread: Re: finding the position of a pattern in list
  • Next by thread: Re: finding the position of a pattern in list