1
votes

I am examining a Prolog example as a tutorial. In this example I have a predicate with Zero operand like this:

print_all_solutions :-
   findall(_,print_solution,_).

how can I call print_all_solution in the console? When I ask this in the Prolog console I get nothing:

?- print_all_solutions

no answer, also :

?- print_all_solutions.

no answer.

While i get correct answers to other questions like:

 ?- goal(state([],right,[a,b,c,d],12)).
true.

 ?- goal(state([],right,[a,b,c,d],19)).
false.

How should I ask a question about predicates with no operand ( /0 ), to see the solution in the console?

2
How is print_solutions defined. It all depends. - false

2 Answers

2
votes

I guess your problem is that either init(State) or, more probably, solve(State,Solution,EndState) don't work.

You need to debug: enter these commands after you consulted the source file

?- leash(-all),trace.
?- print_solution.

and you'll get some clue from the Prolog engine

0
votes

I simply typed this in the console:

findall(_,print_all_solutions,_).

and i get the answer.