Prolog n00b here, but not new to programming, having first learned Fortran at Uni in 1974.
Has anyone worked through the code that Thomas de Boer presents in section 6.4 of his "A Beginners' Guide to Visual Prolog V7.2", or maybe the author even reads this forum?
(Huge thanks to Mr de Boer for putting the book together.)
I get this part at the top of section 6.4...
Code: Select all
grandFather(Person,TheGrandFather):-
parent(Person,ParentOfPerson),
father(ParentOfPerson,TheGrandFather).
TheGrandFather is father of ParentOfPerson who is parent of Person, so that ultimately:
TheGrandFather is grandFather of Person.
I also get that that introduces the notion of father and that requires its own predicate to determine fatherhood.
So yes, I then understand both versions of that as presented bottom of page 83 and middle of page 84. (And in fact if you simply query fatherhood, those both work "standalone" so to speak.)
What I don't understand is the code presented at the bottom of page 84 and in the screenshot figure 6.3 where there's an extra "layer" (for want of a better word) compared to the part I quoted earlier:
Code: Select all
grandfather(Person,Grandfather) :-
parent(Father,ParentOfPerson),
father(ParentOfPerson,GrandFather).
Code: Select all
father(Person, person(Name, "male")) :-
parent(Person, person(Name,"male")).
Believe me, I have spent a lot of time trying to figure this out.....
Cheers,
Jim