, tfilter/3
list_uniqmember_t/3
!
list_uniqs(Es, Us) :-
tfilter(list_uniqmember_t(Es), Es, Us).
, OP, :
?- list_uniqs([green,red,blue,purple,yellow,brown,orange,black,purple], Xs).
Xs = [green,red,blue,yellow,brown,orange,black]. % succeeds deterministically
?
?- list_uniqs([A,B,A], []).
A=B
; false.
?- list_uniqs([A,B,A], [_]).
dif(A,B).
?- list_uniqs([A,B,A], [_,_]).
false.
?- list_uniqs([A,B,A], Xs).
Xs = [] , A=B
; Xs = [B], dif(A,B).
! - ?
?- list_uniqs([A,B,C],Xs).
Xs = [] , A=B , B=C
; Xs = [C] , A=B , dif(B,C)
; Xs = [B] , A=C , dif(B,C)
; Xs = [A] , dif(A,C), B=C
; Xs = [A,B,C], dif(A,B), dif(A,C), dif(B,C).
!