HI,
I have a Zipper tree and try to label (with integers) the nodes in pre-order.
When the function detects state == index it continues processing
instead stopping the processing and return the state value.
See this code:
def find_node( nil, _, _), do: nil
def find_node(_ , state), do: {:ok, state}
def find_node(node, index, counter) do
v = value(node)
Agent.update(counter, fn x -> x + 1 end )
state = Agent.get(counter, &(&1))
if index == state do
#-------------------------------------------------------------
#At his point the function should stop and return with
#the state equal to index
#-------------------------------------------------------------
end
find_node(left( node), index, counter)
find_node(right( node), index, counter)
end