title: Empty Map Pattern matches even for non-empty Map
body: <p>The problem I am trying to solve states</p>
  
  <blockquote>
    <p>Write a function map_search_pred(Map, Pred) that returns the first
    element {Key,Value} in the map for which Pred(Key, Value) is true.</p>
  </blockquote>
  
  <p>My attempt looks like  </p>
  
  <pre><code>map_search_pred(#{}, _)     -&gt; {};
  map_search_pred(Map, Pred)  -&gt;
    [H|_] = [{Key, Value} || {Key, Value} &lt;- maps:to_list(Map), Pred(Key, Value) =:= true],
    H.
  </code></pre>
  
  <p>When I run this, I see output as  </p>
  
  <pre><code>1&gt; lib_misc:map_search_pred(#{1 =&gt; 1, 2 =&gt; 3}, fun(X, Y) -&gt; X =:= Y end).
  {}
  2&gt; lib_misc:map_search_pred(#{1 =&gt; 1, 2 =&gt; 3}, fun(X, Y) -&gt; X =:= Y end).
  {}
  3&gt; maps:size(#{}).
  0
  4&gt; 
  </code></pre>
  
  <p><strong>How am I so sure?</strong> 
  I pulled out the first clause so it looks like  </p>
  
  <pre><code>map_search_pred(Map, Pred)  -&gt;
    [H|_] = [{Key, Value} || {Key, Value} &lt;- maps:to_list(Map), Pred(Key, Value) =:= true],
    H.
  </code></pre>
  
  <p>and run again</p>
  
  <pre><code>1&gt; lib_misc:map_search_pred(#{1 =&gt; 1, 2 =&gt; 3}, fun(X, Y) -&gt; X =:= Y end).
  {1,1}
  2&gt; lib_misc:map_search_pred(#{}, fun(X, Y) -&gt; X =:= Y end).
  ** exception error: no match of right hand side value []
       in function  lib_misc:map_search_pred/2 (/Users/harith/code/IdeaProjects/others/erlang/programmingErlang/src/lib_misc.erl, line 42)
  3&gt;
  </code></pre>