title: Haskell: Pattern Matching with Lists
body: <p>I'm trying to make a function that takes in a list, and if one of the elements is negative, then any elements in that list that are equal to its positive counterpart should be changed to 0. Eg, if there is a -2 in a list, then all 2's in that list should be changed to 0.</p>
  <p>Any ideas why it only works for some cases and not others? I'm not understanding why this is, I've looked it over several times.</p>
  <pre><code>changeToZero [] = []
  changeToZero [x] = [x]
  changeToZero (x:zs:y:ws) | (x &lt; 0) &amp;&amp; ((-1)*(x) == y) = x : zs : 0 : changeToZero ws
  changeToZero (x:xs) = x : changeToZero xs
  
  changeToZero [-1,1,-2,2,-3,3]
  -- [-1,1,-2,2,-3,3]
  
  changeToZero [-2,1,2,3]
  -- [-2,1,0,3]
  
  changeToZero [-2,1,2,3,2]
  -- [-2,1,0,3,2]
  
  changeToZero [1,-2,2,2,1]
  -- [1,-2,2,0,1]
  </code></pre>