title: How does aggregate generalise fold and fold generalise reduce?
body: <p>As far as I understand <code>aggregate</code> is a generalisation of <code>fold</code> which in turn is a generalisation of <code>reduce</code>.</p>
  
  <p>Similarily <code>combineByKey</code> is a generalisation of <code>aggregateByKey</code> which in turn is a generalisation of <code>foldByKey</code> which in turn is a generalisation of <code>reduceByKey</code>.</p>
  
  <p>However I have trouble finding simple examples for each of those seven methods which can in turn only be expressed by them and not their less general versions. For example I found <a href="http://blog.madhukaraphatak.com/spark-rdd-fold/" rel="nofollow noreferrer">http://blog.madhukaraphatak.com/spark-rdd-fold/</a> giving an example for <code>fold</code>, but I have been able to use <code>reduce</code> in the same situation as well.</p>
  
  <p>What I found out so far:</p>
  
  <ul>
  <li>I read that the more generalised methods can be more efficient, but that would be a non-functional requirement and I would like to get examples which can not be implemented with the more specific method.</li>
  <li>I also read that e.g. the function passed to <code>fold</code> only has to be associative, while the one for <code>reduce</code> has to be commutative additionally: <a href="https://stackoverflow.com/a/25158790/4533188">https://stackoverflow.com/a/25158790/4533188</a> (However, I still don't know any good simple example.) whereas in <a href="https://stackoverflow.com/a/26635928/4533188">https://stackoverflow.com/a/26635928/4533188</a> I read that fold needs both properties to hold...</li>
  <li>We could think of the zero value as a feature (e.g. for <code>fold</code> over <code>reduce</code>) as in "add all elements and add 3" and using 3 as the zero value, but that would be misleading, because 3 would be added for each partition, not just once. Also this is simply not the purpose of <code>fold</code> as far as I understood - it wasn't meant as a feature, but as a necessity to implement it to be able to take non-commutative functions.</li>
  </ul>
  
  <p>What would simple examples for those seven methods be?</p>