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

shift(?X, ?C, ?Y)

Y is C places after X in the domain order
X
variable or domain value
C
variable or integer
Y
variable or domain value

Description

Constrains X and Y such that Y is C positions after X in the domain order. C must be an integer or integer variable, and its range is -(S-1)..S-1 where S is the size of the symbolic domain. X and Y must be variables or values of the same domain. If one of them is domain-less, it will be given the same domain as the other.

The implementation achieves domain consistency iff C is instantiated at call time, otherwise only bounds consistency.

Modules

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

Examples

    ?- [X,Y] &:: weekday, shift(X, 1, Y).
    X = X{[mo, tu, we, th, fr, sa]}
    Y = Y{[tu, we, th, fr, sa, su]}
    There is 1 delayed goal.
    Yes (0.00s cpu)

    [eclipse 4]: [X,Y]&::weekday, shift(X,C,Y). 
    X = X{[mo, tu, we, th, fr, sa, su]}
    C = C{-6 .. 6}
    Y = Y{[mo, tu, we, th, fr, sa, su]}
    There are 3 delayed goals.
    Yes (0.00s cpu)

    ?- shift(we, 1, th).
    Yes (0.00s cpu)

    ?- shift(we, 2, fr).
    Yes (0.00s cpu)

    ?- shift(X, -1, th).
    X = fr
    Yes (0.00s cpu)

    ?- shift(tu, X, fr).
    X = 3
    Yes (0.00s cpu)

    ?- shift(tu,X,Y).
    X = X{-1 .. 5}
    Y = Y{[mo, tu, we, th, fr, sa, su]}
    Delayed goals: ...

    ?- shift(tu, 1, th).
    No (0.00s cpu)

    ?- shift(X, 1, Y).
    Arguments have no domains in shift(X, 1, Y) in module eclipse
    Abort

    ?- X &:: weekday, shift(X, 1, red).
    Arguments have different domains (weekday,colour) in shift(X, 1, red) ...
    Abort
    

See Also

shift / 4, &< / 2, &> / 2, &=< / 2, &>= / 2, &= / 2, &\= / 2, rotate / 3, domain / 1