%{"a" => 1, "b" => 2}
|> Enum.map(fn {k, v} -> {String.upcase(k), v} end)
|> Enum.into(%{})
%{"a" => 1, "b" => 2}
|> Enum.map(fn {k, v} -> {String.upcase(k), v} end, into: %{})
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/23c345b9-9ba1-48ea-8db0-6d2e9e700473%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Does the Enumerable protocol enable the performance improvement of not converting to a list? I don't think it does.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAM9Rf%2BLY6tyh%3DE6iM%2BA7rmyY8dKP-ddCJpB%2BWZDn0jCuJ7FKaA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAOMhEnyR_50BhVdVugiQqDUxY9jUBNRCR23Bao%3DhwQ9Zmeh4PA%40mail.gmail.com.
Michał.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/23c345b9-9ba1-48ea-8db0-6d2e9e700473%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--Andrea Leopardi--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAM9Rf%2BLY6tyh%3DE6iM%2BA7rmyY8dKP-ddCJpB%2BWZDn0jCuJ7FKaA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/23c345b9-9ba1-48ea-8db0-6d2e9e700473%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Andrea Leopardi--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAM9Rf%2BLY6tyh%3DE6iM%2BA7rmyY8dKP-ddCJpB%2BWZDn0jCuJ7FKaA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.--
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAOMhEnyR_50BhVdVugiQqDUxY9jUBNRCR23Bao%3DhwQ9Zmeh4PA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/af052020-b329-49e0-a7b7-f0bf487c123c%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/23c345b9-9ba1-48ea-8db0-6d2e9e700473%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/23c345b9-9ba1-48ea-8db0-6d2e9e700473%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Andrea Leopardi--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAM9Rf%2BLY6tyh%3DE6iM%2BA7rmyY8dKP-ddCJpB%2BWZDn0jCuJ7FKaA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.--
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAOMhEnyR_50BhVdVugiQqDUxY9jUBNRCR23Bao%3DhwQ9Zmeh4PA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
--To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/af052020-b329-49e0-a7b7-f0bf487c123c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/1afb754e-5d9b-41ff-a855-161610e63908%40googlegroups.com.
To be fair, :maps.map is the fastest. But it's about as fast as :lists.map . Enum has a lot of overhead.
Enum.into/3 should do what you want :)
On Thursday, 7 July 2016, Wiebe-Marten Wijnja <w.m.w...@panache-it.com> wrote:
I propose to add `into: collectable` as optional third argument to Enum.map.--This would allow mapping over things without first converting it to a list and then convert it back.So:
%{"a" => 1, "b" => 2}
|> Enum.map(fn {k, v} -> {String.upcase(k), v} end)
|> Enum.into(%{})could be written as:
%{"a" => 1, "b" => 2}
|> Enum.map(fn {k, v} -> {String.upcase(k), v} end, into: %{})
Not having to do the list conversion in the middle might also improve performance.Right now, enumerating and collecting in one go is of course possible using `Kernel.SpecialForms.for`. `for` is however not very pipeline-friendly.What do you think?Sincerely,~Wiebe-Marten
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/23c345b9-9ba1-48ea-8db0-6d2e9e700473%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--Andrea Leopardi
I do agree that documentation in Enum could mention that. I'm inclined to stick it in the moduledoc though because it applies to conceptually to the whole module. By way of example, it's just as relevant to filter as it is to map.