2
我試圖讓所有的兄弟姐妹一起在下面的代碼:讓所有的兄弟姐妹一起在序言
father_child(tom, sally).
father_child(john, alfred).
father_child(george, peter).
father_child(tom, dick).
father_child(john, harry).
father_child(george, eliz).
father_child(tom, james).
father_child(john, ron).
father_child(george, hermoine).
siblings(X, Y):- father_child(Z, X), father_child(Z, Y), X @< Y.
?- findall([X,Y], siblings(X,Y), L).
L = [[alfred, harry], [alfred, ron], [dick, sally], [dick, james], [harry, ron], [eliz, peter], [eliz, hermoine], [james|...], [...|...]].
但它僅給出了對。如果我不知道有多少兄弟姐妹在那裏,我想要列出兄弟姐妹名單(如下),我該如何管理?
[[a, b, c], [d, e], [x, y, z, w]]
完美,這正是我想要的。謝謝。 – rnso