MapExpressionNodes
transforms an expression expr
by
replacing every node in the tree with the result of applying a function
f
. The parameters functions
, inners
, and leafs
control if f
should be applied to the function symbols, inner
subtrees, and leafs of expr
, respectively.
MapExpressionLeafs
and MapExpressionSubtrees
are shorthands
for calls to MapExpressionNodes
.
expr
.
an expression expr
.
expr
, given as list of nodes and and list of vertices. Each
vertex is represented as a pair of indices into the list of nodes.
AllExpressionNodes
checks if all nodes in the tree of expr
satisfy the predicate p
(p
returns TRUE
for every node).
This function short-cuts returning FALSE
as soon as a node that
does not satisfy p
is encountered.
AnyExpressionNode
checks if any node in the tree of expr
satisfies the predicate p
. This function short-cuts returning
TRUE
as soon as a node that satisfies p
is encountered.
subtreeAt
returns the subtree at index
.
replaceSubtreeAt
replaces the subtree at index
with
replacement
and returns the result.
MapExpressionNodes(f, expr, functions = TRUE, inners = FALSE, leafs = TRUE)
MapExpressionLeafs(f, expr)
MapExpressionSubtrees(f, expr)
FlattenExpression(expr)
subtrees(expr, functions = FALSE, inners = TRUE, leafs = TRUE)
expressionGraph(expr)
AllExpressionNodes(p, expr)
AnyExpressionNode(p, expr)
subtreeAt(expr, index)
replaceSubtreeAt(expr, index, replacement)
f
to the function symbols
of expr
. Defaults to TRUE
.f
to the inner subtrees of
expr
. Defaults to FALSE
.f
to the leafs of expr
.
Defaults to TRUE
.0
(the root).