Fusing Transformations of Strict Scala Collections with Views

http://fpilluminated.com/assets/fusing-transformations-of-strict-scala-collections-with-views.html

4 Likes

Wow… this clarifies so much for me… thanks.

1 Like

Wow, best feedback I could hope for - thank you!

Not only do I understand Scala collections better, but I understand Java Streams better. Converting a Java Collection to a Stream is the same as converting a Scala Collection to a view with .view, and terminating a Stream with a Collector is the same as Scala .to

IMHO, both Java Streams and Scala Views were poorly explained in the past, never getting to the essence of this fine presentation.

It would be interesting to hear your views (no pun intended) on Teaching old Streams new tricks By Viktor Klang

1 Like

Haha yeah, I learned about .view completely by accident due to a deprecation message when using the .mapValues method.

As an aside, there are some other “fusings” without view. For example, there is the common .groupBy(???).mapValues(???).reduce(???) chain, which can be fused with groupMapReduce(???) which is built-in, and similarly .groupBy(???).mapValues(???) can be fused with .groupMap(???).

2 Likes

Thank you very much for your feedback, and thank you for the link to that presentation, I look forward to watching it.

Let’s see if the new Java Streams tricks will see impurepics updating the drawing for the letter J in his FP alphabet book.

The last time I used Java streams I had a go implementing quicksort and comparing the result with that in other languages.