mirror of
https://github.com/c-cube/iter.git
synced 2025-12-06 03:05:29 -05:00
add Sequence.pair_with_idx
This commit is contained in:
parent
11529ea6ff
commit
92205b6c36
2 changed files with 8 additions and 0 deletions
|
|
@ -971,6 +971,10 @@ let of_list l k = List.iter k l
|
|||
let on_list f l =
|
||||
to_list (f (of_list l))
|
||||
|
||||
let pair_with_idx seq k =
|
||||
let r = ref 0 in
|
||||
seq (fun x -> let n = !r in incr r; k (n,x))
|
||||
|
||||
let to_opt = head
|
||||
|
||||
let of_opt o k = match o with
|
||||
|
|
|
|||
|
|
@ -495,6 +495,10 @@ val on_list : ('a t -> 'b t) -> 'a list -> 'b list
|
|||
@since 0.5.2
|
||||
*)
|
||||
|
||||
val pair_with_idx : 'a t -> (int * 'a) t
|
||||
(** Similar to {!zip_i} but returns a normal sequence of tuples
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
val to_opt : 'a t -> 'a option
|
||||
(** Alias to {!head}
|
||||
@since 0.5.1 *)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue