title: Iterate through updating F# Map vs a C# Dictionary
body: <p>I have a collection of key/value pairs contained inside an F# Map</p>
  
  <pre><code>type node = {myFloat:float, data1:int; data2:int;}
  type nodesCollection = {metaData:int nodes:Map&lt;float,node&gt;}
  
  let results = processData (nodes:Map&lt;float,node&gt;)
  </code></pre>
  
  <p>The function processData returns a list of tuples  with the following signature</p>
  
  <pre><code>val results : (node * int * int * int * int) List
  </code></pre>
  
  <p>I would like to:</p>
  
  <ol>
  <li>Only work with the first item of the tuple (i.e. node)</li>
  <li>Iterate through either the key/value pairs in the Map or the list of nodes</li>
  <li>Replace the node values in the Map with those if the list in the key exist in both</li>
  <li>If the key doesn't exist in the Map added the node from the list to the Map</li>
  <li>Return the updated Map</li>
  </ol>
  
  <p>Ignoring the fact that the returned tuple needs to be parsed, I would do something like this in C# if I was using a <code>Dictionary&lt;float,node&gt;</code></p>
  
  <pre class="lang-cs prettyprint-override"><code>foreach newNode in nodesInList
  {
    if (nodesCollection.nodes.Contains(newNode.myfloat))
       nodesCollection.nodes[newNode.myfloat] = node
    else
       nodesCollection.nodes.Add(newNode.myfloat, node); 
  }
  
  return nodesCollection.nodes
  </code></pre>
  
  <p>How would I approach this using a Map and functional style?</p>