title: foldLeft v. foldRight - does it matter?
body: <p>Previously, <a href="https://stackoverflow.com/users/1370349/nicolas-rinaudo">Nicolas Rinaudo</a> answered my question on Scala's <a href="https://stackoverflow.com/questions/19547976/list-foldright-always-using-foldleft">List foldRight Always Using foldLeft?</a></p>
  
  <p>Studying Haskell currently, my understanding is that <code>foldRight</code> should be preferred over <code>foldLeft</code> in cases where <code>::</code> (prepend) can be used over <code>++</code> (append). </p>
  
  <p>The reason, as I understand, is performance - the former occurs in <code>O(1)</code>, i.e. add an item to the front - constant time. Whereas the latter requires <code>O(N)</code>, i.e. go through the whole list and add an item.</p>
  
  <p>In Scala, given that <code>foldLeft</code> is implemented in terms of <code>foldRight</code>, does the benefit of using <code>:+</code> over <code>++</code> with <code>foldRight</code> even matter since <code>foldRight</code> gets reversed, and then <code>foldLeft'd</code>?</p>
  
  <p>As an example, consider this simple <code>fold..</code> operation for simply returning a list's elements in order.</p>
  
  <p><code>foldLeft</code> folds over each element, adding each item to the list via <code>:+</code>.</p>
  
  <pre><code>scala&gt; List("foo", "bar").foldLeft(List[String]()) { 
                                                      (acc, elem) =&gt; acc :+ elem }
  res9: List[String] = List(foo, bar)
  </code></pre>
  
  <p><code>foldRight</code> performs a foldLeft with <code>::</code> operator on each item, but then reverses.</p>
  
  <pre><code>scala&gt; List("foo", "bar").foldRight(List[String]()) { 
                                                      (elem, acc) =&gt; elem :: acc }
  res10: List[String] = List(foo, bar)
  </code></pre>
  
  <p>In reality, does it matter in Scala which <code>foldLeft</code> or <code>foldRight</code> to use given that <code>foldRight</code> uses <code>foldRight</code>?</p>