'One common hobby between two persons in Prolog
I found this old question ( Prolog Predicate to return true when two people have same hobby ) for writing some code to find the same hobby between two persons using dif. I have a similar situation, to display the names of two persons that have the same hobbies,but the hobbies element is defined as a list. Whatever I try it doesn't seem to work, any ideas would be appreciated.
This is what I have so far:
one_common_hobby(P1,P2):-
dif(P1,P2),
person(P1,_,_,hobbies([H|Tail])),
person(P2,_,_,hobbies([H|Tail])),
member(P1,Tail),
member(P2,Tail).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
