cutbacktrack

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

6.2.34. cutbacktrack

cuts of backtracking

SYNOPSIS

cutbacktrack(BTP)

SYNTAX

cutbacktrack(BackTrackPoint) (i)

ARGUMENTS

integer(BackTrackPoint) (i) A value obtained by getbacktrack.

DESCRIPTION

Together with getbacktrack () this predicate may be used to effect backtracking. Its effect is, that when backtracking takes place back to the cutbacktrack() goal, the execution flow takes a short-cut back to the position where the associated getbacktrack() goal was done.
Instead of using getbacktrack() and cutbacktrack() you may also use set_cut () and cut () 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,
	getbacktrack(BTP),
	for(1,5,X),
		write(X),
		X = 3,
		cutbacktrack(BTP),
		fail.

This will cause the following output: 123123123 ...

ERRORS

A runtime error occurs if BackTrackPoint is invalid. However, misuse may crash the system.

LAYERS

prolog-process, client-server, object

RELATED PREDICATES

! , set_cut , cut , getbacktrack


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