RE: Pattern Matching in Lists
- To: mathgroup at smc.vnet.net
- Subject: [mg35557] RE: [mg35547] Pattern Matching in Lists
- From: "Harvey P. Dale" <hpd1 at nyu.edu>
- Date: Fri, 19 Jul 2002 06:07:58 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Tony: This should do it: Length[Select[Partition[w,2,1],#[[1]]==1&&#[[2]]==0&]] Best, Harvey Harvey P. Dale University Professor of Philanthropy and the Law Director, National Center on Philanthropy and the Law New York University School of Law Room 206A 110 West 3rd Street New York, N.Y. 10012-1074 -----Original Message----- From: Anthony Mendes [mailto:amendes at zeno.ucsd.edu] To: mathgroup at smc.vnet.net Subject: [mg35557] [mg35547] Pattern Matching in Lists 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 ________________________________________________________________________ This email has been scanned for all viruses by the MessageLabs SkyScan service. For more information on a proactive anti-virus service working around the clock, around the globe, visit http://www.messagelabs.com ________________________________________________________________________