title: Algorithm - How to delete duplicate elements in a Haskell list
body: <p>I'm having a problem creating an function similar to the nub function.</p>
  
  <p>I need this func to remove duplicated elements form a list. 
  An element is duplicated when 2 elements have the same email, and it should keep the newer one (is closer to the end of the list).</p>
  
  <pre><code>type Regist = [name,email,,...,date]
  type ListRe = [Regist]
  
  rmDup ListRe -&gt; ListRe
  rmDup [] = []
  rmDup [a] = [a]
  rmDup (h:t) | isDup h (head t) = rmDup t
              | otherwise = h : rmDup t
  
  isDup :: Regist -&gt; Regist -&gt; Bool
  isDup (a:b:c:xs) (d:e:f:ts) = b==e
  </code></pre>
  
  <p>The problem is that the function doesn't delete duplicated elements unless they are together in the list.</p>