mirror of
https://github.com/c-cube/iter.git
synced 2025-12-06 03:05:29 -05:00
apparently drup doesn't like polymorphic variants
This commit is contained in:
parent
6ff605ac04
commit
3d61de614e
1 changed files with 7 additions and 5 deletions
12
sequence.ml
12
sequence.ml
|
|
@ -243,17 +243,19 @@ let persistent seq =
|
|||
let l = MList.of_seq seq in
|
||||
MList.to_seq l
|
||||
|
||||
type 'a lazy_seq = [`Suspend | `Cached of 'a t] ref
|
||||
type 'a lazy_state =
|
||||
| LazySuspend
|
||||
| LazyCached of 'a t
|
||||
|
||||
let persistent_lazy (seq:'a t) =
|
||||
let (r:'a lazy_seq) = ref `Suspend in
|
||||
let r = ref LazySuspend in
|
||||
fun k ->
|
||||
match !r with
|
||||
| `Cached seq' -> seq' k
|
||||
| `Suspend ->
|
||||
| LazyCached seq' -> seq' k
|
||||
| LazySuspend ->
|
||||
(* here if this traversal is interruted, no caching occurs *)
|
||||
let seq' = MList.of_seq_with seq k in
|
||||
r := `Cached (MList.to_seq seq')
|
||||
r := LazyCached (MList.to_seq seq')
|
||||
|
||||
(** Sort the sequence. Eager, O(n) ram and O(n ln(n)) time. *)
|
||||
let sort ?(cmp=Pervasives.compare) seq =
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue