2
我使用下面的代碼:如何避免在Prolog中使用findall重複輸出?
father_child(tom, sally).
father_child(john, alfred).
father_child(george, peter).
father_child(tom, dick).
father_child(john, harry).
father_child(george, eliz).
siblings(X, Y):- father_child(Z, X), father_child(Z, Y), dif(X,Y).
我可以使用下面的代碼的所有兄弟姐妹的列表,但它會產生重複的輸出,在翻轉後的兄弟姐妹位置。這怎麼可能避免:
?- findall((X,Y), siblings(X,Y), L).
L = [ (sally, dick), (alfred, harry), (peter, eliz), (dick, sally), (harry, alfred), (eliz, peter)].