Stream (abstract data type)
From Wikipedia, the free encyclopedia
For the more applied concept in computing, see Stream (computing).
In type theory and functional programming, a stream is a potentially infinite analog of a list, given by the coinductive definition:[1][2]
data Stream α = Nil | Cons α (Stream α)
This article needs additional citations for verification. (February 2020) |
Generating and computing with streams requires lazy evaluation, either implicitly in a lazily evaluated language or by creating and forcing thunks in an eager language. In total languages they must be defined as codata and can be iterated over using (guarded) corecursion.