A.51 library(solution_sequences): Modify solution sequences
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • The SWI-Prolog library
        • library(solution_sequences): Modify solution sequences
          • distinct/1
          • distinct/2
          • reduced/1
          • reduced/3
          • limit/2
          • offset/2
          • call_nth/2
          • order_by/2
          • group_by/4
    • Packages
Availability::- use_module(library(solution_sequences)).(can be autoloaded)
Sourcedistinct(: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).