Prolog Output Doesn't Put "."

43 Views Asked by At

I have a prolog program which includes some predicates, when i query one of the predicates it displays the true output, but it doesn't put the "." at the end and go to the next query. ChatGPT cannot even understand the problem and i cannot think of anything to do What might be the problem? (i am not able to share my code) The predicate calls a recursive predicate inside it and the results are correct i get

1 ?- predicate(1,2,A,B).
A=1,
B=2  

instead of

1 ?- predicate(1,2,A,B).
A=1,
B=2.

2 ?-
1

There are 1 best solutions below

2
gusbro On

The toplevel doesn't print the dot . because there were some choicepoints left, that upon backtracking will try to find another solution.

Press <space>, ; or <enter>(*) to let the prolog engine try to find another solution, or press <esc>, a or . to cancel further searching for other solutions.

If you want to stop automatically after searching the first solution wrap your query on a once goal, like this:

?- once(predicate(1,2,A,B)).
A = 1,
B = 2.

(*) According to SWI documentation <enter> would stop further searching for alternative solutions but that's not what I geton my SWI 8.5.20 toplevel.