Created
May 17, 2018 15:26
-
-
Save leandrocp/65ab75d67ec17186d1e55dd71fe89ff8 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
iex>h Enum.map | |
def map(enumerable, fun) | |
@spec map(t(), (element() -> any())) :: list() | |
Returns a list where each item is the result of invoking fun on each | |
corresponding item of enumerable. | |
For maps, the function expects a key-value tuple. | |
## Examples | |
iex> Enum.map([1, 2, 3], fn(x) -> x * 2 end) | |
[2, 4, 6] | |
iex> Enum.map([a: 1, b: 2], fn({k, v}) -> {k, -v} end) | |
[a: -1, b: -2] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment