In this chapter, we'll discuss higher-order functions for collections. For Java developers, they first appeared in Java 8 with the introduction of Stream API. But they were around for much longer in functional languages.
First, since we expect that many of our readers are familiar with Java 8, let's cover what Stream API is in Java briefly.
Streams from Java8 are not to be confused with some of the I/O classes with similar names, such as InputStream or OutputStream. While the latter represent data, the former are sequences of elements of the same type.
If those are sequences, and they all have the same type, how are they different from Lists? Well, streams can be infinite, unlike collections.
There is also a set of actions defined for Java streams. Not only are those actions the same for any kind of stream, they also have familiar names for those...