+ 3
What are streams?
I am kind of confused of that term...I hear it every now and then but have little knowledge of it.From what i know its like a small storage where data are stored before any operation...Am i correct ?
3 Antworten
+ 2
A stream is an object that you can ask for the next x elements.
If your stream is infinite, like the stream of all natural numbers, then you cannot store all of them in memory, because your memory is finite. But the natural numbers have a very simple rule: Start with 0; add +1 each time. So when I want the 50 naturals, the stream can deliver those.
So infinite streams require a clear rule to generate the next member.
A finite stream is like a list or an array. You can enumerate all the members. Or you use a generation rule that ends somehow.
That's why I said streams abstract over lists and generators.
+ 2
Sorry but don't know about lists.....and What are infinite streams then...?
+ 1
A stream is an abstraction over lists and generators. Lists you probably know. Generators produce results upon request, like a generator for all prime numbers.
So you can ask a stream for x results. Streams can be finite or infinite. The concept is thus very flexible.