title: Haskell function that counts input numbers and finds how many are equal
body: <p>I'm trying to write a function in Haskell that takes 4 integers as input and counts how many of that input numbers are equal to the first integer.</p>
  
  <p>For example:    </p>
  
  <pre><code>howManyEq 3 4 5 6   returns 0
  howManyEq 3 4 3 5   returns 2
  howManyEq 3 4 3 3   returns 3
  howManyEq 3 3 3 3   returns 4
  </code></pre>
  
  <p>This is the function I have created so far, it works for the first instance when there is no input matching the first integer. But it doesn't count the first 3 when there are other matching integers, it always has one less counted.</p>
  
  <pre><code>howManyEq :: Int -&gt; Int-&gt; Int -&gt; Int -&gt; Int
  howManyEq a b c d = count (head (toList a b c d)) (tail (toList a b c d))
  
  count :: Int -&gt; [Int] -&gt; Int
  count x [] = 0
  count x (y:ys)
   | x == y = 1 + (count x ys)
   | otherwise = count x ys
  
  toList :: Int -&gt; Int-&gt; Int -&gt; Int -&gt; [Int]
  toList a b c d = [a,b,c,d]
  </code></pre>
  
  <p>My function gives me:</p>
  
  <pre><code>howManyEq 3 4 5 6   returns 0
  howManyEq 3 4 3 5   returns 1
  howManyEq 3 4 3 3   returns 2
  howManyEq 3 3 3 3   returns 3
  </code></pre>
  
  <p>I'm not sure how to count the first integer when the other input integers are equal.</p>