Skip to content

Instantly share code, notes, and snippets.

@BrooklinJazz
Created June 7, 2021 18:37
Show Gist options
  • Select an option

  • Save BrooklinJazz/a2afba2f310d0ac1ee6eef32667d5ce7 to your computer and use it in GitHub Desktop.

Select an option

Save BrooklinJazz/a2afba2f310d0ac1ee6eef32667d5ce7 to your computer and use it in GitHub Desktop.
Elixir Enum Examples
Enum.map([1, 2, 3], fn x -> x * 2 end) # [2, 4, 6]
Enum.sum([1, 2, 3]) # 6
Enum.map(1..3, fn x -> x * 2 end) # [2, 4, 6]
Enum.sum(1..3) # 6
map = %{"a" => 1, "b" => 2}
Enum.map(map, fn {k, v} -> {k, v * 2} end) # [{"a", 2}, {"b", 4}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment