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

rotate(?X, ?C, ?Y)

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


Constrains X and Y such that Y is C positions after X in the domain order, where the order is considered cyclic, i.e. the first domain element follows the last one. Because of the cyclic order, for each pair of X and Y there are infinitely many solutions for C (which are identical modulo the domain size). 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 currently achieves only bounds-consistency.


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


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

    ?- rotate(th,1,fr).
    Yes (0.00s cpu)

    ?- rotate(su,2,tu).
    Yes (0.00s cpu)

    ?- rotate(su,9,tu).
    Yes (0.00s cpu)

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

    ?- rotate(su,50,X).
    X = mo
    Yes (0.00s cpu)

    ?- rotate(su,-1,X).
    X = sa
    Yes (0.00s cpu)

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

    ?- ic:(X::0..7), rotate(tu,X,fr).
    X = 3
    Yes (0.00s cpu)

    ?- ic:(X::2..4), rotate(tu,X,Y).
    X = X{2 .. 4}
    Y = Y{[th, fr, sa]}
    Delayed goals: ...

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

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

See Also

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