I am working with Enum.reduce and trying to add some debugging outputs to the reduction, but does not seem to output it in Enum.reduce/2 . Works as expected in Enum.reduce/3 .
nodes = [%{"value" => "x"}] Enum.each(nodes, fn (node) -> IO.puts "Each" IO.inspect node["value"] end) Enum.reduce(nodes, fn (node, acc) -> IO.puts "Reduce" IO.inspect node["value"] [node["value"], acc] end) Enum.reduce(nodes, [], fn (node, acc) -> IO.puts "Pre-accumulator" IO.inspect node["value"] [node["value"], acc] end)
When I run it, I get the following:
Each "x" Pre-accumulator "x"
source share