title: compare all elements in a list haskell
body: <p>I have a list with elements that are tuples example:</p>
  <p><code>[(1,2),(3,9),(7,9),(6,4),(1,2),(4,2),(3,9),(1,2)]</code></p>
  <p>I need to compare the first element with the rest of the elements, then then the second item with the rest of the list and so on to return the repeated elements</p>
  <p>In this case it should return</p>
  <p><code>(1,2),(1,2),(1,2),(3,9),(3,9)</code></p>
  <p>any idea how to implement it?</p>
  <p>I have this implemented</p>
  <pre><code>test :: Eq a =&gt; [(a,a)] -&gt; [(a,a)]
  test [(x,y)] = [(x,y)]
  test (x:y:xs) 
      |((fst (x) == fst (y)) &amp;&amp; (snd (x) == snd (y))) = ( [y]) ++ (test (x:xs) )
      |otherwise = test (x:xs)            
  </code></pre>
  <p>the end condition is bad and always returns the last element of the list
  <code>test [(x,y)] = [(x,y)]</code></p>
  <p>And it only compares the first item with the rest of the list but I need to compare the second, the third ... with the rest of the list</p>