Streams in python

Since python supports closure, you don’t need all OOP verbosity to implement iterators/generators concept.
There is something called streams in functional programming which behave quite similarly.
Basically streams return tuple of two elements or pair.
Mostly first element is value and second element as thunk which when called will do the same for next value.
Here are few examples.

Leave a Reply

Your email address will not be published. Required fields are marked *