[ library(suspend) | Reference Manual | Alphabetic Index ]

?Vars :: ?Range

Range constraint with optional integrality constraint
Vars
Variable or number, or a list of variables or numbers
Range
Variable or Lo..Hi, where Lo and Hi are variables or numeric expressions

Description

This constraint suspends until its arguments are ground. It then succeeds iff all the elements of the list Vars are numbers within the range specified by Range.

The range must eventually be in the form Lo..Hi, where Lo and Hi are expressions evaluating to numbers. If both are integers, then Vars must also be integers (integer or list of integers).

Modules

This predicate is sensitive to its module context (tool predicate, see @/2).

Fail Conditions

Vars contains numbers that do not fall within Range, or violate the optional integrality constraint.

Examples

    % with integrality constraint
    ?- X :: 1 .. 5, X = 3.
    X = 3
    Yes (0.00s cpu)

    ?- X :: 1 .. 5, X = 6.
    No (0.00s cpu)

    ?- X :: 1 .. 5, X = 3.0.
    No (0.00s cpu)

    % without integrality constraint
    ?- X :: 1.0 .. 5.0, X = 3.
    X = 3
    Yes (0.00s cpu)

    ?- X :: 1.0 .. 5.0, X = 3.0.
    X = 3.0
    Yes (0.00s cpu)
    

See Also

$:: / 2, #:: / 2, :: / 3, integers / 1, reals / 1