ENHANCED: CLP(FD): all_distinct/1 now uses Régin's filtering algorithm
ENHANCED: CLP(FD): all_distinct/1 now uses Régin's filtering algorithm

To test the constraint, use for example:

   :- use_module(library(clpfd)).

   test_constraints(_, [])     --> [].
   test_constraints(X, [_|Vs]) --> test_constraints(X, Vs).
   test_constraints(X, [V|Vs]) --> [X #\= V], test_constraints(X, Vs).

   all_constraints([], _)      --> [].
   all_constraints([V|Vs], Ns) -->
           test_constraints(V, Ns),
           all_constraints(Vs, Ns).

   test_all_distinct :-
           length(Vs, LVs),
           MaxLCs is LVs^2,
           between(1, MaxLCs, LCs),
           length(Cs, LCs),
           numlist(1, LVs, Ns),
           portray_clause(LVs-LCs),
           phrase(all_constraints(Vs,Ns), Cs),
           Vs ins 1..LVs,
           maplist(call, Cs),
           findall(Vs, (label(Vs),all_distinct(Vs)), L1),
           findall(Vs, (all_distinct(Vs),label(Vs)), L2),
           (   L1 == L2 -> false
           ;   portray_clause(failed-Vs-Cs-L1-L2),
               false
           ).

jn7163/swipl-devel,mndrix/swipl-devel,edechter/swipl-devel,edechter/swipl-devel,koryonik/swipl-devel,jn7163/swipl-devel,edechter/swipl-devel,edechter/swipl-devel,jn7163/swipl-devel,edechter/swipl-devel,koryonik/swipl-devel,jn7163/swipl-devel,mndrix/swipl-devel,mndrix/swipl-devel,koryonik/swipl-devel,jn7163/swipl-devel,mndrix/swipl-devel,koryonik/swipl-devel,mndrix/swipl-devel,koryonik/swipl-devel