
?Vars #:: ++Domain

   Constrain Vars to be integral and have the domain Domain.

Arguments
   Vars                Variable or collection (a la collection_to_list/2) of variables
   Domain              Domain specification

Type
   library(ic)

Description

   Constrains Vars to take only integer values from the domain specified
   by Domain.  Vars may be a variable or a collection of variables
   (as accepted by collection_to_list/2).  Domain can be specified as a
   simple range of integers Lo..Hi, or as a list of subranges and/or
   individual integer elements.  For instance:

     X #:: 0..1                 % boolean
     X #:: -1..5                % integer between -1 and 5
     X #:: 1..inf               % strictly positive integer
     X #:: [0..3,5,8..10]       % any integer from 0 to 10 except 4 and 6
     [X,Y,Z] #:: 1..8           % apply domain to X, Y and Z
     M[2..4,5] #:: 1..8         % apply to rows 2..4, column 5 of matrix M
     X #:: 0.0..5.0             % Type error
     X #:: [a, b, c]            % Type error

   Domain values must be given as integers, ground integer expressions, the
   special constant 'inf' or 1.0Inf (for infinity).

   If the variables already have domains, their domain is intersected with
   the new one, possibly failing if it becomes empty.


Examples
   ?- X #:: 0..1.
X = X{[0, 1]}
Yes (0.00s cpu)

?- X #:: -1..5.
X = X{-1 .. 5}
Yes (0.00s cpu)

?- X #:: 1..inf.
X = X{1 .. 1.0Inf}
Yes (0.00s cpu)

?- X #:: [0..3, 5, 8..10].
X = X{[0 .. 3, 5, 8 .. 10]}
Yes (0.00s cpu)

?- length(Xs, 5), Xs #:: 1 .. 9.
Xs = [_421{1 .. 9}, _435{1 .. 9}, _449{1 .. 9}, _463{1 .. 9}, _477{1 .. 9}]
Yes (0.00s cpu)

?- dim(Xs, [5]), Xs #:: 1 .. 9.
Xs = [](_438{1 .. 9}, _452{1 .. 9}, _466{1 .. 9}, _480{1 .. 9}, _494{1 .. 9})
Yes (0.00s cpu)


See Also
   $:: / 2, #:: / 3, integers / 1, gfd : #:: / 2, suspend : #:: / 2, fd : #:: / 2
