Since OTP 18 there is a pretty convenient function :maps.filter
<http://erlang.org/doc/man/maps.html#filter-2>.
I think it would be nice to have Map.filter(map, predicate) in Elixir as
well instead of doing
map|> Enum.filter(predicate)|> Enum.into(%{})
or
for {key, value} <- map, some_filter(key, value), into: %{}, do: {key, value}
The first one alternative is slower, b/c of 2-step transformation, and the
second one consume more memory, could not be piped and has a lack
of expressiveness (too imperative way to do a simple filtration).
There were benchmarks and a small discussion in PR:
https://github.com/elixir-lang/elixir/pull/9292, but the discussion should
be moved to this mailing list.
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elixir-lang-core/5d403c4a-91f8-4c4d-8dc0-297185a2aed8%40googlegroups.com.