title: Efficient way to filter a Map by value in Elixir
body: <p>In Elixir, what would be an efficient way to filter a <code>Map</code> by its values.</p>
  
  <p>Right now I have the following solution</p>
  
  <pre><code>%{foo: "bar", biz: nil, baz: 4}
  |&gt; Enum.reject(fn {_, v} -&gt; is_nil(v) end)
  |&gt; Map.new
  </code></pre>
  
  <p>This solution seems pretty inefficient to me. When called on a <code>Map</code>, <code>Enum.reject/2</code> returns a <code>Keywords</code>. Since I want a <code>Map</code>, I need to call <code>Map.new/1</code> to convert that <code>Keywords</code> back to me.</p>
  
  <p>This seems inefficient because <code>Enum.reject/2</code> has to iterate over the <code>Map</code> once and then presumably, <code>Map.new/1</code> has to iterate over the <code>Keywords</code> another time.</p>
  
  <p>What would be a more efficient solution?</p>