Liste des Groupes | Revenir à cl prolog |
Given a list of goals representing a conjunction, I would like it to fail as soon as any goal fails, but I would like *not* to cut on the search space otherwise.
Here is my actual test case, only considering ground goals (otherwise too many ways to play with it that seem immaterial to the problem):
```
red(1).
red(1).
and([]) :- !. % with Xs ground!
and([H:B|Xs]) :-
red(B), writeln(H:B),
and(Xs).
/*
Actual:
-------
?- and([x:1,y:1]), fail. % ok: full search space
x:1
y:1
y:1
x:1
y:1
y:1
false.
?- and([x:1,y:0]), fail. % KO: could fail earlier
x:1
x:1
false.
Expected:
---------
?- and([x:1,y:0]), fail. % ok: fails early!
x:1
false.
*/
```
Am I just missing something obvious? I am trying with "ancestral cuts" (SWI-Prolog has these), but I have not yet found a solution.
-Julio
Les messages affichés proviennent d'usenet.