Top Qs
Timeline
Chat
Perspective

Stream (abstract data type)

Potentially infinite analog of a list, in type theory and functional programming From Wikipedia, the free encyclopedia

Remove ads
Remove ads

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 α)

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.

Thumb
UML package diagram of the stream hierarchy in .NET

Java provides the Stream interface under the java.util.stream namespace.

JavaScript provides the ReadableStream, WritableStream and TransformStream interfaces.[3]

Python have the StreamReader and StreamWriter classes in the asyncio module.[4]

.NET provides the abstract class Stream[5] which is implemented by classes such as FileStream and MemoryStream.[6]

In Rust a struct can implement the Read trait.[7] There is also the Cursor struct wraps an in-memory buffer.[8]

Remove ads

See also

References

Loading content...
Loading related searches...

Wikiwand - on

Seamless Wikipedia browsing. On steroids.

Remove ads