title: match lists L1 with L2 in prolog
body: <p>I try to write predicate <code>one_occurence(L1, L2)</code> that is true if each element of <code>L1</code> occurs once in <code>L2</code>.  </p>
  
  <pre><code>delete([H|T], H, TN) :- delete(T, H, TN).
  
  delete([H|T], E, [H|TN]) :- \+ H = E, delete(T, E, TN).
  
  delete([], _, []).
  
  /*one_occurence(L,LN) is true if a list LN is identical to a list L
    without all repeated elements.*/
  
  one_occurence([],[]).
  
  one_occurence([H|T], [H|TU]) :- delete(T, E, TN), one_occurence(TN, TU).
  </code></pre>
  
  <p>But when I ask <code>one_occurence([a,b,a,a,b,c,d,c],N)</code> I get <code>N=[a,a,c,c]</code> which is wrong. I should get <code>N=[a,b,c,d]</code>. What am I doing wrong? </p>