Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!rutgers!psuvax1!psuvm!f0o From: F0O@psuvm.psu.edu Newsgroups: comp.lang.prolog Subject: Finding all solutions in Prolog Message-ID: <90216.112514F0O@psuvm.psu.edu> Date: 4 Aug 90 15:25:14 GMT Organization: Penn State University Lines: 31 I have a fairly simple question, but yet have never ran across any book that explains it. If you have a simple PDC prolog program like: predicates person(symbol) clauses person(jack). person(jill). person(mary). and from the goal prompt type: person(X), you will get all 3 persons. But if you have an internal goal like: person(X), write(X),nl. prolog will only find the first person. You would have to use the fail predicate to force Prolog to find all solutions. Why does Prolog only find the first solution on internal goals? I'd think finding all solutions to a query would be more common than only finding one. I can see that only finding one solution and then using the fail predicate gives you control over the search, however you could also use the cut if you wanted to limit the search. Am I missing something fundamental here? [Tim]