mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
add a few functions to CCPersistentArray
This commit is contained in:
parent
d0c270504a
commit
c71595f691
2 changed files with 16 additions and 0 deletions
|
|
@ -80,3 +80,13 @@ let of_array a = init (Array.length a) (fun i -> a.(i))
|
||||||
let to_list t = Array.to_list (reroot t)
|
let to_list t = Array.to_list (reroot t)
|
||||||
let of_list l = ref (Array (Array.of_list l))
|
let of_list l = ref (Array (Array.of_list l))
|
||||||
|
|
||||||
|
type 'a sequence = ('a -> unit) -> unit
|
||||||
|
|
||||||
|
let to_seq a yield = iter yield a
|
||||||
|
|
||||||
|
let of_seq seq =
|
||||||
|
let l = ref [] in
|
||||||
|
seq (fun x -> l := x :: !l);
|
||||||
|
of_list (List.rev !l)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,4 +96,10 @@ val to_list : 'a t -> 'a list
|
||||||
val of_list : 'a list -> 'a t
|
val of_list : 'a list -> 'a t
|
||||||
(** [of_list l] returns a fresh persistent array containing the elements of [l]. *)
|
(** [of_list l] returns a fresh persistent array containing the elements of [l]. *)
|
||||||
|
|
||||||
|
type 'a sequence = ('a -> unit) -> unit
|
||||||
|
|
||||||
|
val to_seq : 'a t -> 'a sequence
|
||||||
|
|
||||||
|
val of_seq : 'a sequence -> 'a t
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue