% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/terminator.R
\name{terminator}
\alias{terminator}
\title{Constructor of a terminator object}
\usage{
terminator(cond = FALSE, Delta = 1, print = TRUE, plotter = NULL, ...)
}
\arguments{
\item{cond}{a termination condition. Either an expression or call that
evaluates to a logical.}

\item{Delta}{an integer specifying how often the termination condition
is evaluated. \code{Delta = 0} means never, and otherwise
the condition is evaluated every \code{Delta}-th iteration.
\code{Delta = 1} is the default.}

\item{print}{a variable name to print or a logical. If FALSE, nothing is
printed. If a variable name is given, that variable (if it exists)
will be printed every \code{Delta}-th iteration. If TRUE (the
default) the last variable in \code{cond} is printed
every \code{Delta}-th iteration.}

\item{plotter}{an expression, possibly created by the \code{plotter} function.}

\item{...}{other arguments passed to \code{format} for printing and
\code{plot.window}}
}
\value{
A terminator object containing the functions \code{terminator} and
\code{clear}.
}
\description{
Terminator objects are used to write termination conditions
that can be tested via a callback function within another function
during its evaluation.
}
\details{
Terminator objects are similar to tracer objects but serve a different
purpose. Like tracer objects, they can be used to trace, print and
plot values of a variable within the evaluation environment of another
function during its evaluation. The primary purpose of a terminator
object is, however, to evaluate a termination condition, which can
trigger termination of a loop. Terminator objects do not save trace
information and do not trace runtime.
}
\examples{
term <- terminator(quote(i >= 3), print = FALSE)

for (i in 1:5) {
  if (term$terminator()) {
    break
  }
}

i
}
