Description Constructors Methods Author(s) Examples
An Operation
object implements a Command
with an R
closure. This may be useful as a base for customized Command
derivatives. Otherwise, consider it a skeletal proof-of-concept.
Operation(do, undo = NULL)
: Constructs
an Operation
that invokes the closure do
. If
undo
is specified, it is the closure invoked for the
reverse operation.
OperationQ(do, undo)
: Constructs
an Operation
that invokes a function with the body taken from
the quoted argument do
. The function is enclosed in the
calling environment. If undo
is specified, it is
treated equivalently to do
, except it should implement the
reverse operation.
eval(expr)
: Executes the operation by evaluating the
closure.
rev(x)
: Returns a new Operation
that performs
the reverse operation, as long as undo
was provided.
Michael Lawrence
1 2 3 4 5 6 7 8 | op <- OperationQ(message("hello world"))
eval(op)
x <- 2
op <- OperationQ(x^2, sqrt(x))
x <- eval(op)
rop <- rev(op)
identical(2, eval(rop))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.