What Java 8 Stream.collect equivalents are available in the standard Kotlin library?
<p>In Java 8, there is <a href="https://docs.oracle.com/javase/tutorial/collections/streams/reduction.html#collect" rel="noreferrer"><code>Stream.collect</code></a> which allows aggregations on collections.  In Kotlin, this does not exist in the same way, other than maybe as a collection of extension functions in the stdlib.  But it isn't clear what the equivalences are for different use cases.  </p>

<p>For example, at the <a href="https://docs.oracle.com/javase/8/docs/api/java/util/stream/Collectors.html" rel="noreferrer">top of the JavaDoc for <code>Collectors</code></a> are examples written for Java 8, and when porting them to Kolin you can't use the Java 8 classes when on a different JDK version, so likely they should be written differently.  </p>

<p>In terms of resources online showing examples of Kotlin collections, they are typically trivial and don't really compare to the same use cases.  What are good examples that really match the cases such as documented for Java 8 <code>Stream.collect</code>?  The list there is:</p>

<ul>
<li>Accumulate names into a List</li>
<li>Accumulate names into a TreeSet</li>
<li>Convert elements to strings and concatenate them, separated by commas</li>
<li>Compute sum of salaries of employee</li>
<li>Group employees by department</li>
<li>Compute sum of salaries by department</li>
<li>Partition students into passing and failing</li>
</ul>

<p>With details in the JavaDoc linked above.</p>

<p><strong><em>Note:</em></strong> <em>this question is intentionally written and answered by the author (<a href="https://stackoverflow.blog/2011/07/01/its-ok-to-ask-and-answer-your-own-questions/">Self-Answered Questions</a>), so that the idiomatic answers to commonly asked Kotlin topics are present in SO. Also to clarify some really old answers written for alphas of Kotlin that are not accurate for current-day Kotlin.</em></p>