explain the effect of the cut (!) predicates in PROLOG?
explain the effect of the cut (!) predicates in PROLOG?
Collapse
X
-
Tags: None
-
Usage of cut after repeat-fail constructs
The cut opeator (denoted by !) stops the backtracking back to it.
The cut in the above fragment prevents the backtracking toCode:repeat, possible_values(X), do_something(X,Y), check(X), !, continue_task(Y),
in case of failedCode:do_something(X,Y)
.Code:continue_task(Y)
_____________
Hint
RegardsCode:PREDICATES nondeterm repeat CLAUSES repeat. repeat if repeat.
Frank
Comment