defmodule Main do
def traverse(name \\ "", struct)
def traverse(root, map) when is_map(map), do: Enum.each(map, fn {key, value} -> traverse("#{root}.#{key}", value) end)
def traverse
(key
, value
), do: IO.
puts "#{key} --> #{value}"
def main do
traverse(%{a: 1, b: %{c: 2, d: %{e: 3, f: 4}}})
end
end
Main.main
ZGVmbW9kdWxlIE1haW4gZG8KICBkZWYgdHJhdmVyc2UobmFtZSBcXCAiIiwgc3RydWN0KQogIGRlZiB0cmF2ZXJzZShyb290LCBtYXApIHdoZW4gaXNfbWFwKG1hcCksIGRvOiBFbnVtLmVhY2gobWFwLCBmbiB7a2V5LCB2YWx1ZX0gLT4gdHJhdmVyc2UoIiN7cm9vdH0uI3trZXl9IiwgdmFsdWUpIGVuZCkKICBkZWYgdHJhdmVyc2Uoa2V5LCB2YWx1ZSksIGRvOiBJTy5wdXRzICIje2tleX0gLS0+ICN7dmFsdWV9IgoKICBkZWYgbWFpbiBkbwogICAgdHJhdmVyc2UoJXthOiAxLCBiOiAle2M6IDIsIGQ6ICV7ZTogMywgZjogNH19fSkKICBlbmQKZW5kCgpNYWluLm1haW4K