diff --git a/dev/index.html b/dev/index.html index e769887..8dcda4e 100644 --- a/dev/index.html +++ b/dev/index.html @@ -11,7 +11,7 @@

OCaml package documentation

    -
  1. iter 1.7
  2. +
  3. iter 1.8
diff --git a/dev/iter/Iter/index.html b/dev/iter/Iter/index.html index a60ddab..957f0d9 100644 --- a/dev/iter/Iter/index.html +++ b/dev/iter/Iter/index.html @@ -24,7 +24,7 @@ ('a * 'b list) t

group_join_by key2 associates to every element x of the first iterator, all the elements y of the second iterator such that eq x (key y). Elements of the first iterators without corresponding values in the second one are mapped to [] precondition: for any x and y, if eq x y then hash x=hash y must hold.

Set-like

val inter : ?eq:'a equal -> ?hash:'a hash -> 'a t -> 'a t -> 'a t

Intersection of two collections. Each element will occur at most once in the result. Eager. precondition: for any x and y, if eq x y then hash x=hash y must hold.

val union : ?eq:'a equal -> ?hash:'a hash -> 'a t -> 'a t -> 'a t

Union of two collections. Each element will occur at most once in the result. Eager. precondition: for any x and y, if eq x y then hash x=hash y must hold.

val diff : ?eq:'a equal -> ?hash:'a hash -> 'a t -> 'a t -> 'a t

Set difference. Eager.

val subset : ?eq:'a equal -> ?hash:'a hash -> 'a t -> 'a t -> bool

subset a b returns true if all elements of a belong to b. Eager. precondition: for any x and y, if eq x y then hash x=hash y must hold.

Arithmetic

val max : ?lt:('a -> 'a -> bool) -> 'a t -> 'a option

Max element of the iterator, using the given comparison function.

val max_exn : ?lt:('a -> 'a -> bool) -> 'a t -> 'a

Unsafe version of max

val min : ?lt:('a -> 'a -> bool) -> 'a t -> 'a option

Min element of the iterator, using the given comparison function. see max for more details.

val min_exn : ?lt:('a -> 'a -> bool) -> 'a t -> 'a

Unsafe version of min

val sum : int t -> int

Sum of elements

val sumf : float t -> float

Sum of elements, using Kahan summation

List-like

val head : 'a t -> 'a option

First element, if any, otherwise None

val head_exn : 'a t -> 'a

First element, if any, fails

val take : int -> 'a t -> 'a t

Take at most n elements from the iterator. Works on infinite iterators.

val take_while : ('a -> bool) -> 'a t -> 'a t

Take elements while they satisfy the predicate, then stops iterating. Will work on an infinite iterator s if the predicate is false for at least one element of s.

val map_while : ('a -> [ `Yield of 'b | `Return of 'b | `Stop ]) -> 'a t -> - 'b t

Maps over elements of the iterator, stopping early if the mapped function returns `Stop or `Return x. At each iteration:

