diff --git a/dev/iter/Iter/IO/index.html b/dev/iter/Iter/IO/index.html index 24ad335..9e6d6b2 100644 --- a/dev/iter/Iter/IO/index.html +++ b/dev/iter/Iter/IO/index.html @@ -1,5 +1,5 @@ -
Iter.IOval lines_of : ?mode:int -> ?flags:Stdlib.open_flag list -> string -> string tlines_of filename reads all lines of the given file. It raises the same exception as would opening the file and read from it, except from End_of_file (which is caught). The file is always properly closed. Every time the iterator is iterated on, the file is opened again, so different iterations might return different results
val chunks_of :
+IO (iter.Iter.IO) Module Iter.IO
Basic IO
Very basic interface to manipulate files as iterator of chunks/lines. The iterators take care of opening and closing files properly; every time one iterates over an iterator, the file is opened/closed again.
Example: copy a file "a" into file "b", removing blank lines:
Iterator.(IO.lines_of "a" |> filter (fun l-> l<> "") |> IO.write_lines "b");;
By chunks of 4096 bytes:
Iterator.IO.(chunks_of ~size:4096 "a" |> write_to "b");;
Read the lines of a file into a list:
Iterator.IO.lines "a" |> Iterator.to_list
val lines_of : ?mode:int -> ?flags:Stdlib.open_flag list -> string -> string tlines_of filename reads all lines of the given file. It raises the same exception as would opening the file and read from it, except from End_of_file (which is caught). The file is always properly closed. Every time the iterator is iterated on, the file is opened again, so different iterations might return different results
val chunks_of :
?mode:int ->
?flags:Stdlib.open_flag list ->
?size:int ->
diff --git a/dev/iter/Iter/index.html b/dev/iter/Iter/index.html
index 8f9ef9b..54eb5f6 100644
--- a/dev/iter/Iter/index.html
+++ b/dev/iter/Iter/index.html
@@ -1,5 +1,5 @@
-Iter (iter.Iter) Module Iter
Simple and Efficient Iterators
The iterators are designed to allow easy transfer (mappings) between data structures, without defining n^2 conversions between the n types. The implementation relies on the assumption that an iterator can be iterated on as many times as needed; this choice allows for high performance of many combinators. However, for transient iterators, the persistent function is provided, storing elements of a transient iterator in memory; the iterator can then be used several times (See further).
Note that some combinators also return iterators (e.g. group). The transformation is computed on the fly every time one iterates over the resulting iterator. If a transformation performs heavy computation, persistent can also be used as intermediate storage.
Most functions are lazy, i.e. they do not actually use their arguments until their result is iterated on. For instance, if one calls map on an iterator, one gets a new iterator, but nothing else happens until this new iterator is used (by folding or iterating on it).
If an iterator is built from an iteration function that is repeatable (i.e. calling it several times always iterates on the same set of elements, for instance List.iter or Map.iter), then the resulting t object is also repeatable. For one-time iter functions such as iteration on a file descriptor or a Seq, the persistent function can be used to iterate and store elements in a memory structure; the result is an iterator that iterates on the elements of this memory structure, cheaply and repeatably.
An iterator of values of type 'a. If you give it a function 'a -> unit it will be applied to every element of the iterator successively.
type +'a iter = 'a tNOTE Type ('a, 'b) t2 = ('a -> 'b -> unit) -> unit has been removed and subsumed by ('a * 'b) t
Creation
val from_iter : ( ( 'a -> unit ) -> unit ) -> 'a tBuild an iterator from a iter function
val from_labelled_iter : ( f:( 'a -> unit ) -> unit ) -> 'a tBuild an iterator from a labelled iter function
val from_fun : ( unit -> 'a option ) -> 'a tCall the function repeatedly until it returns None. This iterator is transient, use persistent if needed!
val empty : 'a tEmpty iterator. It contains no element.
val singleton : 'a -> 'a tSingleton iterator, with exactly one element.
val doubleton : 'a -> 'a -> 'a tIterator with exactly two elements
val init : ( int -> 'a ) -> 'a tinit f is the infinite iterator f 0; f 1; f 2; ….
val repeat : 'a -> 'a tInfinite iterator of the same element. You may want to look at take and the likes if you iterate on it.
val iterate : ( 'a -> 'a ) -> 'a -> 'a titerate f x is the infinite iterator x, f(x), f(f(x)), ...
val forever : ( unit -> 'b ) -> 'b tIterator that calls the given function to produce elements. The iterator may be transient (depending on the function), and definitely is infinite. You may want to use take and persistent.
Cycle forever through the given iterator. Assume the given iterator can be traversed any amount of times (not transient). This yields an infinite iterator, you should use something like take not to loop forever.
val unfoldr : ( 'b -> ('a * 'b) option ) -> 'b -> 'a tunfoldr f b will apply f to b. If it yields Some (x,b') then x is returned and unfoldr recurses with b'.
Consumption
val iter : ( 'a -> unit ) -> 'a t -> unitConsume the iterator, passing all its arguments to the function. Basically iter f seq is just seq f.
val iteri : ( int -> 'a -> unit ) -> 'a t -> unitIterate on elements and their index in the iterator
val for_each : 'a t -> ( 'a -> unit ) -> unitConsume the iterator, passing all its arguments to the function. for_each seq f is the same as iter f seq, i.e., iter with arguments reversed.
val for_eachi : 'a t -> ( int -> 'a -> unit ) -> unitIterate on elements and their index in the iterator. for_eachi seq f is the same as iteri f seq, i.e., iteri with arguments reversed.
val fold : ( 'a -> 'b -> 'a ) -> 'a -> 'b t -> 'aFold over elements of the iterator, consuming it
val foldi : ( 'a -> int -> 'b -> 'a ) -> 'a -> 'b t -> 'aFold over elements of the iterator and their index, consuming it
val fold_filter_map :
+Iter (iter.Iter) Module Iter
Simple and Efficient Iterators
The iterators are designed to allow easy transfer (mappings) between data structures, without defining n^2 conversions between the n types. The implementation relies on the assumption that an iterator can be iterated on as many times as needed; this choice allows for high performance of many combinators. However, for transient iterators, the persistent function is provided, storing elements of a transient iterator in memory; the iterator can then be used several times (See further).
Note that some combinators also return iterators (e.g. group). The transformation is computed on the fly every time one iterates over the resulting iterator. If a transformation performs heavy computation, persistent can also be used as intermediate storage.
Most functions are lazy, i.e. they do not actually use their arguments until their result is iterated on. For instance, if one calls map on an iterator, one gets a new iterator, but nothing else happens until this new iterator is used (by folding or iterating on it).
If an iterator is built from an iteration function that is repeatable (i.e. calling it several times always iterates on the same set of elements, for instance List.iter or Map.iter), then the resulting t object is also repeatable. For one-time iter functions such as iteration on a file descriptor or a Seq, the persistent function can be used to iterate and store elements in a memory structure; the result is an iterator that iterates on the elements of this memory structure, cheaply and repeatably.
An iterator of values of type 'a. If you give it a function 'a -> unit it will be applied to every element of the iterator successively.
type +'a iter = 'a tCreation
val from_iter : ( ( 'a -> unit ) -> unit ) -> 'a tBuild an iterator from a iter function
val from_labelled_iter : ( f:( 'a -> unit ) -> unit ) -> 'a tBuild an iterator from a labelled iter function
val from_fun : ( unit -> 'a option ) -> 'a tCall the function repeatedly until it returns None. This iterator is transient, use persistent if needed!
val empty : 'a tEmpty iterator. It contains no element.
val singleton : 'a -> 'a tSingleton iterator, with exactly one element.
val doubleton : 'a -> 'a -> 'a tIterator with exactly two elements
val init : ( int -> 'a ) -> 'a tinit f is the infinite iterator f 0; f 1; f 2; ….
val repeat : 'a -> 'a tInfinite iterator of the same element. You may want to look at take and the likes if you iterate on it.
val iterate : ( 'a -> 'a ) -> 'a -> 'a titerate f x is the infinite iterator x, f(x), f(f(x)), ...
val forever : ( unit -> 'b ) -> 'b tIterator that calls the given function to produce elements. The iterator may be transient (depending on the function), and definitely is infinite. You may want to use take and persistent.
Cycle forever through the given iterator. Assume the given iterator can be traversed any amount of times (not transient). This yields an infinite iterator, you should use something like take not to loop forever.
val unfoldr : ( 'b -> ('a * 'b) option ) -> 'b -> 'a tunfoldr f b will apply f to b. If it yields Some (x,b') then x is returned and unfoldr recurses with b'.
Consumption
val iter : ( 'a -> unit ) -> 'a t -> unitConsume the iterator, passing all its arguments to the function. Basically iter f seq is just seq f.
val iteri : ( int -> 'a -> unit ) -> 'a t -> unitIterate on elements and their index in the iterator
val for_each : 'a t -> ( 'a -> unit ) -> unitConsume the iterator, passing all its arguments to the function. for_each seq f is the same as iter f seq, i.e., iter with arguments reversed.
val for_eachi : 'a t -> ( int -> 'a -> unit ) -> unitIterate on elements and their index in the iterator. for_eachi seq f is the same as iteri f seq, i.e., iteri with arguments reversed.
val fold : ( 'a -> 'b -> 'a ) -> 'a -> 'b t -> 'aFold over elements of the iterator, consuming it
val foldi : ( 'a -> int -> 'b -> 'a ) -> 'a -> 'b t -> 'aFold over elements of the iterator and their index, consuming it
val fold_filter_map :
( 'acc -> 'a -> 'acc * 'b option ) ->
'acc ->
'a t ->
@@ -53,4 +53,4 @@
( Stdlib.Buffer.t -> 'a -> unit ) ->
Stdlib.Buffer.t ->
'a t ->
- unitPrint into a buffer
val to_string : ?sep:string -> ( 'a -> string ) -> 'a t -> stringPrint into a string
Basic IO
Very basic interface to manipulate files as iterator of chunks/lines. The iterators take care of opening and closing files properly; every time one iterates over an iterator, the file is opened/closed again.
Example: copy a file "a" into file "b", removing blank lines:
Iterator.(IO.lines_of "a" |> filter (fun l-> l<> "") |> IO.write_lines "b");;
By chunks of 4096 bytes:
Iterator.IO.(chunks_of ~size:4096 "a" |> write_to "b");;
Read the lines of a file into a list:
Iterator.IO.lines "a" |> Iterator.to_list
module IO : sig ... end
\ No newline at end of file
+ unitPrint into a buffer
val to_string : ?sep:string -> ( 'a -> string ) -> 'a t -> stringPrint into a string
module IO : sig ... endBasic IO
\ No newline at end of file
diff --git a/dev/iter/IterBigarray/index.html b/dev/iter/IterBigarray/index.html
index 2adee77..9aef472 100644
--- a/dev/iter/IterBigarray/index.html
+++ b/dev/iter/IterBigarray/index.html
@@ -1,2 +1,2 @@
-IterBigarray (iter.IterBigarray) Module IterBigarray
Interface and Helpers for bigarrays
val of_bigarray : ( 'a, _, _ ) Stdlib.Bigarray.Array1.t -> 'a Iter.tIterate on the elements of a 1-D array
val mmap : string -> char Iter.tMap the file into memory, and read the characters.
\ No newline at end of file
+IterBigarray (iter.IterBigarray) Module IterBigarray
Interface and Helpers for bigarrays
val of_bigarray : ( 'a, _, _ ) Stdlib.Bigarray.Array1.t -> 'a Iter.tIterate on the elements of a 1-D array
val mmap : string -> char Iter.tMap the file into memory, and read the characters.
\ No newline at end of file
diff --git a/dev/iter/index.html b/dev/iter/index.html
index 54949f1..afcd0d7 100644
--- a/dev/iter/index.html
+++ b/dev/iter/index.html
@@ -1,2 +1,2 @@
-index (iter.index) iter index
Library iter
This library exposes the following toplevel modules:
Library iter.bigarray
This library exposes the following toplevel modules:
\ No newline at end of file
+index (iter.index) iter index
Library iter
This library exposes the following toplevel modules:
Iter Simple and Efficient IteratorsIterLabels Iter_shims_
Library iter.bigarray
This library exposes the following toplevel modules:
IterBigarray Interface and Helpers for bigarraysIterBigarrayShims_
\ No newline at end of file