MathGroup Archive 2006

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

Search the Archive

Re: finding the position of a pattern in list


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