Hello,
I'm new to prolog and are used to programming with java and .net. I can't think the way it wants me to.
I'm working off a family structure tutorial an example of the familys lay out is below.
family(
person(pat,marx,date(10,march,1944),unemployed),
person(charlotte,marx,date(11,february,1946),unemployed),
[
person(aine,marx,date(17,april,1985),unemployed),
person(louis,marx,date(25,june,1980),works(harriott,32000)),
person(pearl,marx,date(10,june,1981),unemployed),
person(pat_jr,marx,date(11,march,1983),works(world_of_food,850000)),
person(ricky,marx,date(18,february,1987),unemployed)
]
).
I have to find two persons from different familys with the same name first and last. Then display those names as well as the number of children in their respective families.
Below is what i have so far. I know its wrong and I've been continualy changing it but I'm no closer.
comflict(Persona,Personb):-
Family = family(Husband,Wife,Child),
Family1 = family(Husband,Wife,Child),
Family=\=Family1,
Persona = person(Name,Surname,_,_)),
Personb = person(Name,Surname,_,_)),
member(Persona,Family),
member(Personb,Family1).
Can you please explain how i go about doing this.
Thank you
I'm new to prolog and are used to programming with java and .net. I can't think the way it wants me to.
I'm working off a family structure tutorial an example of the familys lay out is below.
family(
person(pat,marx,date(10,march,1944),unemployed),
person(charlotte,marx,date(11,february,1946),unemployed),
[
person(aine,marx,date(17,april,1985),unemployed),
person(louis,marx,date(25,june,1980),works(harriott,32000)),
person(pearl,marx,date(10,june,1981),unemployed),
person(pat_jr,marx,date(11,march,1983),works(world_of_food,850000)),
person(ricky,marx,date(18,february,1987),unemployed)
]
).
I have to find two persons from different familys with the same name first and last. Then display those names as well as the number of children in their respective families.
Below is what i have so far. I know its wrong and I've been continualy changing it but I'm no closer.
comflict(Persona,Personb):-
Family = family(Husband,Wife,Child),
Family1 = family(Husband,Wife,Child),
Family=\=Family1,
Persona = person(Name,Surname,_,_)),
Personb = person(Name,Surname,_,_)),
member(Persona,Family),
member(Personb,Family1).
Can you please explain how i go about doing this.
Thank you