FWIW, the reduce seems perfectly clear to me, absolutely out of context. It’s a common pattern for dictionary iteration/building. As I understand it you’re trying to do two things in the reduce:

- consolidate duplicate keys, favoring order of insertion but preferring truthy values
- convert a ListDict to a HashDict

HashDict.new accepts ListDicts and a transformation function and the Keyword module has utilities for handling ListDicts with duplicate keys, but scanning through their docs I don’t think there’s anyway you could use them to get the same behaviour while only iterating over the collection once.

As for the permutation stuff, I’d use list comprehensions:

results = lc filter inlist Dict.keys(filters), tag inlist Dict.keys(tags), do: evaluate_filter(filter, tag)  

--  
Christopher Keele
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


On Monday, December 16, 2013 at 1:54 PM, Patrick Van Stee wrote:

> In lib/ex_unit/lib/ex_unit/runner.ex:
> > + Enum.map filters, fn filter -> > + { { elem(filter, 0), elem(tag, 0) }, evaluate_filter(filter, tag) } > + end > + end > + > + results = Enum.reduce results, HashDict.new, fn { key, evaluation }, dict -> > + Dict.update dict, key, evaluation, &(evaluation || &1) > + end > + > + mismatch = Enum.find Dict.to_list(results), &match?({ _, false }, &1) > + > + case mismatch do > + { { _, tag }, _ } -> { :error, tag } > + _ -> :ok > + end > + end  
> Any thoughts on how to improve this? The permutation part at the beginning and the reduce might be a little hard to follow.
>  
> —
> Reply to this email directly or view it on GitHub (https://github.com/elixir-lang/elixir/pull/1909/files#r8379268).
>  
>  
>