Reputation: 700
I have a C++ function that is supposed to count the number of solutions to an ECLiPSe goal, but it only works if there are choice points. If the goal immediately solves (e.g. returns Yes (0.00s cpu)
in the ECLiPSe REPL without an option to look for more answers) then EC_resume
returns EC_fail
rather than EC_succeed
.
A simple example is reproduced here, where 1=1.
immediately succeeds as an ECLiPSe goal and yet this function terminates with count=0
. If I change it to execute the goal 1=2.
then it still fails and terminates with count=0
. How can I distinguish between these two scenarios?
unsigned int count = 0;
post_goal(term("=", 2), 1, 1));
while (EC_resume() == EC_succeed) {
count++;
post_goal(EC_atom("fail"));
}
P.S. the same happens in the ECLiPSe REPL using the count_solutions/2
predicate defined here.
Upvotes: 0
Views: 15