Search code examples
prologbacktrackingprolog-toplevel

Automatic results showing?


How can I make SWI-Prolog interpreter to automatically do a semicolon? I have a lot of results (about 300) due to backtracking and I don't want to push semicolon for all of them.

I do NOT want a list of all solutions, I only want not to push semicolon or space so I can leave the program printing backtracked solutions on background.


Solution

  • You can manually emit solutions (using for example write/1 or format/2), and force backtracking with false to see all solutions. For example:

    ?- solution(S), writeln(S), false.

    In addition, for example in SWI-Prolog, you can simply press SPACE instead of ; for further solutions.