fork download
  1. grandchild(X, Z) :- child(X, Y), child(Y, Z).
  2.  
  3. child(hideyasu, ieyasu).
  4. child(hidetada, ieyasu).
  5. child(yoshinao, ieyasu).
  6. child(yorinobu, ieyasu).
  7. child(yorifusa, ieyasu).
  8.  
  9. child(iemitsu, hidetada).
  10. child(tadanaga, hidetada).
  11. child(masayuki, hidetada).
  12.  
  13. child(ietsuna, iemitsu).
  14. child(tsunayoshi, iemitsu).
  15.  
  16. program :-
  17. findall(X, grandchild(X, ieyasu), Bag),
  18. print(Bag).
  19.  
Success #stdin #stdout #stderr 0.01s 6004KB
stdin
Standard input is empty
stdout
[iemitsu,tadanaga,masayuki]
stderr
% halt