I am almost done with a directive and a meta-calling predicate that I have been working on.
The meta-calling predicate looks like this:
%! call_iterating_depth(Goal, Options) is multi. % % Calls Goal successively trying deeper recursion depths until Goal succeeds. % * fails silently if Goal fails. % * Stops trying new depths on the first depth that succeeds. % * fails silently if the end(Depth) given as an option is reached. % % Options: % * start(Start): set initial depth to try, default 3. % * step(Step): set increment between depths, default 1. % * end(End): set last depth to try, default `inf` (infinite)
I can contribute this code to the community if there is interest.
There is also a directive called
:- iterate_depth PredIndicator which wraps the original predicate and allows iterating the recursion depth on existing predicates.
I am now writing the test cases, so I would appreciate any test scenarios that you can think of.
Also I am debating between
inf and a large number for the default value for the
end(Depth) option. What do you think makes more sense?