Pipe a possibly unresolved value forward into a function.

x %>>% f

Arguments

x

a value that is possibly an 'unresolvedValue'.

f

a function that accepts 'x' as its first argument.

Value

The evaluated result, or if x is an 'unresolvedValue', an 'unresolvedExpr'.

Details

An 'unresolvedExpr' encapsulates the eventual evaluation result. Query its $data element for resolution. Once resolved, the object changes into a 'resolvedExpr' and the evaluated result will be available at $data.

Supports stringing together a series of piped expressions (as per the below example).

unresolved may be used on an 'unresolvedExpr' or its $data element to test for resolution.

Usage

Usage is similar to R's native |> pipe.

x %>>% f is equivalent to f(x)

x %>>% f() is equivalent to f(x)

x %>>% f(y) is equivalent to f(x, y)

Please note that other usage is not supported and it is not a drop-in replacement for magrittr's %>% pipe.

Examples

if (interactive()) {
# Only run examples in interactive R sessions

m <- mirai({Sys.sleep(0.5); 1})
b <- m$data %>>% c(2, 3) %>>% as.character()
b
b$data
Sys.sleep(1)
b$data
b

}