projog

3.17. X in 1..4 / [X,Y,Z] ins 1..4 - restrict CLP variables to a range of values.

Examples

?- X in 7..9.
X = 7..9

yes

?- X in 7..7.
X = 7

yes

?- [X,Y,Z] ins -7..9.
X = -7..9
Y = -7..9
Z = -7..9

yes

?- X in 7..9, X=7.
X = 7

yes

?- X in 7..9, X#=7.
X = 7

yes

?- X=8, X in 7..9.
X = 8

yes

?- X#=8, X in 7..9.
X = 8

yes

?- X in 7..9, X=6.

no

?- X in 7..9, X#=6.

no

?- X=6, X in 7..9.

no

?- X#=6, X in 7..9.

no

?- X in 7..9, X=10.

no

?- X in 7..9, X#=10.

no

?- X=10, X in 7..9.

no

?- X#=10, X in 7..9.

no

?- X#>=Z+2, [X,Y,Z] ins 7..9.
X = 9
Y = 7..9
Z = 7

yes

?- [X,Y,Z] ins 7..9, X#=<Z-2.
X = 7
Y = 7..9
Z = 9

yes

?- X#>Z+2, [X,Y,Z] ins 7..9.

no

?- [X,Y,Z] ins 7..9, X#<Z-2.

no

?- 7 in 7..9.

yes

?- 8 in 7..9.

yes

?- 9 in 7..9.

yes

?- 6 in 7..9.

no

?- 10 in 7..9.

no

?- [7,9,8] ins 7..9.

yes

?- [8,8,8] ins 7..9.

yes

?- [7,9,6] ins 7..9.

no

?- [7,10,9] ins 7..9.

no

?- [6,9,8] ins 7..9.

no

?- a in 7..8.

Unexpected term of type: ATOM with value: a

?- X in 7.

Expected a predicate with two arguments and the name: '..' but got: 7

?- X in a.

Expected a predicate with two arguments and the name: '..' but got: a

?- X in 8..7.

Minimum value > maximum value in: ..(8, 7)

?- X in a..9.

Expected Numeric but got: ATOM with value: a

?- X in 7..z.

Expected Numeric but got: ATOM with value: z