Last active
September 15, 2016 19:49
-
-
Save rozap/ba6bbe62d6f081ff6b2621206960c35c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Foo do | |
def to_strings(m) when is_map(m) do | |
m | |
|> Enum.map(fn | |
{k, v} when is_integer(k) -> {Integer.to_string(k), to_strings(v)} | |
{k, v} -> {k, to_strings(v)} | |
end) | |
|> Enum.into(%{}) | |
end | |
def to_strings(a_list) when is_list(a_list) do | |
Enum.map(a_list, &to_strings/1) | |
end | |
def to_strings(not_map), do: not_map | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment