Definition of Stream'
and functions on streams #
A stream Stream' α
is an infinite sequence of elements of α
. One can also think about it as an
infinite list. In this file we define Stream'
and some functions that take and/or return streams.
Note that we already have Stream
to represent a similar object, hence the awkward naming.
Prepend an element to a stream.
Equations
Instances For
Prepend an element to a stream.
Equations
Instances For
Get the n
-th element of a stream.
Equations
Instances For
a ∈ s
means that a = Stream'.get n s
for some n
.
Equations
Iterates of a function as a stream.
Equations
Instances For
Given functions f : α → β
and g : α → α
, corec f g
creates a stream by:
- Starting with an initial value
a : α
- Applying
g
repeatedly to get a stream of α values - Applying
f
to each value to convert them to β
Equations
Instances For
Given a function f : α → β × α
, corec' f
creates a stream by repeatedly:
- Starting with an initial value
a : α
- Applying
f
to get both the next stream element (β) and next state value (α) This is a more convenient form when the next element and state are computed together.
Equations
Instances For
Use a state monad to generate a stream through corecursion
Equations
Instances For
Equations
Instances For
Interleave two streams.
Equations
Instances For
Elements of a stream with even indices.
Equations
Instances For
Elements of a stream with odd indices.
Equations
Instances For
Append a stream to a list.
Equations
Instances For
Given a stream of functions and a stream of values, apply n
-th function to n
-th value.