projog

3.16. all_different([X,Y,Z]) - enforce that none of the given CLP variables share the same value.

Examples

?- all_different([X,Y,Z]), X#=1, Y#=1.

no

?- all_different([X,Y,Z]), [X,Y,Z] ins 1..2, label([X,Y,Z]).

no

?- all_different([X,Y,Z]), [X,Y,Z] ins 1..3.
X = 1..3
Y = 1..3
Z = 1..3

yes

?- all_different([X,Y,Z]), [X,Y,Z] ins 1..3, Y#=2.
X = {1, 3}
Y = 2
Z = {1, 3}

yes

?- all_different([X,Y,Z]), [X,Y,Z] ins 1..3, Y#=1.
X = 2..3
Y = 1
Z = 2..3

yes

?- all_different([X,Y,Z]), [X,Y,Z] ins 1..3, Y#=1, Z#=Y+2.
X = 2
Y = 1
Z = 3

yes

?- all_different([]).

yes

?- all_different([X]), X#=7.
X = 7

yes

?- all_different([X,X]), X in 1..3, label([X]).

no

?- all_different([6,7,8]).

yes

?- all_different([6,7,6]).

no

?- all_different([6,6,8]).

no

?- all_different([6,8,8]).

no

?- all_different([7,7,7]).

no

?- all_different(x).

Expected LIST but got: ATOM with value: x

?- all_different([x]).

Unexpected term of type: ATOM with value: x