View Source zipper (zipper v1.1.0)
Summary
Functions
Adds a node as the rightmost child of the current one.
Returns the list of children zippers.
Returns the zipper in the first child, if any.
Edits the current node by applying the given function. The parameters of said function will be [Node | Args].
Returns a list of all the nodes in the zipper that match a predicate.
Returns the root of the tree, where the value of each node (after the current location of Zipper) is replaced with the result from applying Fun to the node as the first argument and Args as additional arguments.
Applies Fun recursively on the zipper. The arguments of Fun will be (Node, Acc) where Acc is the result of the previous call or the initial value provided.
Adds a node as the leftmost child of the current one.
Inserts a node to the left of the current one.
Inserts a node to the right of the current one.
Is this node a branch?
Is it the end of the zipper traversal.
Returns the zipper on the left, if any.
Returns the leftmost zipper in the current zipper.
Applies a function to all nodes of the zipper. Returns a list with the results.
Builds a new zipper with nodes of type T.
Returns the next zipper.
Returns the value of the current node in the zipper.
Returns the previous zipper.
Removes current node from zipper. Moves down, if possible. If not, it moves to the rightmost node.
Replaces the current node.
Returns the zipper on the right, if any.
Returns the rightmost zipper in the current zipper.
Returns the node on the root of the zipper.
Returns the size of the zipper.
Traverses the zipper following the given list of operations. If, at some point, an operation is invalid, it will crash.
Returns the zipper in the parent node, if possible.
Types
-type children_fun(T) :: fun((T) -> [T]).
-type info(T) :: #{lefts => [T], rights => [T], parent_node => undefined | T, parent_info => undefined | info(T), is_modified => boolean()}.
-type is_branch_fun(T) :: fun((T) -> boolean()).
-type make_node_fun(T) :: fun((T, [T]) -> T).
-type operation() :: next | prev | up | down | left | right | root | node | rightmost | leftmost.
-opaque zipper(T)
Functions
-spec filter(fun((T) -> boolean()), zipper(T)) -> [T].
-spec fmap(fun((...) -> T), [term()], zipper(T)) -> T.
-spec fold(fun((T, A) -> A), A, zipper(T)) -> A.
-spec is_branch(zipper(_)) -> boolean().
-spec is_end(zipper(_)) -> boolean().
-spec map(fun((T) -> U), zipper(T)) -> [U].
-spec new(is_branch_fun(T), children_fun(T), make_node_fun(T), T) -> zipper(T).
-spec node(zipper(T)) -> T.
-spec root(zipper(T)) -> T.
-spec size(zipper(_)) -> non_neg_integer().