Post-traversal function calls are good

When traversing, it’s a good idea to have a way to call a function on the current node after the traversal is done.

def visit({"some_node", _}, current_path, state) do
    state
    |> update(current_path, fn 
        node -> :new_value
    end)
end

That way you don’t have to keep in mind how the changes might affect the traversal and can potentially optimise operations.

First published 2025-09-12
Last updated
Filed under
  • programming
  • recursion
  • tree-walk
  • parsers