Module MoreString


module MoreString: sig .. end
Utilities for strings.

This module provides the necessary functions for applying data structure comprehension to strings.



String utilities


val to_string : string -> string
Convert a string to itself.

This function does nothing. It is included for consistency.

val to_array : string -> char array
Convert a string to an array of the same size
val to_stream : string -> char Stream.t
Lazily convert a string to a stream.

As the conversion is lazy, if you modify s after the conversion, the result of to_stream s may be affected.

val to_lazylist : string -> char LList.t
Lazily convert a string to a lazy list.

As the conversion is lazy, if you modify s after the conversion, the result of to_lazylist s may be affected.

val to_list : string -> char list
Convert a string to a list
val map : (char -> char) -> string -> string
Transform a character string into another one of the same size.
val filter : (char -> bool) -> string -> string
Extract characters validating a predicate
val map_filter : (char -> char option) -> string -> string
Drop some characters, transform others

If s is the string composed of characters a1, a2 ... an, map_filter f s applies f to each a1, ..., an. If f ai evaluates to None, the element is not included in the result. Otherwise, if f ai evaluates to Some x, element x is included in the result.

This is equivalent to

MoreList.to_string [match f a1 with
     | Some x1 -> x1 :: (match f a2 with
            |Some x2 -> x2 :: (match ...
                       (match f an with
                            | Some xn -> [ xn ]
                            | None    -> [ ]
                       )
            | ...)
     | None   -> ... 
.

Identical to module String


val length : string -> int
val get : string -> int -> char
val set : string -> int -> char -> unit
val create : int -> string
val make : int -> char -> string
val copy : string -> string
val sub : string -> int -> int -> string
val fill : string -> int -> int -> char -> unit
val blit : string -> int -> string -> int -> int -> unit
val concat : string -> string list -> string
val iter : (char -> unit) -> string -> unit
val escaped : string -> string
val index : string -> char -> int
val rindex : string -> char -> int
val index_from : string -> int -> char -> int
val rindex_from : string -> int -> char -> int
val contains : string -> char -> bool
val contains_from : string -> int -> char -> bool
val rcontains_from : string -> int -> char -> bool
val uppercase : string -> string
val lowercase : string -> string
val capitalize : string -> string
val uncapitalize : string -> string
type t = string 
val compare : t -> t -> int
val unsafe_get : string -> int -> char
val unsafe_set : string -> int -> char -> unit
val unsafe_blit : string -> int -> string -> int -> int -> unit
val unsafe_fill : string -> int -> int -> char -> unit