Created
June 7, 2021 18:37
-
-
Save BrooklinJazz/a2afba2f310d0ac1ee6eef32667d5ce7 to your computer and use it in GitHub Desktop.
Elixir Enum Examples
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
| 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