diff options
| author | Pierre-Marie Pédrot | 2014-07-03 17:45:06 +0200 |
|---|---|---|
| committer | Pierre-Marie Pédrot | 2014-07-03 17:45:06 +0200 |
| commit | c892f8cab37c0a89f6975e6a14bebad4d86156bd (patch) | |
| tree | c599bb1bafa4841b7a8ad539a83f4103413d4d10 /lib | |
| parent | b17fb013f1810106b8cd88a12a2df3f26dc7c289 (diff) | |
Adding a coiterator to IStream.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/iStream.ml | 6 | ||||
| -rw-r--r-- | lib/iStream.mli | 3 |
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/iStream.ml b/lib/iStream.ml index da54d9f7b8..36b9c43ad0 100644 --- a/lib/iStream.ml +++ b/lib/iStream.ml @@ -20,6 +20,12 @@ let cons x s = Lazy.lazy_from_val (Cons (x, s)) let thunk = Lazy.lazy_from_fun +let rec make_node f s = match f s with +| Nil -> Nil +| Cons (x, s) -> Cons (x, make f s) + +and make f s = lazy (make_node f s) + let rec force s = match Lazy.force s with | Nil -> () | Cons (_, s) -> force s diff --git a/lib/iStream.mli b/lib/iStream.mli index 61967f49e4..a059570107 100644 --- a/lib/iStream.mli +++ b/lib/iStream.mli @@ -31,6 +31,9 @@ val cons : 'a -> 'a t -> 'a t val thunk : (unit -> ('a,'a t) u) -> 'a t (** Internalize the lazyness of a stream. *) +val make : ('a -> ('b, 'a) u) -> 'a -> 'b t +(** Coiteration constructor. *) + (** {6 Destructors} *) val is_empty : 'a t -> bool |
