5.6 Soft Cut
Sometimes it is useful to be able to remove a choice point which is
not the last one and to keep the following ones, for example
when defining an if-then-else construct which backtracks also
into the condition.
This functionality is usually called soft cut in the Prolog
folklore.
Softcuts are written as:
A *−> B ; C
If A succeeds, B is executed and on backtracking subsequent
solutions of A followed by B are returned, but C is never executed.
If A fails straight away, C is executed.
The behaviour of *−>/2
is similar to −>/2
with the exception that −>/2
cuts both A and the disjunction if A succeeds, whereas
*−>/2
cuts only the disjunction.