Fam grandparents

Description

A more efficient version of grandparent

Source: The Art of Prolog

Download

Program source code: fam_grandparents.pl

Listing

/*
   grandparent(X,Z) :- X is the grandparent of Z.
*/
   grandparent(X,Z) :- nonvar(X), parent(X,Y), parent(Y,Z).
   grandparent(X,Z) :- nonvar(Z), parent(Y,Z), parent(X,Y).
 
%  Program 10.3  A more efficient version of grandparent

Comments

pl/prolog/pllib/fam_grandparents.txt · ostatnio zmienione: 2019/06/27 15:50 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0