0

I'm sort of a beginner to Prolog and I have a quick question. I've built a family tree in prolog with parents(X,Y,Z). But when time comes to built uncle(Uncle,X). and aunt(Aunt,X). seems a bit difficult for me. I've tried uncle(Uncle,X) :- first_cousins(X,Y),parents(Y,Uncle,_). and aunt(Aunt,X) :- first_cousins(X,Y),parents(Y,_,Aunt). but it brings me out the same outcome several times before proceeding to the next one. So, I was thinking something like with four sentences for each one. Any thoughts?

gew kar
  • 1
  • 3
  • 1
    Show your code. – repeat Mar 09 '19 at 22:46
  • i finally came down to this – gew kar Mar 10 '19 at 11:31
  • uncle(Uncle,X) :- parents(X,A,_),siblings(A,Uncle),male(Uncle). uncle(Uncle,X) :- parents(X,_,B),siblings(B,Uncle),male(Uncle). uncle(Uncle,X) :- parents(X,A,_),siblings(A,Aunt),parents(_,Uncle,Aunt). uncle(Uncle,X) :- parents(X,_,B),siblings(B,Uncle),parents(_,Uncle,_). aunt(Aunt,X) :- parents(X,A,_),siblings(A,Uncle),parents(_,Uncle,Aunt). aunt(Aunt,X) :- parents(X,_,B),siblings(B,Uncle),parents(_,Uncle,Aunt). aunt(Aunt,X) :- parents(X,A,_),siblings(A,Aunt),female(Aunt). aunt(Aunt,X) :- parents(X,_,B),siblings(B,Aunt),female(Aunt). – gew kar Mar 10 '19 at 11:31
  • uncle runs just fine . Although aunt needs a little adjustment because gives double answers – gew kar Mar 10 '19 at 11:33

0 Answers0