Prolog программа сортировка дерева скачать

Prolog программа сортировка дерева

Prolog Family Tree Blood Relations, Recursion? [duplicate]
This question already has an answer here: I need a recursive function that finds all blood relatives in a family tree. But I honestly have no idea how to implement this in Prolog. My current understanding for a solution, would be to search the current branch for a match and proceed to the next branch should there be no match. To check if Tom and sam are related, we simply check the first branch by finding all siblings (checking the parent and checking all child elements). This logic then applies as we iterate up the tree.

For example, to see if Sally and Tom are related, first we check if they are siblings, if not then check the siblings of their parents and so on. I do have predicates such as cousin, uncle etc, that can check things like this, but the problem is scalability. It seems ilogical to create predicates for great-great-grandfather, when I could just employ some sort of recursion to check if they are blood related. Thanks in advance :) Here are some basic facts/ predicates to illustrate the angle I am approaching from:

I have more I'm using for the tree but I don't think they are relevant to this question.



  • Prolog программа сортировка дерева

  • Prolog программа сортировка дерева
  • Вам может понравиться: