Get information on whether a node is a leaf (meaning that it doesn't have any children) and whether it is named.
Arguments
- x
A node, either from
tree_root()
or from anothernode_*()
function.
Examples
src <- "x <- rnorm(100, mean = 2)
any(duplicated(y))
x <- z + 1
any(duplicated(x))"
root <- src |>
tree_new() |>
tree_root()
node_is_leaf(root)
#> [[1]]
#> [1] FALSE
#>
root |>
node_find(ast_rule(pattern = "z")) |>
node_is_leaf()
#> $rule_1
#> [1] TRUE
#>
root |>
node_find(ast_rule(pattern = "z")) |>
node_is_named()
#> $rule_1
#> [1] TRUE
#>