title: Creating lists do not include duplicates in Prolog
body: <pre><code>**FACTS**
  player(milan,[seedorf,zambrotta,gattuso]).
  player(inter,[seedorf,ronaldo,zambrotta]).
  player(realmadrid,[seedorf,zidane,ronaldo]).
  </code></pre>
  
  <p>i wanna create a predicate such that :  </p>
  
  <pre><code>find (TEAM, PLAYERS)
  </code></pre>
  
  <p>and if my goal is <strong>find(X,Y)</strong> it will returns List of teams,X, and List of players,Y, without any duplicates... Like below:</p>
  
  <pre><code>X=[milan], Y=[seedorf,zambrotta,gattuso];
  X=[inter], Y=[seedorf,ronaldo,zambrotta];
  X=[realmadrid], Y=[seedorf,zidane,ronaldo]; 
  X=[milan,inter] Y=[seedorf,zambrotta];
  X=[milan,realmadri] Y=[seedorf]; 
  ...
  X=[milan,inter,realmadrid] Y=[seedorf];
  ... 
  </code></pre>
  
  <p>i try to do this with but it gives "ERROR: Out of local stack",
  If i do not use remove_dups predicate, 
  The list of teams,"X", would have duplicates and program could not stop...
  keep going like X=[milan,milan,milan,milan,inter] .... How can i correct this code. ?:</p>
  
  <pre><code>find([X], Y) :- player(X1, Y),remove_dups(X1,X).
  find([X|Xs], Y) :- player(X1, Y0),find(Xs, Y3), intersection(Y0, Y3, Y),remove_dups(X1,X).
  
  remove_dups([],[]).
  remove_dups([First|Rest],NewRest):-member(First, Rest),remove_dups(Rest, NewRest).
  remove_dups([First|Rest],[First|NewRest]):-not(member(First, Rest)),remove_dups(Rest, NewRest).
  </code></pre>
  
  <p>Thanks a lot...</p>