tree_apply: Tree apply

Description Usage Arguments Details Value

View source: R/tree-helpers.R

Description

Applies a function to tree leaves only.

Usage

1
tree_apply(tree, leaf_def, action_def)

Arguments

leaf_def

function which takes a node and returns TRUE only if the node is a leaf.

action_def

function to run on each leaf node.

x

the tree-shaped list

Details

In this terminology a tree is a multi-level list, not necessarily balanced, and each tree branch ends in a node which is defined _only_ by the 'leaf_def' function. At each leaf the 'action_def' function is applied.

Value

a list matching the tree structure and each node processed by the provided function.


sakrejda/simachine documentation built on May 29, 2019, 1 p.m.