How can I call a predicate if all calls to another predicate failed?
I have:
foo(A, B, C, D) :-
(bar1(Y,Z); bar2(L, K, M)),
foo(A, B, C, D).
What I want :
- at any time, If
bar1/2
has succeded,bar2/3
will never be executed. - if all
bar1/2
calls failed, thenbar2/3
will eventually be executed.
Sample Backtracting tree
root root
|
/ \ |
/ \ all bar1 failed |
/ \ |
/ | \ \ ===>>>======>>>> |
/ | \ \ |
F F F F E
time 0 1 2 3 4
Abbreviation:
Bar1 failed : F
Bar2 executed : E