我有以下程序:
%% adjacent((Xs, Ys), (Xa, Ya)) - <Xa, Ya> is adjacent to <Xs, Ys>.
adjacent((Xs, Ys), (Right, Ys)) :- Right is Xs + 1.
adjacent((Xs, Ys), (Left, Ys)) :- Left is Xs - 1.
adjacent((Xs, Ys), (Xs, Up)) :- Up is Ys + 1.
adjacent((Xs, Ys), (Xs, Down)) :- Down is Ys - 1.
当我做
?- adjacent((5, 6), (X, Y)).
它给了我
X = Y, Y = 6 ;
X = 4,
Y = 6 ;
X = 5,
Y = 7 ;
X = Y, Y = 5.
发生了什么?
答案 0 :(得分:0)