title: How to remove duplicates from a list in SWI-Prolog?
body: <p>I need to write a predicate <code>remove_duplicates/2</code> that removes duplicate elements form a given list. For example:</p>
  <p><code>?- remove_duplicates([a,a,b,c,c], List). List = [a,b,c] Yes</code></p>
  <p>Please keep in mind I'm only learning SWI-Prolog for two days and only understand the basics of Prolog. This is what I have at the moment:</p>
  <p><code>remove_duplicates([H | T], List) :- member(H, T), append(T, [], List1). </code></p>
  <p>This works for the list <code>[a,a,b,c]</code> but not for lists where two elements in the tail are the same. I figured I somehow have to remove the Head to a temporary list, create a new Head and just repeat the predicate. I have no idea how to do that. Also, when the Head is not in the Tail, for example with lists like <code>[a,b,b,c]</code>, the terminal just says <code>False</code>, because <code>member(H, T)</code> is not true.</p>
  <p>Any ideas?</p>