# Module Iter

`module Iter: `sig` .. `end``
Astract iterators.

`type `'a` t `
`val next : `'a t -> 'a option``
get the next element of the iterator
`val next_exn : `'a t -> 'a``
`val progress : `'a t -> float option``
get the position in the iterator either None or Some x in `0;1`
`val progress_string : `float option -> string``
convert the progress return value to a string: None->"", Some->" 33%"
`val i : `'a t -> f:('a -> unit) -> unit``
iterate over the iterator: call f on each element
`val concat : `'a t list -> 'a t``
concatenate a list of iterators
`val reduce : `'a t -> init:'i -> f:('i -> 'a -> 'i) -> 'i``
fold over the iterator: call f on each element and return the accumulator
`val map : `'a t -> f:('a -> 'b) -> 'b t``
transform the iterator
`val fold : `'a t -> init:'i -> f:('i -> 'a -> 'i) -> 'i``
fold is the same as reduce
`val unfold : `init:'i -> f:('i -> 'a * 'i) -> stop:'i -> 'a t``
`val find : `'a t -> f:('a -> bool) -> 'a``
find an element that satisfies the predicate
`val filter : `'a t -> f:('a -> bool) -> 'a t``
iterate over elements that satisfy the predicate
`val for_all : `'a t -> f:('a -> bool) -> bool``
evaluate a predicate over the entire iterator
`val exists : `'a t -> f:('a -> bool) -> bool``
`val t : `?progress:(unit -> float option) -> (unit -> 'a option) -> 'a t``
create an iterator from an iterating function
`val empty : `'a t``
an iterator that halts immediately
`val of_opt : `'a option -> 'a t``
create an iterator that may iterate over one value
`val of_list : `'a list -> 'a t``
create an iterator that will go over list elements
`val to_list : `'a t -> f:('a -> 'b) -> 'b list``
iterate a function and collect results to a list
`val to_list_opt : `'a t -> f:('a -> 'b option) -> 'b list``
`val of_array : `'a array -> 'a t``
create an iterator that will go over array elements
`val to_array : `'a t -> f:('a -> 'b) -> 'b array``
iterate a function and collect results to a array
`val to_array_opt : `'a t -> f:('a -> 'b option) -> 'b array``
`val channel_progress : `?total:int64 -> Pervasives.in_channel -> unit -> float option``
create a progress function for an input channel
`val of_channel : `?total:int64 ->       Pervasives.in_channel -> f:(Pervasives.in_channel -> 'a) -> 'a t``
create an iterator that will read from file using f
`val channel : `Pervasives.in_channel -> f:(Pervasives.in_channel -> unit) -> unit``
call f on channel until End_of_file