iteraptor v1.2.0 Iteraptor.AST View Source
Iteraptor.AST
module traverses AST, allowing map
, reduce
and family.
Link to this section Summary
Functions
Reduces the AST with an accumulator
Link to this section Functions
Reduces the AST with an accumulator.
Parameters
input
: the AST to traverseacc
: the accumulatorfun
: the function to be called on the tree elementopts
: the options to be passed to the iterationyield
::all | nil
what to yield; default:nil
for yielding values only.
Examples
iex> ":math.sin(42 * a / (3.14 * b)) > c"
...> |> Iteraptor.AST.reduce([], fn
...> {var, _, val}, acc when is_atom(val) -> [var | acc]
...> _, acc -> acc
...> end)
...> |> Enum.reverse()
~w|a b c|a