Print last choice point

While trying to eliminate choice points, especially during tests, you would like to know what predicate
left the last choice point. Add this to your init file to print out the last choice point:

print_chpoint :-
   prolog_current_choice(ChI),
   prolog_choice_attribute(ChI,frame,F),
   prolog_frame_attribute(F,goal,Goal),
   format('Last choice point: ~w', [ Goal ]).

Then you can call it at the end of your test predicate to see who is leaving the choice point.

7 Likes