Re: Tracing with out using trace?
- From: Bruce Horrocks <news@xxxxxxxxxxxxxxxxx>
- Date: Sun, 03 Sep 2006 12:19:59 +0100
Markus Triska wrote:
What about:
grandparent([Grandparent,Parent,Child]) :-
parent(Grandparent, Parent),
parent(Parent, Child).
Yielding:
?- grandparent(Ls).
Ls = [gramps, homer, bart] ;
and generalising the drawing bit to handle such extended relations
represented as lists? You can keep the old rule as well and use it to
draw the corresponding binary relation.
That would work for a specific degree of relationship. Suppose though that I wished to define a rule "is_related_to". Distant cousins of varying degrees will have a variable number of names in the result list which could not necessarily be tied back to the right relationship.
Or friend-of-friend where there could be any number of connections before getting to a final person?
Regards,
--
Bruce Horrocks
Surrey
England
<firstname>@<surname>.plus.com -- fix the obvious for email
.
- Follow-Ups:
- Re: Tracing with out using trace?
- From: Markus Triska
- Re: Tracing with out using trace?
- References:
- Tracing with out using trace?
- From: Bruce Horrocks
- Re: Tracing with out using trace?
- From: Markus Triska
- Tracing with out using trace?
- Prev by Date: Re: Mainstream Prolog
- Next by Date: Re: Tracing with out using trace?
- Previous by thread: Re: Tracing with out using trace?
- Next by thread: Re: Tracing with out using trace?
- Index(es):
Relevant Pages
|