projog

3.19. label([X]) - assigns concrete values to the given CLP variables.

Examples

?- X in 7..9, label([X]).
X = 7

yes;
X = 8

yes;
X = 9

yes;

no

?- X in 7..9, Y#=X*2, label([X]).
X = 7
Y = 14

yes;
X = 8
Y = 16

yes;
X = 9
Y = 18

yes;

no

?- Z#=X+Y, X in 7..9, Y in 4..5, label([X,Y]).
X = 7
Y = 4
Z = 11

yes;
X = 8
Y = 4
Z = 12

yes;
X = 9
Y = 4
Z = 13

yes;
X = 7
Y = 5
Z = 12

yes;
X = 8
Y = 5
Z = 13

yes;
X = 9
Y = 5
Z = 14

yes;

no

?- Z#=X+Y, X in 7..9, Y in 4..5, label([X,Y]), Z=12.
X = 8
Y = 4
Z = 12

yes;
X = 7
Y = 5
Z = 12

yes;

no

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

yes

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

no

?- X#=1, label([X]).
X = 1

yes

?- X=1, label([X]).
X = 1

yes

?- label([1]).

yes

?- label(x).

Expected LIST but got: ATOM with value: x

?- label([x]).

Unexpected term of type: ATOM with value: x

?- X#=Y, label([X,Y]).

java.lang.IllegalStateException: Variables not sufficiently bound. Too many possibilities.