title: Prolog - using negation (declarative approach) to define member/2 to only succeed once for each number
body: <p>I'm trying to write an alternative definition to member/2 which will won't return repetitions of numbers (i.e. will only succeed once for each element). I've currently got this code working using the cut procedurally:</p>
  
  <pre><code>once_member(X,[H|T]) :-
      member(H,T),
      !,
      once_member(X,T).
  once_member(H,[H|_]).
  once_member(X,[_|T]) :-
      once_member(X,T).
  </code></pre>
  
  <p>However, I'm aware that you can also use negation in a declarative approach to do this but I can't work out how to do it. If anyone could point me in the right direction that'd be great.</p>