compose_visitor: compose visitor functions

Description Usage Arguments Value Examples

Description

compose visitor functions

Usage

1
lhs %then% rhs

Arguments

lhs

visitor object

rhs

visitor object

Value

composed visitor object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
add1 <- make_visitor(
  leaf = function(x) if(is.numeric(x)) x + 1 else x
)
mul2 <- make_visitor(
  leaf = function(x) if(is.numeric(x)) x * 2 else x
)
walk_ast(quote(1 + 2 * 3), add1)
walk_ast(quote(1 + 2 * 3), mul2)
walk_ast(quote(1 + 2 * 3), add1 %then% mul2)
walk_ast(quote(1 + 2 * 3), mul2 %then% add1)

TobCap/walkast documentation built on May 9, 2019, 4:51 p.m.