This file contains 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 MyModule do | |
def hello do | |
"Hello, World!" | |
end | |
end | |
IO.puts(MyModule.hello) |
This file contains 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 MyModule do | |
def hello do | |
"Hello, World!" | |
end | |
end | |
IO.puts(MyModule.hello) |
This file contains 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
IO.inspect {:ok, agent} = Agent.start_link fn -> [] end | |
IO.inspect Agent.update(agent, fn list -> ["eggs"|list] end) | |
IO.inspect Agent.get(agent, fn list -> list end) | |
IO.inspect Agent.stop(agent) |
This file contains 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 MyModule do | |
def hello do | |
"Hello, World!" | |
end | |
end | |
IO.puts(MyModule.hello) |
This file contains 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 MyModule do | |
def hello do | |
"Hello, World!" | |
end | |
end | |
IO.puts(MyModule.hello) |
This file contains 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 Crutches.Map do | |
def deep_key_change(map, fun), do: deep_key_change(map, fun, %{}) | |
def deep_key_change(map, _, acc) when map == %{}, do: acc | |
def deep_key_change(map, fun, acc) do | |
map | |
|> Enum.reduce acc, fn(submap, akk) -> | |
case submap do | |
{key, value} when is_map(value) -> | |
Map.put(akk, fun.(key), deep_key_change(value, fun, %{})) | |
{key, value} -> |
This file contains 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 Crutches.Map do | |
def deep_key_change(map, fun), do: deep_key_change(map, fun, %{}) | |
def deep_key_change(map, _fun, acc) when map == %{}, do: acc | |
def deep_key_change(map, fun, acc) do | |
map | |
|> Enum.reduce acc, fn(submap, akk) -> | |
case submap do | |
{key, value} when is_map(value) -> | |
Map.put(akk, fun.(key), deep_key_change(value, fun, %{})) | |
{key, value} -> |
This file contains 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 MyModule do | |
def hello do | |
"Hello, World!" | |
end | |
end | |
IO.puts(MyModule.hello) |
This file contains 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 MyModule do | |
def hello do | |
"Hello, World!" | |
end | |
end | |
IO.puts(MyModule.hello) |
This file contains 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
IO.puts "Hi!" |
OlderNewer