title: Elixir/Phoenix exit the loop
body: <p>I have two lists with maps:</p>
  
  <pre><code>apps = [%{name: "app1", version: "0.0.1"}, %{name: "app2", version: "0.0.1"}]
  updates_list = [%{name: "app1", version: "0.0.2"},
                  %{name: "app2", version: "0.0.1"},
                  %{name: "app3", version: "0.0.1"},
                  %{name: "app4", version: "0.0.1"}]
  </code></pre>
  
  <p>and need to enumerate through the <code>updates_list</code>, to put new key into each element in the <code>apps</code> list to show if there are updates. i.e. Here there is new version for <code>app1</code>, I need to add <code>new_version: true/false</code> and get the desired result:</p>
  
  <pre><code>result = [%{name: "app1", version: "0.0.1", new_version: true},
            %{name: "app2", version: "0.0.1", new_version: false}]
  </code></pre>
  
  <p>I have tried with the following function:</p>
  
  <pre><code>updates_map = Enum.map(updates_list, fn (x) -&gt; Map.put(%{}, x.name, x.version ) end)
  result = Enum.map(apps, fn (x) -&gt; map_updates(x, updates_map) end)
  </code></pre>
  
  <p>and function: </p>
  
  <pre><code>defp map_updates(app, updates_map) do
    app_map = Map.from_struct(app)
    for update &lt;- updates_map do
      if Map.has_key?(update, app_map.name) do
        if Map.fetch(update, app_map.name) != app_map.version do
          app_map = app_map |&gt; Map.put(:new_version, true)
        else
          app_map = app_map |&gt; Map.put(:new_version, false) 
        end
      else
        app_map = app_map
      end 
    end
    app_map
  end
  </code></pre>
  
  <p>But because it enumerates through all <code>updates_map</code> for every app, it just overrides it, and I get no result. How can exit the loop, or preserve the changes to achieve the <code>result</code> as above? Any advise appreciated! </p>