title: Do not continue when duplicate items are found in Prolog
body: <p>The idea is to define a predicate that counts how many times an element appears in a list, but that the recursion stops when there are 2 occurrences of the element. </p>
  
  <pre><code>contElemen(_,[],0).
  contElemen(X,[X|T],N):-contElemen(X,T,N1), N is N1 + 1.
  contElemen(X,[_|T],N):- contElemen(X,T,N).
  </code></pre>
  
  <p>I do not know if I'm understanding everything wrong in prolog, is it possible to stop execution (without break) when N = 2?</p>
  
  <p>Obviously, I'm new to prolog, sorry if the question is incorrect. Thank you</p>