mirror of
https://github.com/c-cube/iter.git
synced 2025-12-06 03:05:29 -05:00
minor cleanup
This commit is contained in:
parent
0e0ca58c7e
commit
fda3ee02d1
2 changed files with 11 additions and 8 deletions
13
src/Iter.ml
13
src/Iter.ml
|
|
@ -33,9 +33,9 @@ let empty _ = ()
|
|||
(try iter (fun _ -> raise Exit) seq; true with Exit -> false);
|
||||
*)
|
||||
|
||||
let singleton x k = k x
|
||||
let return x k = k x
|
||||
let pure f k = k f
|
||||
let singleton = return
|
||||
let pure = return
|
||||
|
||||
let doubleton x y k = k x; k y
|
||||
|
||||
|
|
@ -168,7 +168,7 @@ let concat s k = s (fun s' -> s' k)
|
|||
|> OUnit.assert_equal 2000
|
||||
*)
|
||||
|
||||
let flatten s = concat s
|
||||
let flatten = concat
|
||||
|
||||
let flat_map f seq k = seq (fun x -> f x k)
|
||||
|
||||
|
|
@ -196,7 +196,8 @@ let seq_list l = seq_list_map (fun x->x) l
|
|||
*)
|
||||
|
||||
let filter_map f seq k =
|
||||
seq (fun x -> match f x with
|
||||
seq
|
||||
(fun x -> match f x with
|
||||
| None -> ()
|
||||
| Some y -> k y)
|
||||
|
||||
|
|
@ -222,7 +223,9 @@ let filter_count f seq =
|
|||
|
||||
let intersperse elem seq k =
|
||||
let first = ref true in
|
||||
seq (fun x -> (if !first then first := false else k elem); k x)
|
||||
seq (fun x ->
|
||||
if !first then first := false else k elem;
|
||||
k x)
|
||||
|
||||
(*$R
|
||||
(1 -- 100)
|
||||
|
|
|
|||
|
|
@ -134,9 +134,9 @@ val mapi : (int -> 'a -> 'b) -> 'a t -> 'b t
|
|||
(** Map objects, along with their index in the iterator *)
|
||||
|
||||
val map_by_2 : ('a -> 'a -> 'a) -> 'a t -> 'a t
|
||||
(** Map objects two by two. lazily.
|
||||
The last element is kept in the iterator if the count is odd.
|
||||
@since 0.7 *)
|
||||
(** Map objects two by two. lazily.
|
||||
The last element is kept in the iterator if the count is odd.
|
||||
@since 0.7 *)
|
||||
|
||||
val for_all : ('a -> bool) -> 'a t -> bool
|
||||
(** Do all elements satisfy the predicate? *)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue