Access.find/1 and Access.filter/1

49 views
Skip to first unread message

Zach Daniel

unread,
Oct 4, 2017, 6:11:53 PM10/4/17
to elixir-lang-core
Some utilities that I often wish I had are `Access.filter/1` and `Access.find/1`. Often I find myself doing something like

list_of_results = get_in(some_list, [:path_a, :path_b])

filtered_results = Enum.filter(list_of_results, &some_predicate/1)

get_in
(filtered_results, [Access.all(), :a, :b])


The PR w/ documentation and information can be found here: https://github.com/elixir-lang/elixir/pull/6634

Let me know what you guys think!
Message has been deleted

Zach Daniel

unread,
Oct 4, 2017, 11:41:31 PM10/4/17
to elixir-lang-core
Apologies for using the informal "you guys", I sometimes forget that it is not an inclusive identifier. To anyone reading, use something like "you folks" or "everyone". :)

binaryseed

unread,
Oct 5, 2017, 1:02:33 PM10/5/17
to elixir-lang-core
This is great! I've written a similar helper before to pick a single map out of a list of maps that matches a desired {key, val}

Zach Daniel

unread,
Oct 5, 2017, 11:59:01 PM10/5/17
to elixir-lang-core
Yeah, it seemed like pretty common behavior in my projects as well. Now it is merged, so we should see it in 1.6! :)
Reply all
Reply to author
Forward
0 new messages