So I want to be able to count the number of neighbour pairs of opposite sign in a list of 1's and -1's (eg. 1 for {1,1,1,-1,-1} and 3 for {1,-1,1,-1,-1}), but I can't work out the pattern matching syntax in Mathematica even after reading the documentation. I was thinking to use the Count function. Anybody able to help, please?(adsbygoogle = window.adsbygoogle || []).push({});

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Basic Mathematica pattern matching

**Physics Forums | Science Articles, Homework Help, Discussion**