==/2
is a binary predicate, '=='(X,Y)
, that will succeed or fail depending upon whether X
and Y
are bound to the same value. So you can't "cascade" them like A == B == C
as it would be a syntax error.
What you can do is individual pairs. This would be an adequate test to tell if any one of A
, B
, C
or D
are different (i.e., they are "not all the same"):
valid(A, B, C, D) :-
\+ (A == B, A == C, A == D).
You could generalize this to a list of numbers, [A,B,C,...]:
valid([X|T]) :- \+ maplist(==(X), T).
And get:
| ?- valid([a,a,a,a]).
no
| ?- valid([a,a,a,b]).
yes