title: Difference between fold and foldLeft or foldRight?
body: <p>NOTE: I am on Scala 2.8—can that be a problem?</p>
  
  <p>Why can't I use the <code>fold</code> function the same way as <code>foldLeft</code> or <code>foldRight</code>?</p>
  
  <p>In the <a href="http://www.scala-lang.org/api/current/scala/collection/immutable/Set.html">Set scaladoc</a> it says that:</p>
  
  <blockquote>
    <p>The result of folding may only be a supertype of this parallel collection's type parameter <code>T</code>.</p>
  </blockquote>
  
  <p>But I see no type parameter <code>T</code> in the function signature:</p>
  
  <pre><code>def fold [A1 &gt;: A] (z: A1)(op: (A1, A1) ⇒ A1): A1
  </code></pre>
  
  <p>What is the difference between the <code>foldLeft-Right</code> and <code>fold</code>, and how do I use the latter?</p>
  
  <p>EDIT: For example how would I write a fold to add all elements in a list? With <code>foldLeft</code> it would be:</p>
  
  <pre><code>val foo = List(1, 2, 3)
  foo.foldLeft(0)(_ + _)
  
  // now try fold:
  foo.fold(0)(_ + _)
  &gt;:7: error: value fold is not a member of List[Int]
    foo.fold(0)(_ + _)
      ^
  </code></pre>