Create A Stream From An Array
There are functions in the Stream
module for turning a variety of data structures into streams -- lists, input channels, etc.
What if you have an array?
The Stream.from
function lets you define a function for custom fitting data structures into streams. Let's take a look:
The function takes the current index and needs to either return Some('a)
with the corresponding value or None
if the stream is empty.
With that, we now have a stream on which we can invoke any of the stream functions.
Last updated