[ library(ic) | The ECLiPSe Libraries | Reference Manual | Alphabetic Index ]

?Vars :: ++Domain

Constrain Vars to have the domain Domain.
Vars
Variable or collection (a la collection_to_list/2) of variables
Domain
Domain specification

Description

Constrains Vars to take only integer or real 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 Lo .. Hi, or as a list of subranges and/or individual elements. Multiple subranges and/or individual elements are allowed in integer domains only. If all subrange bounds and individual elements are integers the domain is considered an integer domain and the variables Vars are constrained to be integral; otherwise it is considered a real domain and the type of the variables is not constrained. Note that infinities are considered to be untyped for this purpose.

For instance:

     X :: 0..1                  % boolean
     X :: -1..5                 % integer between -1 and 5
     X :: 1..inf                % strictly positive integer
     X :: 0.0..10.0             % real between 0.0 and 10.0
     X :: 1.5..3.7              % real between 1.5 and 3.7
     X :: 0.0..5                % real between 0.0 and 5.0
     X :: 1.4__1.6..3.6__3.8    % real where the bounds aren't known exactly
     X :: breal(0)..inf         % nonnegative real
     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, 7.0..9.0]  % Type error
     X :: [a, b, c]             % Type error

Examples

[eclipse 2]: X :: 0..1.
X = X{[0, 1]}
Yes (0.00s cpu)

[eclipse 3]: X :: -1..5.
X = X{-1 .. 5}
Yes (0.00s cpu)

[eclipse 4]: X :: 1..inf.
X = X{1 .. 1.0Inf}
Yes (0.00s cpu)

[eclipse 5]: X :: 0.0..10.0.
X = X{0.0 .. 10.0}
Yes (0.00s cpu)

[eclipse 6]: X :: 1.5..3.7.
X = X{1.5 .. 3.7}
Yes (0.00s cpu)

[eclipse 7]: X :: 1.4__1.6..3.6__3.8.
X = X{1.4 .. 3.8}
Delayed goals:
        ic : (-(X{1.4 .. 3.8}) =< -1.6__-1.4)
        ic : (X{1.4 .. 3.8} =< 3.6__3.8)
Yes (0.00s cpu)

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

See Also

integers / 1, reals / 1, ic_hybrid_sets : :: / 2, suspend : :: / 2, fd : :: / 2, eplex : :: / 2, ic_sets : :: / 2, fd_sets : :: / 2, :: / 3, #:: / 2, $:: / 2