SWI-Prolog -- distinct/2

Did you know ... Search Documentation:
SWI-Prolog owl logo Predicate distinct/2
Availability::- use_module(library(solution_sequences)).(can be autoloaded)
Source distinct(:Goal)
distinct(?Witness, :Goal)
True if Goal is true and no previous solution of Goal bound Witness to the same value. As previous answers need to be copied, equivalence testing is based on term variance (=@=/2). The variant distinct/1 is equivalent to distinct(Goal,Goal).

If the answers are ground terms, the predicate behaves as the code below, but answers are returned as soon as they become available rather than first computing the complete answer set.

distinct(Goal) :-
 findall(Goal, Goal, List),
 list_to_set(List, Set),
 member(Goal, Set).
Tags are associated to your profile if you are logged in
Tags:
login to add a new annotation post.

AltStyle によって変換されたページ (->オリジナル) /