Hi,
I've the following definitions.(* player(name,age) *)
player(peter,9).
player(paul,10).
player(chris,9).
player(susan,9).
games(X,Y) :- player(X,9),player(Y,9),X \== Y.
I want Prolog to return all possible games to play in a tournament, but only with people aged 9.
The problem is that, when asking
?- games(X,Y).
it gives both
X = chris
Y = susan
and
X = susan
Y = chris
I know I have to use the cut operator (!), and 'fail maybe, but I'm not so sure how to do it.
Can anyone help?
Thx in advance!
I've the following definitions.(* player(name,age) *)
player(peter,9).
player(paul,10).
player(chris,9).
player(susan,9).
games(X,Y) :- player(X,9),player(Y,9),X \== Y.
I want Prolog to return all possible games to play in a tournament, but only with people aged 9.
The problem is that, when asking
?- games(X,Y).
it gives both
X = chris
Y = susan
and
X = susan
Y = chris
I know I have to use the cut operator (!), and 'fail maybe, but I'm not so sure how to do it.
Can anyone help?
Thx in advance!