MathGroup Archive 2002

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

Search the Archive

Re: Pattern Matching in Lists


One way:

In[2]:=
Tr[ReplaceList[{1,1,1,0,0,1,0,1,0,0,1,0,0},{___,1,0,___} -> 1]]

Out[2]=
4

Andrzej Kozlowski
Toyama International University
JAPAN
http://platon.c.u-tokyo.ac.jp/andrzej/


On Thursday, July 18, 2002, at 03:06  AM, Anthony Mendes wrote:

> Hello,
>
> Suppose w={1,1,1,0,0,1,0,1,0,0,1,0,0}.
>
> How can I count the number of occurrences of a 1 in w immediately
> followed by a 0 in w?
>
> I have tried every incarnation of Count[] I can think of; for example,
>
> Count[w,{___,1,0,___}]
>
> does not seem to work.  In general, how can I count the number of
> occurrences of a 1 followed by a 0 in a list of 1's and 0's?  Thank you!
>
>
> --
> Tony
> _____________________
> amendes at math.ucsd.edu
>
>
>
>
>



  • Prev by Date: Re: Pattern Matching in Lists
  • Next by Date: Re: Pattern Matching in Lists
  • Previous by thread: Re: Pattern Matching in Lists
  • Next by thread: Re: Pattern Matching in Lists