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

?X &\= ?Y

X is different from Y
X
Variable or atomic value
Y
Variable or atomic value

Description

Constrains X and Y to be different. Operationally, the predicate delays until one side is instantiated and the other has a domain. The instantiated value is then removed from the domain.

Examples

    ?- X &:: [red,green,blue], X &\= red.
    X = X{[blue, green]}
    Yes (0.00s cpu)

    ?- X &:: [red, green, blue], X &\= yellow.
    X = X{[blue, green, red]}
    Yes (0.00s cpu)

    ?- X &:: [red,green], X &\= red.
    X = green
    Yes (0.00s cpu)

    ?- X &:: [red,green], X &\= red, X &\= green.
    No (0.00s cpu)

    ?- X &\= red.
    X = X
    There is 1 delayed goal.
    Yes (0.00s cpu)

    ?- X &\= red, X &:: [red,green].
    X = green
    Yes (0.00s cpu)

    ?- [X, Y] &:: [red, green, blue], X &\= Y.
    X = X{[blue, green, red]}
    Y = Y{[blue, green, red]}
    There is 1 delayed goal.
    Yes (0.00s cpu)

    ?- X &:: [red, green], Y &:: [blue, brown], X &\= Y.
    X = X{[green, red]}
    Y = Y{[blue, brown]}
    There is 1 delayed goal.
    Yes (0.00s cpu)

    ?- red &\= green.
    Yes (0.00s cpu)

    ?- red &\= red.
    No (0.00s cpu)
    

See Also

&\= / 3, &= / 2