Skip to content

Commit 98c5c1c

Browse files
committed
remove Zipper.reduce/3 - bugged, but more importantly unused
1 parent d35a28d commit 98c5c1c

File tree

1 file changed

+0
-20
lines changed

1 file changed

+0
-20
lines changed

lib/zipper.ex

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -317,26 +317,6 @@ defmodule Styler.Zipper do
317317
if next = next(zipper), do: do_traverse(next, acc, fun), else: {top(zipper), acc}
318318
end
319319

320-
@doc """
321-
Same as `traverse/3`, but doesn't waste cycles going back to the top of the tree when traversal is finished
322-
323-
Useful when only the accumulator is of interest, and no updates to the zipper are.
324-
"""
325-
@spec reduce(zipper, term, (zipper, term -> {zipper, term})) :: term
326-
def reduce({_, nil} = zipper, acc, fun) do
327-
do_reduce(zipper, acc, fun)
328-
end
329-
330-
def reduce({tree, meta}, acc, fun) do
331-
{{updated, _meta}, acc} = do_reduce({tree, nil}, acc, fun)
332-
{{updated, meta}, acc}
333-
end
334-
335-
defp do_reduce(zipper, acc, fun) do
336-
{zipper, acc} = fun.(zipper, acc)
337-
if next = next(zipper), do: do_reduce(next, acc, fun), else: acc
338-
end
339-
340320
@doc """
341321
Traverses the tree in depth-first pre-order calling the given function for
342322
each node.

0 commit comments

Comments
 (0)