d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Prolog Question
Add Reply New Topic New Poll
Member
Posts: 29,197
Joined: Feb 5 2007
Gold: 4,000.18
Jul 12 2012 07:15pm
I need to implement a tree:


Code
male(Peter).
male(Stewie).
male(Chris).
male(Francis).
male(Joe).
male(Kevin).

female(Louis).
female(Meg).
female(Thelma).
female(Bonnie).
female(Susie).


father(Peter,Stewie).
father(Peter,Chris).
father(Peter,Meg).
father(Joe,Kevin).
father(Joe,Susie).
father(Francis,Peter).
father(Francis,Joe).

mother(Louis,Stewie).
mother(Louis,Chris).
mother(Louis,Meg).
mother(Thelma,Peter).
mother(Bonnie,Kevin).
mother(Bonnie,Susie).


brother(X,Y) :- mother(Z,X),
        mother(Z,Y),
 male(X),
 X \= Y.

sister(X,Y) :- mother(Z,X),
       mother(Z,Y),
       female(X),
       X \= Y.

grandfather(X,Y) :- father(Z,Y); mother(Z,Y),
     father(X,Z),
     male(X).

grandmother(X,Y) :- father(Z,Y); mother(Z,Y),
     mother(X,Z),
     female(X).

uncle(X,Y) :- brother(X,Z),
      father(Z,Y); mother(Z,Y),
      male(X).

aunt(X,Y) :- sister(X,Z),
     father(Z,Y); mother(Z,Y),
     female(X).

cousin(X,Y) :- father(Z,X); mother(Z,X),
       father(Q,Y); mother(Q,Y),
       brother(Z,Q); sister(Z,Q).

nephew(X,Y) :- father(Z,X); mother(Z,X),
       brother(X,Y); sister(X,Y).

related(X,Y) :- uncle(X,Y); uncle(Y,X);
               aunt(X,Y); aunt(Y,X);
 brother(X,Y); brother(Y,X);
 sister(X,Y); sister(Y,X);
               cousin(X,Y); cousin(Y,X);
 nephew(X,Y); nephew(Y,X);
 mother(X,Y); mother(Y,X);
 father(X,Y); father(Y,X);
 grandmother(X,Y); grandmother(Y,X);
 grandfather(X,Y); grandfather(Y,X).


Everything gives true for some reason xD any idea?

/e Note that I learned prolog in less than a day after learning haskell after 2 classes O.o

This post was edited by IsraeliSoldier on Jul 12 2012 07:17pm
Member
Posts: 299
Joined: Apr 11 2010
Gold: 2,491.00
Jul 12 2012 08:55pm
fgs imo
Member
Posts: 29,197
Joined: Feb 5 2007
Gold: 4,000.18
Jul 12 2012 09:20pm
Quote (PumblesMumbles @ Jul 12 2012 09:55pm)
fgs imo


Thanks for the help
Member
Posts: 2,736
Joined: Nov 28 2009
Gold: 34.00
Jul 13 2012 12:49pm
Quote (IsraeliSoldier @ 13 Jul 2012 19:09)
do you know prolog?


If I wanted to help you with your prolog issue, I would post in your thread with a solution or steps towards one.
Stop cluttering my private messages folder, thanks.
Member
Posts: 29,197
Joined: Feb 5 2007
Gold: 4,000.18
Jul 13 2012 02:12pm
Quote (eagl3s1ght @ Jul 13 2012 01:49pm)
If I wanted to help you with your prolog issue, I would post in your thread with a solution or steps towards one.
Stop cluttering my private messages folder, thanks.


Such a dick lol.
Member
Posts: 2,736
Joined: Nov 28 2009
Gold: 34.00
Jul 14 2012 04:53am
Quote (IsraeliSoldier @ 13 Jul 2012 22:12)
Code
From         Subject Date
IsraeliSoldier umad 14 hours, 38 minutes ago

good cuz ur a dick




Oh and, remind me next time you ask something how little gratitude you show when you get help with something. I remember helping you before and this is the thanks I get.

This post was edited by eagl3s1ght on Jul 14 2012 05:07am
Member
Posts: 29,197
Joined: Feb 5 2007
Gold: 4,000.18
Jul 15 2012 12:25am
Quote (eagl3s1ght @ Jul 14 2012 05:53am)
http://2.imgland.net/k24yxP.png

Oh and, remind me next time you ask something how little gratitude you show when you get help with something. I remember helping you before and this is the thanks I get.


I thanked you when you helped me :) .

Also tried telling you to do it in a nicer way to other people >< .
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll