traverse v0.1.2 Traverse.Walker
Implements traversal functions, structure is not maintained unless the traversal functions do so.
Summary
Functions
walk
implements a top down recursive pre traversal in an arbitrary Elixir datastructure
Types
t_simple_filter_fn :: (any -> boolean)
t_simple_mapper_fn :: (any -> any)
t_simple_walker_fn :: (any, any -> any)
t_traceable_fn ::
(any -> any) |
(any, any -> any) |
(any, any, any -> any)
Functions
Specs
walk(any, any, t_simple_walker_fn) :: any
walk
implements a top down recursive pre traversal in an arbitrary Elixir datastructure.
Lists and Tuples are traversed, while maps are considered scalar data.
iex> Traverse.Walker.walk( {1, [2, %{a: 3}, 4], 5}, 0,
...> fn (n, acc) when is_number(n) -> acc + n
...> _, acc -> acc end )
12
The traversal function can avoid recursive descent by returning its accumulator value boxed in a %Cut{acc: acc}
struct.