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.
Instances For
Get the n-th element of a stream.
Instances For
Tail of a stream: Stream'.tail (h :: t) = t.
Instances For
a ∈ s means that a = Stream'.get n s for some n.
The constant stream: Stream'.get n (Stream'.const a) = a.
Instances For
Iterates of a function as a stream.
Instances For
Given a function f : α → β × α, corec' f creates a stream by repeatedly:
- Starting with an initial value
a : α - Applying
fto 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.
Instances For
Use a state monad to generate a stream through corecursion
Instances For
Instances For
Interleave two streams.
Instances For
Elements of a stream with even indices.
Instances For
Elements of a stream with odd indices.
Instances For
An auxiliary definition for Stream'.cycle corecursive def
Instances For
Tails of a stream, starting with Stream'.tail s.
Instances For
An auxiliary definition for Stream'.inits.
Instances For
A constant stream, same as Stream'.const.
Instances For
Given a stream of functions and a stream of values, apply n-th function to n-th value.
Instances For
The stream of natural numbers: Stream'.get n Stream'.nats = n.