Hi,
How do I have to change fun to collect data in Postwalk?
ast = quote do
if ( a < b ) and (c < d ) -> x = z
end
fun = fn node, acc ->
if is_tuple(node), do: IO.inspect(elem(node,0))
{node, acc}
end
This is the result:
iex(1)> ast |> Macro.postwalk([], fun) |> Enum.reverse
:a
:b
:<
:c
:d
:<
:and
:x
:z
:=
:then
:if
** (Protocol.UndefinedError) protocol Enumerable not implemented for {{:if, [context: Elixir, import: Kernel], [{:and, [context: Elixir, import: Kernel], [{:<, [context: Elixir, import: Kernel], [{:a, [], Elixir}, {:b, [], Elixir}]}, {:<, [context: Elixir, import: Kernel], [{:c, [], Elixir}, {:d, [], Elixir}]}]}, {:then, [], [{:=, [], [{:x, [], Elixir}, {:z, [], Elixir}]}]}]}, []}
(elixir) lib/enum.ex:1: Enumerable.impl_for!/1
(elixir) lib/enum.ex:116: Enumerable.reduce/3
(elixir) lib/enum.ex:1636: Enum.reduce/3
Thanks in advance,
Thiel