integer/1
fails if the argument is not an integer, for example if you pass an unbound variable.
I believe you should use CLP(FD) for these kind of tasks. Otherwise you may manually bind/test variables in some integer range, using between/3
to set that range.
E.g.:
ordering(A, B, C) :-
between(0, 100, A), % A is an integer in the range [0,100]
between(0, 100, B), % same for B
between(0, 100, C), % and C
A > B,
B > C,
A > 0,
10 > C.
Sample run:
?- ordering(3,X,1).
X = 2 ;
false.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…