traverse v0.1.6 Traverse.Walker

Implements traversal functions, structure is not maintained unless the traversal functions do so.

Link to this section Summary

Functions

walk implements a top down recursive pre traversal in an arbitrary Elixir datastructure

Link to this section Types

Link to this type t_simple_filter_fn()
t_simple_filter_fn() :: (any() -> boolean())
Link to this type t_simple_mapper_fn()
t_simple_mapper_fn() :: (any() -> any())
Link to this type t_simple_walker_fn()
t_simple_walker_fn() :: (any(), any() -> any())
Link to this type t_traceable_fn()
t_traceable_fn() ::
  (any() -> any()) |
  (any(), any() -> any()) |
  (any(), any(), any() -> any())

Link to this section Functions

Link to this function walk(coll, acc, collector)
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.