Liste des Groupes | Revenir à cl prolog |
On 09/12/2024 16:47, Julio Di Egidio wrote:No no, forget that: that is cutting on the search space. The previous solution is it.On 09/12/2024 15:14, Mild Shock wrote:Actually, this one works (no need for a soft cut in `scut`), and it at least starts making sense:Julio Di Egidio schrieb:>>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):
First create a conjunction:
A1,...,An
Wrap each goal Aj into a soft cut:
(Aj *-> true; !).
The cut will abort all previous goals.
Indeed soft-cuts do it, thank you very much!
>
Though with this scheme: `(Aj *-> true; !, fail)`.
>
I have also managed to abstract the recursive scheme away to a meta-predicate, by combining soft with ancestral cuts. But I am not sure how good it is, especially since term rewriting also can do the trick and quite more simply so...
```
scut(G, ChF) :-
( call(G, ChF), !
; prolog_cut_to(ChF),
fail
).
```
Les messages affichés proviennent d'usenet.