Executes a function on a set of nodes

# OO-style:
# node$Do(fun, 
#         ..., 
#         traversal = c("pre-order", "post-order", "in-order", "level", "ancestor"), 
#         pruneFun = NULL, 
#         filterFun = NULL)
         
# traditional:
Do(nodes, fun, ...)

Arguments

nodes

The nodes on which to perform the Get (typically obtained via Traverse)

fun

the function to execute. The function is expected to be either a Method, or to take a Node as its first argument

...

any additional parameters to be passed on to fun

See also

Examples

data(acme)
traversal <- Traverse(acme)
Do(traversal, function(node) node$expectedCost <- node$p * node$cost)
print(acme, "expectedCost")
#>                           levelName expectedCost
#> 1  Acme Inc.                                  NA
#> 2   ¦--Accounting                             NA
#> 3   ¦   ¦--New Software                   500000
#> 4   ¦   °--New Accounting Standards       375000
#> 5   ¦--Research                               NA
#> 6   ¦   ¦--New Product Line               500000
#> 7   ¦   °--New Labs                       675000
#> 8   °--IT                                     NA
#> 9       ¦--Outsource                       80000
#> 10      ¦--Go agile                        12500
#> 11      °--Switch to R                     50000