Will myList always be identical to Map.keys(myMap)? Or will they diverge?
Will Map.values(myMap) always be identical to a list of "no"? Or might there be other values?
In the following solution, I will assume, that myList and Map.keys(myMap) might be different, while the values all have to be "no".
intersection_of_keys = myList -- myOtherList
for {k, v} <- myMap, into: %{} do
if k in intersection_of_keys, do: {k, "yes"}, else: {k, "no"}
end
The reason why your original code did not work is, because the inner binding in the fn you pass to Enum.each/2 does not change the outer binding of myMap, always remember, elixir is immutable, it does only support shadowing, but shadowing does never leak its scope.






















