cut

BAP Online Manuals : Library Reference : Library by Name : cut
Previous: cursor
Next: cutbacktrack

6.2.33. cut

cuts of backtracking

SYNOPSIS

INCLUDE 'prolib.h'
cut(handle)

SYNTAX

cut(cut_point) (i)

ARGUMENTS

handle(cut_point) (i) Handle associated with set_cut.

DESCRIPTION

Together with set_cut () this predicate may be used to effect backtracking. Its effect is, that when backtracking takes place back to the cut() goal, the execution flow takes a short-cut back to the position where the associated set_cut () goal was done. Instead of using set_cut () and cut() you may also use getbacktrack () and cutbacktrack () to achieve the same purpose. Getbacktrack()/Cutbacktrack() works faster, on the other hand you cannot use virtual handles.
NOTE: If you cut back over a set_cut goal, the associated handle is not cleared. You thus might be able to use it in the wrong place, causing the system to crash. This problem will be fixed soon.

EXAMPLE

repeat,
	set_cut(start),
	for(1,5,X),
		write(X),
		X = 3,
		cut(start),
		fail.

This will cause the following output:

123123123 ...

ERRORS

A runtime error occurs if the Handle was not initialised by set_cut . Misuse my crash the system.

LAYERS

prolog-process, client-server, object

RELATED PREDICATES

! , set_cut , getbacktrack , cutbacktrack


BAP Online Manuals : Library Reference : Library by Name : cut
Previous: cursor
Next: cutbacktrack