title: Elixir check if map contains a list of keys
body: <p><code>required_keys = [ "a", "b", "c" ]</code></p>
  
  <p><code>map_to_check = %{ "x" =&gt; "foo", "y" =&gt; "bar", "z" =&gt; "baz" }</code></p>
  
  <p>Given the above required_keys list, and the map_to_check map, how can I easily test if map_to_check contains ALL the keys found in required_keys list in Elixir? </p>
  
  <p>I know I can use <code>Map.has_key?(map_to_check, "a")</code> check if one value exist. </p>
  
  <p>And trying to iterate over the required_keys gave me an error because I was using Enum.map like so: </p>
  
  <pre><code>Enum.map(required_keys, fn k -&gt; Map.has_key?(Map.keys(map_to_check), k) end)
  </code></pre>
  
  <p>The above didn't work because Enum.map does not iterate over lists. </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>From looking at the answers, I've noticed that the reason my solution didn't work wasn't because Enum.map couldn't iterate lists, but rather due to the fact that I was passing in a list to <code>Map.has_key?</code> function by calling <code>Map.keys(map_to_check)</code></p>
  
  <p>So the following alternative should also work:</p>
  
  <pre><code>Enum.map(required_keys, fn k -&gt; Map.has_key?(map_to_check, k) end)
  </code></pre>