Is there an elegant (even terse) way of filtering or findings a map in a list of maps by the values of another map? I don’t want to hard code any keys/values, so preferably it would all be dynamic.
list_of_maps = [
%{id: 1, one: "two", three: "four"},
%{id: 2, one: "five", three: "six"},
%{id: 3, one: "seven", three: "eight"},
]
# find maps with these keys/values
find_by = %{id: 2, three: "six"}
# is there a nice/terse way to do this?
my_find_method(find_by, list_of_maps)
=> %{id: 2, one: "five", three: "six"}
# a filter may return a list
my_filter_method(find_by, list_of_maps)
=> [%{id: 2, one: "five", three: "six"}]