4.7 Control Predicates
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Built-in Predicates
        • Control Predicates
          • fail/0
          • false/0
          • true/0
          • repeat/0
          • !/0
          • ,/2
          • ;/2
          • |/2
          • ->/2
          • *->/2
          • \+/1
    • Packages
Availability:built-in
[ISO]!
Cut. Discard all choice points created since entering the predicate in which the cut appears. In other words, commit to the clause in which the cut appears and discard choice points that have been created by goals to the left of the cut in the current clause. Meta calling is opaque to the cut. This implies that cuts that appear in a term that is subject to meta-calling (call/1) only affect choice points created by the meta-called term. The following control structures are transparent to the cut: ;/2, ->/2 and *->/2. Cuts appearing in the condition part of ->/2 and *->/2 are opaque to the cut. The table below explains the scope of the cut with examples. Prunes here means “prunes X choice point created by X” .

t0 :- (a, !, b). % prunes a/0 and t0/0
t1 :- (a, !, fail ; b). % prunes a/0 and t1/0
t2 :- (a -> b, ! ; c). % prunes b/0 and t2/0
t3 :- (a, !, b -> c ; d). % prunes a/0
t4 :- call((a, !, fail ; b)). % prunes a/0
t5 :- \+(a, !, fail). % prunes a/0