Skip to content

Instantly share code, notes, and snippets.

@rozap
Last active September 15, 2016 19:49
Show Gist options
  • Save rozap/ba6bbe62d6f081ff6b2621206960c35c to your computer and use it in GitHub Desktop.
Save rozap/ba6bbe62d6f081ff6b2621206960c35c to your computer and use it in GitHub Desktop.
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