mirror of
https://github.com/c-cube/iter.git
synced 2025-12-06 19:25:30 -05:00
update sequenceLabels.mli
This commit is contained in:
parent
b3fdd356ca
commit
b24ebfb405
1 changed files with 41 additions and 21 deletions
|
|
@ -118,14 +118,16 @@ val exists : f:('a -> bool) -> 'a t -> bool
|
||||||
|
|
||||||
val mem : ?eq:('a -> 'a -> bool) -> x:'a -> 'a t -> bool
|
val mem : ?eq:('a -> 'a -> bool) -> x:'a -> 'a t -> bool
|
||||||
(** Is the value a member of the sequence?
|
(** Is the value a member of the sequence?
|
||||||
@param eq the equality predicate to use (default [(=)]) *)
|
@param eq the equality predicate to use (default [(=)])
|
||||||
|
@since 0.5 *)
|
||||||
|
|
||||||
val find : f:('a -> 'b option) -> 'a t -> 'b option
|
val find : ('a -> 'b option) -> 'a t -> 'b option
|
||||||
(** Find the first element on which the function doesn't return [None] *)
|
(** Find the first element on which the function doesn't return [None]
|
||||||
|
@since 0.5 *)
|
||||||
|
|
||||||
val find_map : f:('a -> 'b option) -> 'a t -> 'b option
|
val find_map : f:('a -> 'b option) -> 'a t -> 'b option
|
||||||
(** Alias to {!find}
|
(** Alias to {!find}
|
||||||
@since NEXT_RELEASE *)
|
@since 0.10 *)
|
||||||
|
|
||||||
val findi : f:(int -> 'a -> 'b option) -> 'a t -> 'b option
|
val findi : f:(int -> 'a -> 'b option) -> 'a t -> 'b option
|
||||||
(** Indexed version of {!find}
|
(** Indexed version of {!find}
|
||||||
|
|
@ -133,7 +135,7 @@ val findi : f:(int -> 'a -> 'b option) -> 'a t -> 'b option
|
||||||
|
|
||||||
val find_mapi : f:(int -> 'a -> 'b option) -> 'a t -> 'b option
|
val find_mapi : f:(int -> 'a -> 'b option) -> 'a t -> 'b option
|
||||||
(** Alias to {!findi}
|
(** Alias to {!findi}
|
||||||
@since NEXT_RELEASE *)
|
@since 0.10 *)
|
||||||
|
|
||||||
val find_pred : f:('a -> bool) -> 'a t -> 'a option
|
val find_pred : f:('a -> bool) -> 'a t -> 'a option
|
||||||
(** [find_pred p l] finds the first element of [l] that satisfies [p],
|
(** [find_pred p l] finds the first element of [l] that satisfies [p],
|
||||||
|
|
@ -160,6 +162,11 @@ val append : 'a t -> 'a t -> 'a t
|
||||||
(** Append two sequences. Iterating on the result is like iterating
|
(** Append two sequences. Iterating on the result is like iterating
|
||||||
on the first, then on the second. *)
|
on the first, then on the second. *)
|
||||||
|
|
||||||
|
val append_l : 'a t list -> 'a t
|
||||||
|
(** Append sequences. Iterating on the result is like iterating
|
||||||
|
on the each sequence of the list in order.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val concat : 'a t t -> 'a t
|
val concat : 'a t t -> 'a t
|
||||||
(** Concatenate a sequence of sequences into one sequence. *)
|
(** Concatenate a sequence of sequences into one sequence. *)
|
||||||
|
|
||||||
|
|
@ -235,6 +242,7 @@ val group_by : ?hash:('a -> int) -> ?eq:('a -> 'a -> bool) ->
|
||||||
'a t -> 'a list t
|
'a t -> 'a list t
|
||||||
(** Group equal elements, disregarding their order of appearance.
|
(** Group equal elements, disregarding their order of appearance.
|
||||||
The result sequence is traversable as many times as required.
|
The result sequence is traversable as many times as required.
|
||||||
|
precondition: for any [x] and [y], if [eq x y] then [hash x=hash y] must hold.
|
||||||
@since 0.6 *)
|
@since 0.6 *)
|
||||||
|
|
||||||
val count : ?hash:('a -> int) -> ?eq:('a -> 'a -> bool) ->
|
val count : ?hash:('a -> int) -> ?eq:('a -> 'a -> bool) ->
|
||||||
|
|
@ -264,7 +272,8 @@ val diagonal : 'a t -> ('a * 'a) t
|
||||||
@since 0.9 *)
|
@since 0.9 *)
|
||||||
|
|
||||||
val product2 : 'a t -> 'b t -> ('a, 'b) t2
|
val product2 : 'a t -> 'b t -> ('a, 'b) t2
|
||||||
(** Binary version of {!product}. Same requirements. *)
|
(** Binary version of {!product}. Same requirements.
|
||||||
|
@since 0.5 *)
|
||||||
|
|
||||||
val join : join_row:('a -> 'b -> 'c option) -> 'a t -> 'b t -> 'c t
|
val join : join_row:('a -> 'b -> 'c option) -> 'a t -> 'b t -> 'c t
|
||||||
(** [join ~join_row a b] combines every element of [a] with every
|
(** [join ~join_row a b] combines every element of [a] with every
|
||||||
|
|
@ -284,7 +293,8 @@ val join_by : ?eq:'key equal -> ?hash:'key hash ->
|
||||||
values [(x,y)] from [(a,b)] with the same [key]
|
values [(x,y)] from [(a,b)] with the same [key]
|
||||||
using [merge]. If [merge] returns [None], the combination
|
using [merge]. If [merge] returns [None], the combination
|
||||||
of values is discarded.
|
of values is discarded.
|
||||||
@since NEXT_RELEASE *)
|
precondition: for any [x] and [y], if [eq x y] then [hash x=hash y] must hold.
|
||||||
|
@since 0.10 *)
|
||||||
|
|
||||||
val join_all_by : ?eq:'key equal -> ?hash:'key hash ->
|
val join_all_by : ?eq:'key equal -> ?hash:'key hash ->
|
||||||
('a -> 'key) -> ('b -> 'key) ->
|
('a -> 'key) -> ('b -> 'key) ->
|
||||||
|
|
@ -301,7 +311,7 @@ val join_all_by : ?eq:'key equal -> ?hash:'key hash ->
|
||||||
- call [merge k l1 l2]. If [merge] returns [None], the combination
|
- call [merge k l1 l2]. If [merge] returns [None], the combination
|
||||||
of values is discarded, otherwise it returns [Some c]
|
of values is discarded, otherwise it returns [Some c]
|
||||||
and [c] is inserted in the result.
|
and [c] is inserted in the result.
|
||||||
@since NEXT_RELEASE *)
|
@since 0.10 *)
|
||||||
|
|
||||||
val group_join_by : ?eq:'a equal -> ?hash:'a hash ->
|
val group_join_by : ?eq:'a equal -> ?hash:'a hash ->
|
||||||
('b -> 'a) ->
|
('b -> 'a) ->
|
||||||
|
|
@ -313,14 +323,16 @@ val group_join_by : ?eq:'a equal -> ?hash:'a hash ->
|
||||||
sequence such that [eq x (key y)]. Elements of the first
|
sequence such that [eq x (key y)]. Elements of the first
|
||||||
sequences without corresponding values in the second one
|
sequences without corresponding values in the second one
|
||||||
are mapped to [[]]
|
are mapped to [[]]
|
||||||
@since NEXT_RELEASE *)
|
precondition: for any [x] and [y], if [eq x y] then [hash x=hash y] must hold.
|
||||||
|
@since 0.10 *)
|
||||||
|
|
||||||
val inter :
|
val inter :
|
||||||
?eq:'a equal -> ?hash:'a hash ->
|
?eq:'a equal -> ?hash:'a hash ->
|
||||||
'a t -> 'a t -> 'a t
|
'a t -> 'a t -> 'a t
|
||||||
(** Intersection of two collections. Each element will occur at most once
|
(** Intersection of two collections. Each element will occur at most once
|
||||||
in the result. Eager.
|
in the result. Eager.
|
||||||
@since NEXT_RELEASE *)
|
precondition: for any [x] and [y], if [eq x y] then [hash x=hash y] must hold.
|
||||||
|
@since 0.10 *)
|
||||||
|
|
||||||
(*$=
|
(*$=
|
||||||
[2;4;5;6] (inter (1--6) (cons 2 (4--10)) |> sort |> to_list)
|
[2;4;5;6] (inter (1--6) (cons 2 (4--10)) |> sort |> to_list)
|
||||||
|
|
@ -332,7 +344,8 @@ val union :
|
||||||
'a t -> 'a t -> 'a t
|
'a t -> 'a t -> 'a t
|
||||||
(** Union of two collections. Each element will occur at most once
|
(** Union of two collections. Each element will occur at most once
|
||||||
in the result. Eager.
|
in the result. Eager.
|
||||||
@since NEXT_RELEASE *)
|
precondition: for any [x] and [y], if [eq x y] then [hash x=hash y] must hold.
|
||||||
|
@since 0.10 *)
|
||||||
|
|
||||||
(*$=
|
(*$=
|
||||||
[2;4;5;6] (union (4--6) (cons 2 (4--5)) |> sort |> to_list)
|
[2;4;5;6] (union (4--6) (cons 2 (4--5)) |> sort |> to_list)
|
||||||
|
|
@ -342,7 +355,7 @@ val diff :
|
||||||
?eq:'a equal -> ?hash:'a hash ->
|
?eq:'a equal -> ?hash:'a hash ->
|
||||||
'a t -> 'a t -> 'a t
|
'a t -> 'a t -> 'a t
|
||||||
(** Set difference. Eager.
|
(** Set difference. Eager.
|
||||||
@since NEXT_RELEASE *)
|
@since 0.10 *)
|
||||||
|
|
||||||
(*$=
|
(*$=
|
||||||
[1;2;8;9;10] (diff (1--10) (3--7) |> to_list)
|
[1;2;8;9;10] (diff (1--10) (3--7) |> to_list)
|
||||||
|
|
@ -352,7 +365,8 @@ val subset :
|
||||||
?eq:'a equal -> ?hash:'a hash ->
|
?eq:'a equal -> ?hash:'a hash ->
|
||||||
'a t -> 'a t -> bool
|
'a t -> 'a t -> bool
|
||||||
(** [subset a b] returns [true] if all elements of [a] belong to [b]. Eager.
|
(** [subset a b] returns [true] if all elements of [a] belong to [b]. Eager.
|
||||||
@since NEXT_RELEASE *)
|
precondition: for any [x] and [y], if [eq x y] then [hash x=hash y] must hold.
|
||||||
|
@since 0.10 *)
|
||||||
|
|
||||||
(*$T
|
(*$T
|
||||||
subset (2 -- 4) (1 -- 4)
|
subset (2 -- 4) (1 -- 4)
|
||||||
|
|
@ -375,7 +389,7 @@ val max : ?lt:('a -> 'a -> bool) -> 'a t -> 'a option
|
||||||
val max_exn : ?lt:('a -> 'a -> bool) -> 'a t -> 'a
|
val max_exn : ?lt:('a -> 'a -> bool) -> 'a t -> 'a
|
||||||
(** Unsafe version of {!max}
|
(** Unsafe version of {!max}
|
||||||
@raise Not_found if the sequence is empty
|
@raise Not_found if the sequence is empty
|
||||||
@since NEXT_RELEASE *)
|
@since 0.10 *)
|
||||||
|
|
||||||
val min : ?lt:('a -> 'a -> bool) -> 'a t -> 'a option
|
val min : ?lt:('a -> 'a -> bool) -> 'a t -> 'a option
|
||||||
(** Min element of the sequence, using the given comparison function.
|
(** Min element of the sequence, using the given comparison function.
|
||||||
|
|
@ -384,7 +398,7 @@ val min : ?lt:('a -> 'a -> bool) -> 'a t -> 'a option
|
||||||
val min_exn : ?lt:('a -> 'a -> bool) -> 'a t -> 'a
|
val min_exn : ?lt:('a -> 'a -> bool) -> 'a t -> 'a
|
||||||
(** Unsafe version of {!min}
|
(** Unsafe version of {!min}
|
||||||
@raise Not_found if the sequence is empty
|
@raise Not_found if the sequence is empty
|
||||||
@since NEXT_RELEASE *)
|
@since 0.10 *)
|
||||||
|
|
||||||
val sum : int t -> int
|
val sum : int t -> int
|
||||||
(** Sum of elements
|
(** Sum of elements
|
||||||
|
|
@ -395,11 +409,13 @@ val sumf : float t -> float
|
||||||
@since NEXT_RELEASE *)
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val head : 'a t -> 'a option
|
val head : 'a t -> 'a option
|
||||||
(** First element, if any, otherwise [None] *)
|
(** First element, if any, otherwise [None]
|
||||||
|
@since 0.5.1 *)
|
||||||
|
|
||||||
val head_exn : 'a t -> 'a
|
val head_exn : 'a t -> 'a
|
||||||
(** First element, if any, fails
|
(** First element, if any, fails
|
||||||
@raise Invalid_argument if the sequence is empty *)
|
@raise Invalid_argument if the sequence is empty
|
||||||
|
@since 0.5.1 *)
|
||||||
|
|
||||||
val take : int -> 'a t -> 'a t
|
val take : int -> 'a t -> 'a t
|
||||||
(** Take at most [n] elements from the sequence. Works on infinite
|
(** Take at most [n] elements from the sequence. Works on infinite
|
||||||
|
|
@ -412,7 +428,8 @@ val take_while : f:('a -> bool) -> 'a t -> 'a t
|
||||||
|
|
||||||
val fold_while : f:('a -> 'b -> 'a * [`Stop | `Continue]) -> init:'a -> 'b t -> 'a
|
val fold_while : f:('a -> 'b -> 'a * [`Stop | `Continue]) -> init:'a -> 'b t -> 'a
|
||||||
(** Folds over elements of the sequence, stopping early if the accumulator
|
(** Folds over elements of the sequence, stopping early if the accumulator
|
||||||
returns [('a, `Stop)] *)
|
returns [('a, `Stop)]
|
||||||
|
@since 0.5.5 *)
|
||||||
|
|
||||||
val drop : int -> 'a t -> 'a t
|
val drop : int -> 'a t -> 'a t
|
||||||
(** Drop the [n] first elements of the sequence. Lazy. *)
|
(** Drop the [n] first elements of the sequence. Lazy. *)
|
||||||
|
|
@ -471,7 +488,8 @@ val pair_with_idx : 'a t -> (int * 'a) t
|
||||||
@since NEXT_RELEASE *)
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val to_opt : 'a t -> 'a option
|
val to_opt : 'a t -> 'a option
|
||||||
(** Alias to {!head} *)
|
(** Alias to {!head}
|
||||||
|
@since 0.5.1 *)
|
||||||
|
|
||||||
val to_array : 'a t -> 'a array
|
val to_array : 'a t -> 'a array
|
||||||
(** Convert to an array. Currently not very efficient because
|
(** Convert to an array. Currently not very efficient because
|
||||||
|
|
@ -489,7 +507,8 @@ val array_slice : 'a array -> int -> int -> 'a t
|
||||||
from [i] to [j] *)
|
from [i] to [j] *)
|
||||||
|
|
||||||
val of_opt : 'a option -> 'a t
|
val of_opt : 'a option -> 'a t
|
||||||
(** Iterate on 0 or 1 values. *)
|
(** Iterate on 0 or 1 values.
|
||||||
|
@since 0.5.1 *)
|
||||||
|
|
||||||
val of_stream : 'a Stream.t -> 'a t
|
val of_stream : 'a Stream.t -> 'a t
|
||||||
(** Sequence of elements of a stream (usable only once) *)
|
(** Sequence of elements of a stream (usable only once) *)
|
||||||
|
|
@ -537,7 +556,8 @@ val to_str : char t -> string
|
||||||
|
|
||||||
val concat_str : string t -> string
|
val concat_str : string t -> string
|
||||||
(** Concatenate strings together, eagerly.
|
(** Concatenate strings together, eagerly.
|
||||||
Also see {!intersperse} to add a separator. *)
|
Also see {!intersperse} to add a separator.
|
||||||
|
@since 0.5 *)
|
||||||
|
|
||||||
exception OneShotSequence
|
exception OneShotSequence
|
||||||
(** Raised when the user tries to iterate several times on
|
(** Raised when the user tries to iterate several times on
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue