module Text:sig..end
This module provides some general functions which are especially useful for manipulating text and text files.
val iter_lines_of_channel : (string -> unit) -> Stdlib.in_channel -> unititer_lines_of_channel f ic reads input channel ic
and applies successively the given function f to
each line until the end of file is reached.
val iter_lines_of_file : (string -> unit) -> string -> unititer_lines_of_file f file reads file file
and applies successively the given function f to
each line until the end of file is reached.
val lines_of_channel : Stdlib.in_channel -> string listlines_of_channel ic returns the list of the lines that can be
read from input channel ic.
val lines_of_file : string -> string listlines_of_file file returns the list of the lines that can be
read from file file.
val channel_contents : Stdlib.in_channel -> stringchannel_contents ic returns the string containing the bytes
that can be read from the given input channel ic.
val file_contents : ?bin:bool -> string -> stringfile_contents file returns the string containing the bytes
that can be read from the given file.
Option bin specifies if Pervasives.open_in_bin should be
used instead of Pervasives.open_in to open the file. Default is
false.
val save : string -> string -> unitsave file data stores the string data in file.
If the file already exists, its contents is discarded silently.
val save_lines : string -> string list -> unitsave_lines file l saves the given list l of strings in file
and adds a newline characters ('\n') after each of them.
If the file already exists, its contents is discarded silently.
exception Skip
This exception can be used to skip an element of a list being
processed with rev_map, map, fold_left, and fold_right.
val map : ('a -> 'b) -> 'a list -> 'b listLike List.map but it is guaranteed that
the elements of the input list are processed from left to right.
Moreover the Skip exception can be used to skip an element
of the list.
This function runs in constant stack space.
val rev_map : ('a -> 'b) -> 'a list -> 'b listLike List.rev_map, but it is guaranteed that
the elements of the input list are processed from left to right.
Moreover the Skip exception can be used to skip an element
of the list.
This function runs in constant stack space and is slightly faster
then map.
val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'aLike List.fold_left
but the Skip exception can be used to skip an element
of the list.
This function runs in constant stack space.
val fold_right : ('a -> 'b -> 'b) -> 'a list -> 'b -> 'bLike List.fold_right
but the Skip exception can be used to skip an element
of the list.
This function runs in constant stack space.
val map_lines_of_channel : (string -> 'a) -> Stdlib.in_channel -> 'a listmap_lines_of_channel f ic is equivalent to
map f (lines_of_channel ic) but faster.
val map_lines_of_file : (string -> 'a) -> string -> 'a listmap_lines_of_file f file is equivalent to
map f (lines_of_file file) but faster.