find_nodes: Find Nodes in an RStatic Object

Description Usage Arguments Value See Also Examples

View source: R/find_nodes.R

Description

This function traverses the given RStatic object and returns a list of all descendants that satisfy the given test function.

Usage

1
find_nodes(node, test, ..., recursive = TRUE, initial = list())

Arguments

node

(ASTNode) The RStatic object to search.

test

(function) The test function, which should accept an rstatic object to check as its first argument and return a scalar logical.

...

Additional arguments to the test function.

recursive

(logical) Search recursively in matching nodes?

initial

(list) Initial list of matching nodes.

Value

A list of matching nodes.

See Also

find_node_indices(), replace_nodes()

Examples

1
2
3
4
5
6
7
8
9
ast = quote_ast(
  function(x, y) {
    x = x + y
    function() x
  })

find_nodes(ast, is, "Function")

find_nodes(ast, is_symbol, "x")

nick-ulle/rstatic documentation built on Oct. 18, 2019, 4:38 a.m.