Nested comprehensions in Elixir
<p>In Python, one can do this <code>[e2 for e1 in edits1(word) for e2 in edits1(e1)]</code>. What is the equivalent (and right) form of this construct in Elixir?</p>

<p>What I tried, is:</p>

<pre><code>def edits2(word) do
  (for e1 &lt;- edits1(word), do: edits1(e1))
  |&gt; Enum.reduce(MapSet.new, fn(item, acc) -&gt; MapSet.union(item, acc) end)
end
</code></pre>

<p>but this is awfully slow, since it happens I need to do a MapSet of hundreds of lists, each containing 500+ elements.</p>