title: Removing consecutive duplicates from a list in Prolog
body: <p>I have list like following : </p>
  
  <pre><code>[a,b,b,e,e,f,f,g]
  </code></pre>
  
  <p>The first and last entries are single, while all others are repeated. How can I remove these extra entries. I should not disturb the order. </p>
  
  <p>I tried following but it gets an empty list: </p>
  
  <pre><code>removeDups([], []).
  removeDups([H1,H2|T], Newlist) :- 
      (H1 == H2 -&gt; removeDups([H2|T],Newlist) 
      ; removeDups(T,Newlist)).
  
  ?- removeDups([a,b,b,c,c,d,d,e],L).
  L = [].
  </code></pre>
  
  <p>Edit: I have already checked many similar question on stackoverflow. But in my list the duplicates are consecutive and therefore a simpler solution may be possible. I could not find a question on removing consecutive duplicate entries.</p>