Please forgive me if this is a dumb question, but I'm a rank beginner at Prolog (been about a couple hours so far!) and am a bit confused. Not sure if I'm trying to do something beyond my level.
Imagine I have a set of people...
parent(daddy, john).
parent(daddy, jim).
...and the following predicate to find siblings...
sib(X, Y) :- parent(Z, X), parent(Z, Y), not(X = Y).
If I run sib(X, Y).
, it works fine, but gives me duplicates, eg...
X = jim,
Y = john ;
X = john,
Y = jim ;
false
I'm trying to work out how to avoid the duplicates.
I saw this answer, which uses setof
, and spent some time reading about that predicate, but a) can't work out if it's what I need, and b) can't (yet) grok it.
Anyone able to help a newbie? Thanks
In case it makes any difference, I'm using SWI-Prolog on Ubuntu