less-than-.foolbox_pipe: This operator is used together with 'rewrites' to transform a...

Description Usage Arguments See Also Examples

Description

This operator is used together with rewrites to transform a function after it is defined and before it is assigned to a name.

Usage

1
2
## S3 method for class 'foolbox_pipe'
pipe < fn

Arguments

pipe

A specificiation of a a pipeline of transformations provided using the subscript operator to rewrites().

fn

The function we wish to transform.

See Also

[.foolbox_rewrite_spec

rewrites

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# This is a very simple inline function that require we
# provide the function body as it should be inserted.
# For a more detailed version, see the Tutorial vignette.
inline <- function(f, fn, body) {
   body <- substitute(body)
   rewrite(f) %>%
     rewrite_with(
         rewrite_callbacks() %>%
           add_call_callback(fn, function(expr, ...) body)
     )
}

g <- function(x) x**2
h <- rewrites[inline(g,y**2)] < function(y) y + g(y)
h

foolbox documentation built on May 1, 2019, 8:44 p.m.