Prolog: How to get oldest and youngest in bloodline

Viewed 506

Let's say that I have a bloodline of male population Williams and Skywalker families as my knowledge base:

father(phil,tom, williams).
father(tom, bob, williams).
father(bob, robert, williams).
father(robert, steve, williams).

father(anakin, luke, skywalker)
father(luke, finn, skywalker)
father(finn, andrew, skywalker)
father( andrew, charles, skywalker)

Which rule can I use to know the oldest and youngest in bloodline?

For example

?- oldestYoungest(skywalker,X,Y)

should return

X = anakin
Y = charles
1 Answers
Related