BAP Online Manuals : Library Reference : Library by Name : set_cut
Previous: setprofile
Next: set_flush_nl

6.2.121. set_cut

sets a backtrack point

SYNOPSIS

getbacktrack(handle)

SYNTAX

cutbacktrack(BackTrackPoint) (i)

ARGUMENTS

handle(BackTrackPoint) (i) A virtual handle to be used with cut().

DESCRIPTION

Together with 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 getbacktrack() goal was done.
Instead of using set_cut() and cut() you may also use getbacktrack () and cutbacktrack () to achieve the same purpose. set_cut()/cut() are more comfortable in a way that you may use virtual handle, but they work sufficiently slower.

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 in case of misuse of virtual handles. However, misuse may crash the system.

LAYERS

prolog-process, client-server, object

RELATED PREDICATES

! , cut , cutbacktrack , getbacktrack


BAP Online Manuals : Library Reference : Library by Name : set_cut
Previous: setprofile
Next: set_flush_nl