Preface_stdlib.StreamImplementation for Stream.t.
A Stream.t is an infinite lazy list.
module Functor : Preface_specs.FUNCTOR with type 'a t = 'a tmodule Applicative : Preface_specs.APPLICATIVE with type 'a t = 'a tmodule Monad : Preface_specs.MONAD with type 'a t = 'a tmodule Comonad : Preface_specs.COMONAD with type 'a t = 'a tmodule Invariant : Preface_specs.INVARIANT with type 'a t = 'a tAdditional functions to facilitate practical work with Stream.t.
val pure : 'a -> 'a tCreate a value from 'a to 'a t.
val hd : 'a t -> 'aGet the head of the stream. Since Stream.t are infinite, hd can not fail (without values). For each stream, we have an head.
Get the tail of the stream. Like hd, since Stream.t are infinite, the function can not fail. For each stream, we have a tail.
Get the value at given position. at 10 (naturals) gives Ok 9. The function may fail if the position if negative.
drop n stream drop the nth values of the stream. The function may fail if the position if negative.
take n stream returns the firsts n elements of stream as list.
val take_while : ('a -> bool) -> 'a t -> 'a listtake_while p stream returns all first elements of stream as list satisfying the predicate p. Be careful, the function may diverge if every element of the stream are satisfying the predicate p.
drop_while p stream drop all first elements of stream satisfying the predicate p. Be careful, the function may diverge if every element of the stream are satisfying the predicate p.
module Infix : sig ... end