val fold_while : ('a -> 'b -> 'a * [ `Stop | `Continue ]) -> 'a -> 'b t -> 'a

Folds over elements of the iterator, stopping early if the accumulator returns ('a, `Stop)

val drop : int -> 'a t -> 'a t

Drop the n first elements of the iterator. Lazy.

val drop_while : ('a -> bool) -> 'a t -> 'a t

Predicate version of drop

val rev : 'a t -> 'a t

Reverse the iterator. O(n) memory and time, needs the iterator to be finite. The result is persistent and does not depend on the input being repeatable.

val zip_i : 'a t -> (int * 'a) t

Zip elements of the iterator with their index in the iterator.

Pair iterators

val fold2 : ('c -> 'a -> 'b -> 'c) -> 'c -> ('a * 'b) t -> 'c
val iter2 : ('a -> 'b -> unit) -> ('a * 'b) t -> unit
val map2 : ('a -> 'b -> 'c) -> ('a * 'b) t -> 'c t
val map2_2 : ('a -> 'b -> 'c) -> ('a -> 'b -> 'd) -> ('a * 'b) t -> ('c * 'd) t

map2_2 f g seq2 maps each x, y of seq2 into f x y, g x y

Data structures converters

val to_list : 'a t -> 'a list

Convert the iterator into a list. Preserves order of elements. This function is tail-recursive, but consumes 2*n memory. If order doesn't matter to you, consider to_rev_list.

val to_rev_list : 'a t -> 'a list

Get the list of the reversed iterator (more efficient than to_list)

val of_list : 'a list -> 'a t
val on_list : ('a t -> 'b t) -> 'a list -> 'b list

on_list f l is equivalent to to_list @@ f @@ of_list l.

val pair_with_idx : 'a t -> (int * 'a) t

Similar to zip_i but returns a normal iterator of tuples

val to_opt : 'a t -> 'a option

Alias to head

val to_array : 'a t -> 'a array

Convert to an array. Currently not very efficient because an intermediate list is used.

val of_array : 'a array -> 'a t
val of_array_i : 'a array -> (int * 'a) t

Elements of the array, with their index

val array_slice : 'a array -> int -> int -> 'a t

array_slice a i j Iterator of elements whose indexes range from i to j

val of_opt : 'a option -> 'a t

Iterate on 0 or 1 values.

val of_seq : 'a Stdlib.Seq.t -> 'a t

Iterator of elements of a Seq.t.

val to_seq_persistent : 'a t -> 'a Stdlib.Seq.t

Convert to a Seq. Linear in memory and time (a copy is made in memory). This does not work on infinite iterators.

val to_stack : 'a Stdlib.Stack.t -> 'a t -> unit

Push elements of the iterator on the stack

val of_stack : 'a Stdlib.Stack.t -> 'a t

Iterator of elements of the stack (same order as Stack.iter)

val to_queue : 'a Stdlib.Queue.t -> 'a t -> unit

Push elements of the iterator into the queue

val of_queue : 'a Stdlib.Queue.t -> 'a t

Iterator of elements contained in the queue, FIFO order

val hashtbl_add : ('a, 'b) Stdlib.Hashtbl.t -> ('a * 'b) t -> unit

Add elements of the iterator to the hashtable, with Hashtbl.add

val hashtbl_replace : ('a, 'b) Stdlib.Hashtbl.t -> ('a * 'b) t -> unit

Add elements of the iterator to the hashtable, with Hashtbl.replace (erases conflicting bindings)

val to_hashtbl : ('a * 'b) t -> ('a, 'b) Stdlib.Hashtbl.t

Build a hashtable from an iterator of key/value pairs

val of_hashtbl : ('a, 'b) Stdlib.Hashtbl.t -> ('a * 'b) t

Iterator of key/value pairs from the hashtable

val hashtbl_keys : ('a, 'b) Stdlib.Hashtbl.t -> 'a t
val hashtbl_values : ('a, 'b) Stdlib.Hashtbl.t -> 'b t
val of_str : string -> char t
val to_str : char t -> string
val concat_str : string t -> string

Concatenate strings together, eagerly. Also see intersperse to add a separator.

exception OneShotSequence

Raised when the user tries to iterate several times on a transient iterator

val of_in_channel : Stdlib.in_channel -> char t

Iterates on characters of the input (can block when one iterates over the iterator). If you need to iterate several times on this iterator, use persistent.

val to_buffer : char t -> Stdlib.Buffer.t -> unit

Copy content of the iterator into the buffer

val int_range : start:int -> stop:int -> int t

Iterator on integers in start...stop by steps 1. Also see (--) for an infix version.

val int_range_dec : start:int -> stop:int -> int t

Iterator on decreasing integers in stop...start by steps -1. See (--^) for an infix version

val int_range_by : step:int -> int -> int -> int t

int_range_by ~step i j is the range starting at i, including j, where the difference between successive elements is step. use a negative step for a decreasing iterator.

val bools : bool t

Iterates on true and false

val of_set : + 'b t

Maps over elements of the iterator, stopping early if the mapped function returns `Stop or `Return x. At each iteration:

val fold_while : ('a -> 'b -> 'a * [ `Stop | `Continue ]) -> 'a -> 'b t -> 'a

Folds over elements of the iterator, stopping early if the accumulator returns ('a, `Stop)

val drop : int -> 'a t -> 'a t

Drop the n first elements of the iterator. Lazy.

val drop_while : ('a -> bool) -> 'a t -> 'a t

Predicate version of drop

val rev : 'a t -> 'a t

Reverse the iterator. O(n) memory and time, needs the iterator to be finite. The result is persistent and does not depend on the input being repeatable.

val zip_i : 'a t -> (int * 'a) t

Zip elements of the iterator with their index in the iterator.

Pair iterators

val fold2 : ('c -> 'a -> 'b -> 'c) -> 'c -> ('a * 'b) t -> 'c
val iter2 : ('a -> 'b -> unit) -> ('a * 'b) t -> unit
val map2 : ('a -> 'b -> 'c) -> ('a * 'b) t -> 'c t
val map2_2 : ('a -> 'b -> 'c) -> ('a -> 'b -> 'd) -> ('a * 'b) t -> ('c * 'd) t

map2_2 f g seq2 maps each x, y of seq2 into f x y, g x y

Data structures converters

val to_list : 'a t -> 'a list

Convert the iterator into a list. Preserves order of elements. This function is tail-recursive, but consumes 2*n memory. If order doesn't matter to you, consider to_rev_list.

val to_rev_list : 'a t -> 'a list

Get the list of the reversed iterator (more efficient than to_list)

val of_list : 'a list -> 'a t
val on_list : ('a t -> 'b t) -> 'a list -> 'b list

on_list f l is equivalent to to_list @@ f @@ of_list l.

val pair_with_idx : 'a t -> (int * 'a) t

Similar to zip_i but returns a normal iterator of tuples

val to_opt : 'a t -> 'a option

Alias to head

val to_array : 'a t -> 'a array

Convert to an array. Currently not very efficient because an intermediate list is used.

val of_array : 'a array -> 'a t
val of_array_i : 'a array -> (int * 'a) t

Elements of the array, with their index

val array_slice : 'a array -> int -> int -> 'a t

array_slice a i j Iterator of elements whose indexes range from i to j

val of_opt : 'a option -> 'a t

Iterate on 0 or 1 values.

val of_seq : 'a Stdlib.Seq.t -> 'a t

Iterator of elements of a Seq.t.

val to_seq_persistent : 'a t -> 'a Stdlib.Seq.t

Convert to a Seq. Linear in memory and time (a copy is made in memory). This does not work on infinite iterators.

val to_stack : 'a Stdlib.Stack.t -> 'a t -> unit

Push elements of the iterator on the stack

val of_stack : 'a Stdlib.Stack.t -> 'a t

Iterator of elements of the stack (same order as Stack.iter)

val to_queue : 'a Stdlib.Queue.t -> 'a t -> unit

Push elements of the iterator into the queue

val of_queue : 'a Stdlib.Queue.t -> 'a t

Iterator of elements contained in the queue, FIFO order

val hashtbl_add : ('a, 'b) Stdlib.Hashtbl.t -> ('a * 'b) t -> unit

Add elements of the iterator to the hashtable, with Hashtbl.add

val hashtbl_replace : ('a, 'b) Stdlib.Hashtbl.t -> ('a * 'b) t -> unit

Add elements of the iterator to the hashtable, with Hashtbl.replace (erases conflicting bindings)

val to_hashtbl : ('a * 'b) t -> ('a, 'b) Stdlib.Hashtbl.t

Build a hashtable from an iterator of key/value pairs

val of_hashtbl : ('a, 'b) Stdlib.Hashtbl.t -> ('a * 'b) t

Iterator of key/value pairs from the hashtable

val hashtbl_keys : ('a, 'b) Stdlib.Hashtbl.t -> 'a t
val hashtbl_values : ('a, 'b) Stdlib.Hashtbl.t -> 'b t
val of_str : string -> char t
val to_str : char t -> string
val concat_str : string t -> string

Concatenate strings together, eagerly. Also see intersperse to add a separator.

exception OneShotSequence

Raised when the user tries to iterate several times on a transient iterator

val of_in_channel : Stdlib.in_channel -> char t

Iterates on characters of the input (can block when one iterates over the iterator). If you need to iterate several times on this iterator, use persistent.

val to_buffer : char t -> Stdlib.Buffer.t -> unit

Copy content of the iterator into the buffer

val int_range : start:int -> stop:int -> int t

Iterator on integers in start...stop by steps 1. Also see (--) for an infix version.

val int_range_dec : start:int -> stop:int -> int t

Iterator on decreasing integers in stop...start by steps -1. See (--^) for an infix version

val int_range_by : step:int -> int -> int -> int t

int_range_by ~step i j is the range starting at i, including j, where the difference between successive elements is step. use a negative step for a decreasing iterator.

val bools : bool t

Iterates on true and false

val of_set : (module Stdlib.Set.S with type elt = 'a and type t = 'b) -> 'b -> 'a t

Convert the given set to an iterator. The set module must be provided.

val to_set :