why does this not work
Roelof Wobben <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
I have this :
male(roelof).
male(mans).
male(ronald).
male(jan).
female(chantal).
female(marie).
female(gerda).
female(dagmar).
female(denise).
female(kimberly).
parent(mans,gerda).
parent(mans,roelof).
parent(marie,gerda).
parent(marie,roelof).
parent(dagmar,denise).
parent(dagmar,kimberly).
parent(ronald,denise).
parent(ronald,kimberly).
parent(chantal,tamara).
parent(roelof,tamara).
parent(jan,chantal).
parent(jan,dagmar).
% Looks for the father of a child. Gives the name if found.
if no father is found then it gives false
father_child(Child) :-
parent(Father, Child),
male(Father).
% Looks for the mother of a child. Gives the name if found.
if no mother is found then it gives false
mother_child(Child) :-
parent(Mother, Child),
female(Mother).
% Looks if two person has the same father.
% Gives true if a person is a father of both persons
% Gives false if no person is a father of both persons.
same_father(Child, Sibling) :-
parent(Father,Child),
parent(Father,Sibling),
male(Father).
% Looks if two person has the same mother.
% Gives true if a person is a mother of both persons
% Gives false if no person is a mother of both persons.
same_mother(Child, Sibling) :-
parent(Mother,Child),
parent(Mother,Sibling),
female(Mother).
% Looks if there are siblings of a person.
% Persons are siblings if they have the same father or
% if they have the same mother and not the same father.
siblings(X,Y) :-
( same_father(X, Y),
X \= Y
; same_mother(X, Y),
\+ same_father(X, Y)
).
% Displays the output of siblings(X,Y) and takes care that
% there are no duplicates.
display_siblings(Person) :-
findall(Person-Y, (siblings(Person,Y),Person @< Y), Sibs),
display_the_siblings(Sibs).
% Display a message if there are no siblings found.
display_the_siblings([]) :-
write('Er zijn geen zussen/broers bekend').
% Displays a message if one sibling is found.
display_the_siblings([X-Y]) :-
write('The enigste broer of zuster is '),
write(Y).
% Display a message if there are more then 1 siblings found.
display_the_siblings([H|T]) :-
XYs0=[H,T],
write('Alle zusterparen zijn : \n'),
forall(( member(X - Y,XYs0)
),( format('~w en ~w. \n',[X,Y])
)).
But when I do display_siblings(kimberly) I see a message Er zijn geen zussen/broers bekend
That's wrong Denise is a sibling of Kimberly.
Where does I make a error.
Roelof
-------------- next part --------------
HTML attachment scrubbed and removed