Skip to content

Instantly share code, notes, and snippets.

@leandrocp
Created May 17, 2018 15:26
Show Gist options
  • Save leandrocp/65ab75d67ec17186d1e55dd71fe89ff8 to your computer and use it in GitHub Desktop.
Save leandrocp/65ab75d67ec17186d1e55dd71fe89ff8 to your computer and use it in GitHub Desktop.
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