title: Unexpected issue with max function in Haskell
body: <p>I have this function that removes the maximum value of a list and it seems to work, and when I keep adding numbers it works until I add a new high number. Then it will still remove only the old max number. But when I start a new list it will work again. Can anyone explain what is going on, and what I am doing wrong?</p>
  
  <pre><code>    removeMax :: [Int] -&gt; [Int]
      removeMax [] = []
      removeMax [x] = [] 
      removeMax (x:y:xs)
          | x &gt; y = (y:xs)
          | otherwise = x : removeMax (y:xs)
  </code></pre>
  
  <p>And here is the outputs of several tests I made: </p>
  
  <pre><code>    *Main&gt; removeMax [1,9,3,2,6]
      [1,3,2,6]
      *Main&gt; removeMax [1,9,3,2,6,8]
      [1,3,2,6,8]
      *Main&gt; removeMax [1,9,3,2,6,8,7]
      [1,3,2,6,8,7]
      *Main&gt; removeMax [1,9,3,2,6,8,7,14]
      [1,3,2,6,8,7,14]
      *Main&gt; removeMax [1,9,3,2,6,8,7,14]
      [1,3,2,6,8,7,14]
      *Main&gt; removeMax [1,9,3,2,6,8,7,14]
      [1,3,2,6,8,7,14]
      *Main&gt; removeMax [1,3,14,5]
      [1,3,5]
      *Main&gt; removeMax[1,3,8,9]
      [1,3,8]
      *Main&gt; removeMax [1,2,3,67,87,12]
      [1,2,3,67,12]
      *Main&gt; removeMax [1,2,3,67,87,12,88]
      [1,2,3,67,12,88]
  </code></pre>
  
  <p>As you can see it works when you keep doing it on new lists and when you use an old list and only add smaller numbers.</p>