title: Pushing a series of Scala map operations into a separate list
body: <p>Was tinkering about translating a Java module into Scala and thought this would be a good learning exercise on Maps/Placeholders... Is there a way to translate the essence of this code block into single (map?) statement? (This is what I've come up with so far for a Scala-ized version)<br></p>
  
  <pre><code>dataProcList foreach (processor =&gt; { // #1
    val fieldName: String = processor.getWriteColumn // #2
    val sqlValue: String = processor.getSqlValue(hashMapOfFieldValuePairs.get(fieldName)) // #3
    sqlColumnValuePair += ((fieldName, sqlValue)) // #4
  })
  </code></pre>
  
  <p>In short:</p>
  
  <ol>
  <li>A list of DataProcessor(s) is iterated</li>
  <li>From each DP, a string is extracted (call it "Alpha")</li>
  <li>Alphpa is used as the look-up key to a (externally defined) HashMap, which gets/returns a SQL-prep'd value (call it "Zed")</li>
  <li>Alpha and Zed are then paired and appended to their own List/Hash/Set/Whatever (called "sqlColumnValuePair")</li>
  </ol>
  
  <p>Those lines have been expanded for readability; and portions could be distilled down using various map-ings (for example 1 &amp; 2), but is there a way to do it in using a single statment? It feels like I <em>should</em> be able to condense it down that far...but I don't have enough Scala experience with Map-ings/placeholders to know if it is a fruitless endeavor, or not.</p>
  
  <p>TIA.</p>
  
  <p>(NOTE: I found the answer from this post to be a pretty educational summary on Scala's Map operations: <a href="https://stackoverflow.com/questions/2293592/functional-programming-scala-map-and-fold-left">Functional programming, Scala map and fold left</a>)</p>
  
  <p>EDIT: I removed a .getOrElse() operation from the original example, as I think it was just a distraction to the core problem.</p>
  
  <p>EDIT 2: After some consideration, maybe a better way to phrase my learning objective here would be: "How to duplicate this functionality using the fewest number of operations." (Which I had assumed would be some combination of map operations, partial functions, and so forth.) And in doing so, hopefully gain a broader understanding of the set of Scala classes/operators that can be used in similar situations.</p>