Hi!
I am playing around with inductive logic programming, getting Prolog to search for theories. Naturally, such searches take a lot of time. Are there any good ways to print out every Nth solution during the search (instead of every solution)? In more concrete terms, and simplifying, suppose I have
list([a,b,c,d,e,f,g,h]).
p:-
list(List),
member(X1, List),
q(X2),
format('~w~w ~w~n', ['X1 and X2 are ', X1, X2]).
q(X2):-
list(List),
member(X2, List).
test:- p, fail.
Instead of printing every solution, as the format/2 above does, I would like to print, say, every 10th solution. Or maybe a solution every 10 seconds. In my actual program I don’t want to have a recursive loop to conduct the search (in that case I know that I could have a counter that increments on each recursion and that I could use to print at certain intervals).
Could I use, for example, statistics(runtime, [CurrentTime | _])
somehow? I did some dubious experiments with maybe/1 but that did really not feel right Any suggestions welcome
Kind regards, JCR