From b4e421864ac280e923dbbbf7ad40a81164e0346c Mon Sep 17 00:00:00 2001 From: c-cube Date: Mon, 3 May 2021 17:34:13 +0000 Subject: [PATCH] deploy: 7444b51d8bdb2849e35dc788267bda0819ca4958 --- dev/containers/CCOpt/index.html | 2 +- dev/containers/CCSexp/Make/index.html | 2 +- dev/containers/CCString/index.html | 2 +- dev/containers/CCStringLabels/index.html | 2 +- dev/index.html | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dev/containers/CCOpt/index.html b/dev/containers/CCOpt/index.html index b5211152..1bc6a727 100644 --- a/dev/containers/CCOpt/index.html +++ b/dev/containers/CCOpt/index.html @@ -1,2 +1,2 @@ -CCOpt (containers.CCOpt)

Module CCOpt

Options

type +'a t = 'a option
val map : ('a -> 'b) -> 'a t -> 'b t

map f o applies the function f to the element inside o, if any.

val map_or : default:'b -> ('a -> 'b) -> 'a t -> 'b

map_or ~default f o is f x if o = Some x, default otherwise.

since
0.16
val map_lazy : (unit -> 'b) -> ('a -> 'b) -> 'a t -> 'b

map_lazy default_fn f o if f o if o = Some x, default_fn () otherwise.

since
1.2
val is_some : _ t -> bool

is_some (Some x) returns true otherwise it returns false.

val is_none : _ t -> bool

is_none None returns true otherwise it returns false.

since
0.11
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int

compare comp o1 o2 compares two options o1 and o2, using custom comparators comp for the value. None is always assumed to be less than Some _.

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

equal p o1 o2 tests for equality between option types o1 and o2, using a custom equality predicate p.

val return : 'a -> 'a t

return x is a monadic return, that is return x = Some x.

val (>|=) : 'a t -> ('a -> 'b) -> 'b t

o >|= f is the infix version of map.

val flat_map : ('a -> 'b t) -> 'a t -> 'b t

flat_map f o is equivalent to map followed by flatten. Flip version of >>=.

val bind : 'a t -> ('a -> 'b t) -> 'b t

bind o f is f v if o is Some v, None otherwise. Monadic bind.

since
3.0
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t

o >>= f is the infix version of bind.

val map2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t

map2 f o1 o2 maps 'a option and 'b option to a 'c option using f.

val iter : ('a -> unit) -> 'a t -> unit

iter f o applies f to o. Iterate on 0 or 1 element.

val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a

fold f init o is f init x if o is Some x, or init if o is None. Fold on 0 or 1 element.

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

filter f o returns Some x if o is Some x and f x is true, or None if f x is false or if o is None. Filter on 0 or 1 element.

since
0.5
val if_ : ('a -> bool) -> 'a -> 'a option

if_ f x is Some x if f x, None otherwise.

since
0.17
val exists : ('a -> bool) -> 'a t -> bool

exists f o returns true iff there exists an element for which the provided function f evaluates to true.

since
0.17
val for_all : ('a -> bool) -> 'a t -> bool

for_all f o returns true iff the provided function f evaluates to true for all elements.

since
0.17
val get_or : default:'a -> 'a t -> 'a

get_or ~default o extracts the value from o, or returns default if o is None.

since
0.18
val value : 'a t -> default:'a -> 'a

value o ~default is similar to the Stdlib's Option.value and to get_or.

since
2.8
val get_exn : 'a t -> 'a

get_exn o returns x if o is Some x or fails if o is None.

raises Invalid_argument

if the option is None.

deprecated

use get_exn_or instead

val get_exn_or : string -> 'a t -> 'a

get_exn_or msg o returns x if o is Some x or fails with Invalid_argument msg if o is None.

raises Invalid_argument

if the option is None.

since
NEXT_RELEASE
val get_lazy : (unit -> 'a) -> 'a t -> 'a

get_lazy default_fn o unwraps o, but if o is None it returns default_fn () instead.

since
0.6.1
val sequence_l : 'a t list -> 'a list t

sequence_l [x1; x2; …; xn] returns Some [y1; y2; …; yn] if every xi is Some yi. Otherwise, if the list contains at least one None, the result is None.

val wrap : ?⁠handler:(exn -> bool) -> ('a -> 'b) -> 'a -> 'b option

wrap ?handler f x calls f x and returns Some y if f x = y. If f x raises any exception, the result is None. This can be useful to wrap functions such as Map.S.find.

parameter handler

the exception handler, which returns true if the exception is to be caught.

val wrap2 : ?⁠handler:(exn -> bool) -> ('a -> 'b -> 'c) -> 'a -> 'b -> 'c option

wrap2 ?handler f x y is similar to wrap but for binary functions.

Applicative

val pure : 'a -> 'a t

pure x is an alias to return.

val (<*>) : ('a -> 'b) t -> 'a t -> 'b t

f <*> (Some x) returns Some (f x) and f <*> None returns None.

val (<$>) : ('a -> 'b) -> 'a t -> 'b t

f <$> o is like map f o.

Alternatives

val or_ : else_:'a t -> 'a t -> 'a t

or_ ~else_ o is o if o is Some _, else_ if o is None.

since
1.2
val or_lazy : else_:(unit -> 'a t) -> 'a t -> 'a t

or_lazy ~else_ o is o if o is Some _, else_ () if o is None.

since
1.2
val (<+>) : 'a t -> 'a t -> 'a t

o1 <+> o2 is o1 if o1 is Some _, o2 if o1 is None.

val choice : 'a t list -> 'a t

choice lo returns the first non-None element of the list lo, or None.

val flatten : 'a t t -> 'a t

flatten oo transforms Some x into x.

since
2.2
val return_if : bool -> 'a -> 'a t

return_if b x applies Some or None depending on the boolean b. More precisely, return_if false x is None, and return_if true x is Some x.

since
2.2

Infix Operators

since
0.16
module Infix : sig ... end

Let operators on OCaml >= 4.08.0, nothing otherwise

since
2.8
include CCShimsMkLet_.S with type 'a t_let := 'a option
type 'a t_let
val let+ : 'a t_let -> ('a -> 'b) -> 'b t_let
val and+ : 'a t_let -> 'b t_let -> ('a * 'b) t_let
val let* : 'a t_let -> ('a -> 'b t_let) -> 'b t_let
val and* : 'a t_let -> 'b t_let -> ('a * 'b) t_let

Conversion and IO

val to_list : 'a t -> 'a list

to_list o returns [x] if o is Some x or the empty list [] if o is None.

val of_list : 'a list -> 'a t

of_list l returns Some x (x being the head of the list l), or None if l is the empty list.

val to_result : 'e -> 'a t -> ('a'e) Stdlib.result

to_result e o returns Ok x if o is Some x, or Error e if o is None.

since
1.2
val to_result_lazy : (unit -> 'e) -> 'a t -> ('a'e) Stdlib.result

to_result_lazy f o returns Ok x if o is Some x or Error f if o is None.

since
1.2
val of_result : ('a_) Stdlib.result -> 'a t

of_result result returns an option from a result.

since
1.2
type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a random_gen = Stdlib.Random.State.t -> 'a
val random : 'a random_gen -> 'a t random_gen
val choice_iter : 'a t iter -> 'a t

choice_iter iter is similar to choice, but works on iter. It returns the first Some x occurring in iter, or None otherwise.

since
3.0
val choice_seq : 'a t Stdlib.Seq.t -> 'a t

choice_seq seq works on Seq.t. It returns the first Some x occurring in seq, or None otherwise.

since
3.0
val to_gen : 'a t -> 'a gen

to_gen o is o as a gen. Some x is the singleton gen containing x and None is the empty gen.

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

to_seq o is o as a sequence Seq.t. Some x is the singleton sequence containing x and None is the empty sequence. Same as Stdlib.Option.to_seq Renamed from to_std_seq since 3.0.

since
3.0
val to_iter : 'a t -> 'a iter

to_iter o returns an internal iterator, like in the library Iter.

since
2.8
val pp : 'a printer -> 'a t printer

pp ppf o pretty-prints option o using ppf.

\ No newline at end of file +CCOpt (containers.CCOpt)

Module CCOpt

Options

type +'a t = 'a option
val map : ('a -> 'b) -> 'a t -> 'b t

map f o applies the function f to the element inside o, if any.

val map_or : default:'b -> ('a -> 'b) -> 'a t -> 'b

map_or ~default f o is f x if o = Some x, default otherwise.

since
0.16
val map_lazy : (unit -> 'b) -> ('a -> 'b) -> 'a t -> 'b

map_lazy default_fn f o if f o if o = Some x, default_fn () otherwise.

since
1.2
val is_some : _ t -> bool

is_some (Some x) returns true otherwise it returns false.

val is_none : _ t -> bool

is_none None returns true otherwise it returns false.

since
0.11
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int

compare comp o1 o2 compares two options o1 and o2, using custom comparators comp for the value. None is always assumed to be less than Some _.

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

equal p o1 o2 tests for equality between option types o1 and o2, using a custom equality predicate p.

val return : 'a -> 'a t

return x is a monadic return, that is return x = Some x.

val (>|=) : 'a t -> ('a -> 'b) -> 'b t

o >|= f is the infix version of map.

val flat_map : ('a -> 'b t) -> 'a t -> 'b t

flat_map f o is equivalent to map followed by flatten. Flip version of >>=.

val bind : 'a t -> ('a -> 'b t) -> 'b t

bind o f is f v if o is Some v, None otherwise. Monadic bind.

since
3.0
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t

o >>= f is the infix version of bind.

val map2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t

map2 f o1 o2 maps 'a option and 'b option to a 'c option using f.

val iter : ('a -> unit) -> 'a t -> unit

iter f o applies f to o. Iterate on 0 or 1 element.

val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a

fold f init o is f init x if o is Some x, or init if o is None. Fold on 0 or 1 element.

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

filter f o returns Some x if o is Some x and f x is true, or None if f x is false or if o is None. Filter on 0 or 1 element.

since
0.5
val if_ : ('a -> bool) -> 'a -> 'a option

if_ f x is Some x if f x, None otherwise.

since
0.17
val exists : ('a -> bool) -> 'a t -> bool

exists f o returns true iff there exists an element for which the provided function f evaluates to true.

since
0.17
val for_all : ('a -> bool) -> 'a t -> bool

for_all f o returns true iff the provided function f evaluates to true for all elements.

since
0.17
val get_or : default:'a -> 'a t -> 'a

get_or ~default o extracts the value from o, or returns default if o is None.

since
0.18
val value : 'a t -> default:'a -> 'a

value o ~default is similar to the Stdlib's Option.value and to get_or.

since
2.8
val get_exn : 'a t -> 'a

get_exn o returns x if o is Some x or fails if o is None.

raises Invalid_argument

if the option is None.

deprecated

use get_exn_or instead

val get_exn_or : string -> 'a t -> 'a

get_exn_or msg o returns x if o is Some x or fails with Invalid_argument msg if o is None.

raises Invalid_argument

if the option is None.

since
3.4
val get_lazy : (unit -> 'a) -> 'a t -> 'a

get_lazy default_fn o unwraps o, but if o is None it returns default_fn () instead.

since
0.6.1
val sequence_l : 'a t list -> 'a list t

sequence_l [x1; x2; …; xn] returns Some [y1; y2; …; yn] if every xi is Some yi. Otherwise, if the list contains at least one None, the result is None.

val wrap : ?⁠handler:(exn -> bool) -> ('a -> 'b) -> 'a -> 'b option

wrap ?handler f x calls f x and returns Some y if f x = y. If f x raises any exception, the result is None. This can be useful to wrap functions such as Map.S.find.

parameter handler

the exception handler, which returns true if the exception is to be caught.

val wrap2 : ?⁠handler:(exn -> bool) -> ('a -> 'b -> 'c) -> 'a -> 'b -> 'c option

wrap2 ?handler f x y is similar to wrap but for binary functions.

Applicative

val pure : 'a -> 'a t

pure x is an alias to return.

val (<*>) : ('a -> 'b) t -> 'a t -> 'b t

f <*> (Some x) returns Some (f x) and f <*> None returns None.

val (<$>) : ('a -> 'b) -> 'a t -> 'b t

f <$> o is like map f o.

Alternatives

val or_ : else_:'a t -> 'a t -> 'a t

or_ ~else_ o is o if o is Some _, else_ if o is None.

since
1.2
val or_lazy : else_:(unit -> 'a t) -> 'a t -> 'a t

or_lazy ~else_ o is o if o is Some _, else_ () if o is None.

since
1.2
val (<+>) : 'a t -> 'a t -> 'a t

o1 <+> o2 is o1 if o1 is Some _, o2 if o1 is None.

val choice : 'a t list -> 'a t

choice lo returns the first non-None element of the list lo, or None.

val flatten : 'a t t -> 'a t

flatten oo transforms Some x into x.

since
2.2
val return_if : bool -> 'a -> 'a t

return_if b x applies Some or None depending on the boolean b. More precisely, return_if false x is None, and return_if true x is Some x.

since
2.2

Infix Operators

since
0.16
module Infix : sig ... end

Let operators on OCaml >= 4.08.0, nothing otherwise

since
2.8
include CCShimsMkLet_.S with type 'a t_let := 'a option
type 'a t_let
val let+ : 'a t_let -> ('a -> 'b) -> 'b t_let
val and+ : 'a t_let -> 'b t_let -> ('a * 'b) t_let
val let* : 'a t_let -> ('a -> 'b t_let) -> 'b t_let
val and* : 'a t_let -> 'b t_let -> ('a * 'b) t_let

Conversion and IO

val to_list : 'a t -> 'a list

to_list o returns [x] if o is Some x or the empty list [] if o is None.

val of_list : 'a list -> 'a t

of_list l returns Some x (x being the head of the list l), or None if l is the empty list.

val to_result : 'e -> 'a t -> ('a'e) Stdlib.result

to_result e o returns Ok x if o is Some x, or Error e if o is None.

since
1.2
val to_result_lazy : (unit -> 'e) -> 'a t -> ('a'e) Stdlib.result

to_result_lazy f o returns Ok x if o is Some x or Error f if o is None.

since
1.2
val of_result : ('a_) Stdlib.result -> 'a t

of_result result returns an option from a result.

since
1.2
type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a random_gen = Stdlib.Random.State.t -> 'a
val random : 'a random_gen -> 'a t random_gen
val choice_iter : 'a t iter -> 'a t

choice_iter iter is similar to choice, but works on iter. It returns the first Some x occurring in iter, or None otherwise.

since
3.0
val choice_seq : 'a t Stdlib.Seq.t -> 'a t

choice_seq seq works on Seq.t. It returns the first Some x occurring in seq, or None otherwise.

since
3.0
val to_gen : 'a t -> 'a gen

to_gen o is o as a gen. Some x is the singleton gen containing x and None is the empty gen.

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

to_seq o is o as a sequence Seq.t. Some x is the singleton sequence containing x and None is the empty sequence. Same as Stdlib.Option.to_seq Renamed from to_std_seq since 3.0.

since
3.0
val to_iter : 'a t -> 'a iter

to_iter o returns an internal iterator, like in the library Iter.

since
2.8
val pp : 'a printer -> 'a t printer

pp ppf o pretty-prints option o using ppf.

\ No newline at end of file diff --git a/dev/containers/CCSexp/Make/index.html b/dev/containers/CCSexp/Make/index.html index aad53da0..497be660 100644 --- a/dev/containers/CCSexp/Make/index.html +++ b/dev/containers/CCSexp/Make/index.html @@ -1,2 +1,2 @@ -Make (containers.CCSexp.Make)

Module CCSexp.Make

Functorized operations

This builds a parser and printer for S-expressions represented as in the Sexp argument.

since
2.7
since
NEXT_RELEASE re-bind [loc] to [Sexp.loc]

Parameters

Signature

include CCSexp_intf.S0
type t
type sexp = t

Re-exports

val atom : string -> t

Make an atom out of this string.

since
2.8
val list : t list -> t

Make a Sexpr of this list.

since
2.8

Constructors

val of_int : int -> t
val of_bool : bool -> t
val of_list : t list -> t
val of_rev_list : t list -> t

Reverse the list.

val of_float : float -> t
val of_unit : t
val of_pair : (t * t) -> t
val of_triple : (t * t * t) -> t
val of_quad : (t * t * t * t) -> t
val of_variant : string -> t list -> t

of_variant name args is used to encode algebraic variants into a S-expr. For instance of_variant "some" [of_int 1] represents the value Some 1.

val of_field : string -> t -> t

Used to represent one record field.

val of_record : (string * t) list -> t

Represent a record by its named fields.

Printing

val to_buf : Stdlib.Buffer.t -> t -> unit
val to_string : t -> string
val to_file : string -> t -> unit
val to_file_iter : string -> t CCSexp_intf.iter -> unit

Print the given iter of expressions to a file.

val to_chan : Stdlib.out_channel -> t -> unit
val pp : Stdlib.Format.formatter -> t -> unit

Pretty-printer nice on human eyes (including indentation).

val pp_noindent : Stdlib.Format.formatter -> t -> unit

Raw, direct printing as compact as possible.

Parsing

val parse_string : string -> t CCSexp_intf.or_error

Parse a string.

val parse_string_list : string -> t list CCSexp_intf.or_error

Parse a string into a list of S-exprs.

since
2.8
val parse_chan : Stdlib.in_channel -> t CCSexp_intf.or_error

Parse a S-expression from the given channel. Can read more data than necessary, so don't use this if you need finer-grained control (e.g. to read something else after the S-exp).

val parse_chan_gen : Stdlib.in_channel -> t CCSexp_intf.or_error CCSexp_intf.gen

Parse a channel into a generator of S-expressions.

val parse_chan_list : Stdlib.in_channel -> t list CCSexp_intf.or_error
val parse_file : string -> t CCSexp_intf.or_error

Open the file and read a S-exp from it.

val parse_file_list : string -> t list CCSexp_intf.or_error

Open the file and read a S-exp from it.

type loc = Sexp.loc

Locations for the S-expressions.

since
3.3

Parsing

type 'a parse_result =
| Yield of 'a
| Fail of string
| End

A parser of 'a can return Yield x when it parsed a value, or Fail e when a parse error was encountered, or End if the input was empty.

module Decoder : sig ... end
\ No newline at end of file +Make (containers.CCSexp.Make)

Module CCSexp.Make

Functorized operations

This builds a parser and printer for S-expressions represented as in the Sexp argument.

since
2.7
since
3.4 re-bind [loc] to [Sexp.loc]

Parameters

Signature

include CCSexp_intf.S0
type t
type sexp = t

Re-exports

val atom : string -> t

Make an atom out of this string.

since
2.8
val list : t list -> t

Make a Sexpr of this list.

since
2.8

Constructors

val of_int : int -> t
val of_bool : bool -> t
val of_list : t list -> t
val of_rev_list : t list -> t

Reverse the list.

val of_float : float -> t
val of_unit : t
val of_pair : (t * t) -> t
val of_triple : (t * t * t) -> t
val of_quad : (t * t * t * t) -> t
val of_variant : string -> t list -> t

of_variant name args is used to encode algebraic variants into a S-expr. For instance of_variant "some" [of_int 1] represents the value Some 1.

val of_field : string -> t -> t

Used to represent one record field.

val of_record : (string * t) list -> t

Represent a record by its named fields.

Printing

val to_buf : Stdlib.Buffer.t -> t -> unit
val to_string : t -> string
val to_file : string -> t -> unit
val to_file_iter : string -> t CCSexp_intf.iter -> unit

Print the given iter of expressions to a file.

val to_chan : Stdlib.out_channel -> t -> unit
val pp : Stdlib.Format.formatter -> t -> unit

Pretty-printer nice on human eyes (including indentation).

val pp_noindent : Stdlib.Format.formatter -> t -> unit

Raw, direct printing as compact as possible.

Parsing

val parse_string : string -> t CCSexp_intf.or_error

Parse a string.

val parse_string_list : string -> t list CCSexp_intf.or_error

Parse a string into a list of S-exprs.

since
2.8
val parse_chan : Stdlib.in_channel -> t CCSexp_intf.or_error

Parse a S-expression from the given channel. Can read more data than necessary, so don't use this if you need finer-grained control (e.g. to read something else after the S-exp).

val parse_chan_gen : Stdlib.in_channel -> t CCSexp_intf.or_error CCSexp_intf.gen

Parse a channel into a generator of S-expressions.

val parse_chan_list : Stdlib.in_channel -> t list CCSexp_intf.or_error
val parse_file : string -> t CCSexp_intf.or_error

Open the file and read a S-exp from it.

val parse_file_list : string -> t list CCSexp_intf.or_error

Open the file and read a S-exp from it.

type loc = Sexp.loc

Locations for the S-expressions.

since
3.3

Parsing

type 'a parse_result =
| Yield of 'a
| Fail of string
| End

A parser of 'a can return Yield x when it parsed a value, or Fail e when a parse error was encountered, or End if the input was empty.

module Decoder : sig ... end
\ No newline at end of file diff --git a/dev/containers/CCString/index.html b/dev/containers/CCString/index.html index 21d9a57c..3c1cca97 100644 --- a/dev/containers/CCString/index.html +++ b/dev/containers/CCString/index.html @@ -1,2 +1,2 @@ -CCString (containers.CCString)

Module CCString

Basic String Utils

type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

since
2.8
type 'a gen = unit -> 'a option

Documentation for the standard String module

include module type of sig ... end
type t = string
val make : int -> char -> string
val init : int -> (int -> char) -> string
val length : string -> int
val get : string -> int -> char
val concat : string -> string list -> string
val equal : t -> t -> bool
val compare : t -> t -> int
val contains_from : string -> int -> char -> bool
val rcontains_from : string -> int -> char -> bool
val contains : string -> char -> bool
val sub : string -> int -> int -> string
val split_on_char : char -> string -> string list
val map : (char -> char) -> string -> string
val mapi : (int -> char -> char) -> string -> string
val trim : string -> string
val escaped : string -> string
val uppercase_ascii : string -> string
val lowercase_ascii : string -> string
val capitalize_ascii : string -> string
val uncapitalize_ascii : string -> string
val iter : (char -> unit) -> string -> unit
val iteri : (int -> char -> unit) -> string -> unit
val index_from : string -> int -> char -> int
val index_from_opt : string -> int -> char -> int option
val rindex_from : string -> int -> char -> int
val rindex_from_opt : string -> int -> char -> int option
val index : string -> char -> int
val index_opt : string -> char -> int option
val rindex : string -> char -> int
val rindex_opt : string -> char -> int option
val to_seq : t -> char Stdlib.Seq.t
val to_seqi : t -> (int * char) Stdlib.Seq.t
val of_seq : char Stdlib.Seq.t -> t
val create : int -> bytes
val set : bytes -> int -> char -> unit
val blit : string -> int -> bytes -> int -> int -> unit
val copy : string -> string
val fill : bytes -> int -> int -> char -> unit
val uppercase : string -> string
val lowercase : string -> string
val capitalize : string -> string
val uncapitalize : string -> string
val unsafe_get : string -> int -> char
val unsafe_set : bytes -> int -> char -> unit
val unsafe_blit : string -> int -> bytes -> int -> int -> unit
val unsafe_fill : bytes -> int -> int -> char -> unit
val length : t -> int

length s returns the length (number of characters) of the given string s.

val blit : t -> int -> Stdlib.Bytes.t -> int -> int -> unit

blit src src_pos dst dst_pos len copies len characters from string src starting at character indice src_pos, to the Bytes sequence dst starting at character indice dst_pos. Like String.blit. Compatible with the -safe-string option.

raises Invalid_argument

if indices are not valid.

val fold : ('a -> char -> 'a) -> 'a -> t -> 'a

fold f init s folds on chars by increasing index. Computes f(… (f (f init s.[0]) s.[1]) …) s.[n-1].

since
0.7
val foldi : ('a -> int -> char -> 'a) -> 'a -> t -> 'a

foldi f init s is just like fold, but it also passes in the index of each chars as second argument to the folded function f.

since
3.3

Conversions

val to_gen : t -> char gen

to_gen s returns the gen of characters contained in the string s.

val to_iter : t -> char iter

to_iter s returns the iter of characters contained in the string s.

since
2.8
val to_seq : t -> char Stdlib.Seq.t

to_seq s returns the Seq.t of characters contained in the string s. Renamed from to std_seq since 3.0.

since
3.0
val to_list : t -> char list

to_list s returns the list of characters contained in the string s.

val pp_buf : Stdlib.Buffer.t -> t -> unit

pp_buf buf s prints s to the buffer buf. Renamed from pp since 2.0.

val pp : Stdlib.Format.formatter -> t -> unit

pp f s prints the string s within quotes to the formatter f. Renamed from print since 2.0.

val compare : string -> string -> int

compare s1 s2 compares the strings s1 and s2 and returns an integer that indicates their relative position in the sort order.

val is_empty : string -> bool

is_empty s returns true iff s is empty (i.e. its length is 0).

since
1.5
val hash : string -> int

hash s returns the hash value of s.

val rev : string -> string

rev s returns the reverse of s.

since
0.17
val pad : ?⁠side:[ `Left | `Right ] -> ?⁠c:char -> int -> string -> string

pad ~side ~c n s ensures that the string s is at least n bytes long, and pads it on the side with c if it's not the case.

parameter side

determines where padding occurs (default: `Left).

parameter c

the char used to pad (default: ' ').

since
0.17
val of_char : char -> string

of_char 'a' is "a".

since
0.19
val of_gen : char gen -> string

of_gen gen converts a gen of characters to a string.

val of_iter : char iter -> string

of_iter iter converts an iter of characters to a string.

since
2.8
val of_seq : char Stdlib.Seq.t -> string

of_seq seq converts a seq of characters to a string. Renamed from of_std_seq since 3.0.

since
3.0
val of_list : char list -> string

of_list lc converts a list of characters lc to a string.

val of_array : char array -> string

of_array ac converts an array of characters ac to a string.

val to_array : string -> char array

to_array s returns the array of characters contained in the string s.

val find : ?⁠start:int -> sub:string -> string -> int

find ~start ~sub s returns the starting index of the first occurrence of sub within s or -1.

parameter start

starting position in s.

val find_all : ?⁠start:int -> sub:string -> string -> int gen

find_all ~start ~sub s finds all occurrences of sub in s, even overlapping instances and returns them in a generator gen.

parameter start

starting position in s.

since
0.17
val find_all_l : ?⁠start:int -> sub:string -> string -> int list

find_all_l ~sub s finds all occurrences of sub in s and returns them in a list.

parameter start

starting position in s.

since
0.17
val mem : ?⁠start:int -> sub:string -> string -> bool

mem ~start ~sub s is true iff sub is a substring of s.

since
0.12
val rfind : sub:string -> string -> int

rfind ~sub s finds sub in string s from the right, returns its first index or -1. Should only be used with very small sub.

since
0.12
val replace : ?⁠which:[ `Left | `Right | `All ] -> sub:string -> by:string -> string -> string

replace ~which ~sub ~by s replaces some occurrences of sub by by in s.

parameter which

decides whether the occurrences to replace are:

  • `Left first occurrence from the left (beginning).
  • `Right first occurrence from the right (end).
  • `All all occurrences (default).
raises Invalid_argument

if sub = "".

since
0.14
val is_sub : sub:string -> int -> string -> int -> sub_len:int -> bool

is_sub ~sub ~sub_pos s ~pos ~sub_len returns true iff the substring of sub starting at position sub_pos and of length sub_len is a substring of s starting at position pos.

val repeat : string -> int -> string

repeat s n creates a string by repeating the string s n times.

val prefix : pre:string -> string -> bool

prefix ~pre s returns true iff pre is a prefix of s.

val suffix : suf:string -> string -> bool

suffix ~suf s returns true iff suf is a suffix of s.

since
0.7
val chop_prefix : pre:string -> string -> string option

chop_prefix ~pre s removes pre from s if pre really is a prefix of s, returns None otherwise.

since
0.17
val chop_suffix : suf:string -> string -> string option

chop_suffix ~suf s removes suf from s if suf really is a suffix of s, returns None otherwise.

since
0.17
val take : int -> string -> string

take n s keeps only the n first chars of s.

since
0.17
val drop : int -> string -> string

drop n s removes the n first chars of s.

since
0.17
val take_drop : int -> string -> string * string

take_drop n s is take n s, drop n s.

since
0.17
val lines : string -> string list

lines s returns a list of the lines of s (splits along '\n').

since
0.10
val lines_gen : string -> string gen

lines_gen s returns the gen of the lines of s (splits along '\n').

since
0.10
val lines_iter : string -> string iter

lines_iter s returns the iter of the lines of s (splits along '\n').

since
3.2
val lines_seq : string -> string Stdlib.Seq.t

lines_seq s returns the Seq.t of the lines of s (splits along '\n').

since
3.2
val concat_gen : sep:string -> string gen -> string

concat_gen ~sep gen concatenates all strings of gen, separated with sep.

since
0.10
val concat_seq : sep:string -> string Stdlib.Seq.t -> string

concat_seq ~sep seq concatenates all strings of seq, separated with sep.

since
3.2
val concat_iter : sep:string -> string iter -> string

concat_iter ~sep iter concatenates all strings of iter, separated with sep.

since
3.2
val unlines : string list -> string

unlines ls concatenates all strings of ls, separated with '\n'.

since
0.10
val unlines_gen : string gen -> string

unlines_gen gen concatenates all strings of gen, separated with '\n'.

since
0.10
val unlines_iter : string iter -> string

unlines_iter iter concatenates all strings of iter, separated with '\n'.

since
3.2
val unlines_seq : string Stdlib.Seq.t -> string

unlines_seq seq concatenates all strings of seq, separated with '\n'.

since
3.2
val set : string -> int -> char -> string

set s i c creates a new string which is a copy of s, except for index i, which becomes c.

raises Invalid_argument

if i is an invalid index.

since
0.12
val iter : (char -> unit) -> string -> unit

iter f s applies function f on each character of s. Alias to String.iter.

since
0.12
val filter_map : (char -> char option) -> string -> string

filter_map f s calls (f a0) (f a1) … (f an) where a0 … an are the characters of s. It returns the string of characters ci such as f ai = Some ci (when f returns None, the corresponding element of s is discarded).

since
0.17
val filter : (char -> bool) -> string -> string

filter f s discards characters of s not satisfying f.

since
0.17
val uniq : (char -> char -> bool) -> string -> string

uniq eq s remove consecutive duplicate characters in s.

since
NEXT_RELEASE
val flat_map : ?⁠sep:string -> (char -> string) -> string -> string

flat_map ~sep f s maps each chars of s to a string, then concatenates them all.

parameter sep

optional separator between each generated string.

since
0.12
val for_all : (char -> bool) -> string -> bool

for_all f s is true iff all characters of s satisfy the predicate f.

since
0.12
val exists : (char -> bool) -> string -> bool

exists f s is true iff some character of s satisfy the predicate f.

since
0.12
val drop_while : (char -> bool) -> t -> t

drop_while f s discards any characters of s starting from the left, up to the first character c not satisfying f c.

since
2.2
val rdrop_while : (char -> bool) -> t -> t

rdrop_while f s discards any characters of s starting from the right, up to the first character c not satisfying f c.

since
2.2
val ltrim : t -> t

ltrim s trims space on the left (see String.trim for more details).

since
1.2
val rtrim : t -> t

rtrim s trims space on the right (see String.trim for more details).

since
1.2

Operations on 2 strings

val map2 : (char -> char -> char) -> string -> string -> string

map2 f s1 s2 maps pairs of chars.

raises Invalid_argument

if the strings have not the same length.

since
0.12
val iter2 : (char -> char -> unit) -> string -> string -> unit

iter2 f s1 s2 iterates on pairs of chars.

raises Invalid_argument

if the strings have not the same length.

since
0.12
val iteri2 : (int -> char -> char -> unit) -> string -> string -> unit

iteri2 f s1 s2 iterates on pairs of chars with their index.

raises Invalid_argument

if the strings have not the same length.

since
0.12
val fold2 : ('a -> char -> char -> 'a) -> 'a -> string -> string -> 'a

fold2 f init s1 s2 folds on pairs of chars.

raises Invalid_argument

if the strings have not the same length.

since
0.12
val for_all2 : (char -> char -> bool) -> string -> string -> bool

for_all2 f s1 s2 returns true iff all pairs of chars satisfy the predicate f.

raises Invalid_argument

if the strings have not the same length.

since
0.12
val exists2 : (char -> char -> bool) -> string -> string -> bool

exists2 f s1 s2 returns true iff a pair of chars satisfy the predicate f.

raises Invalid_argument

if the strings have not the same length.

since
0.12

Ascii functions

Those functions are deprecated in String since 4.03, so we provide a stable alias for them even in older versions.

val equal_caseless : string -> string -> bool

equal_caseless s1 s2 compares s1 and s2 without respect to ascii lowercase.

since
1.2

Finding

A relatively efficient algorithm for finding sub-strings.

since
1.0
module Find : sig ... end

Splitting

module Split : sig ... end
val split_on_char : char -> string -> string list

split_on_char by s splits the string s along the given char by.

since
1.2
val split : by:string -> string -> string list

split ~by s splits the string s along the given string by. Alias to Split.list_cpy.

since
1.2

Utils

val compare_versions : string -> string -> int

compare_versions s1 s2 compares version strings s1 and s2, considering that numbers are above text.

since
0.13
val compare_natural : string -> string -> int

compare_natural s1 s2 is the Natural Sort Order, comparing chunks of digits as natural numbers. https://en.wikipedia.org/wiki/Natural_sort_order

since
1.3
val edit_distance : ?⁠cutoff:int -> string -> string -> int

edit_distance ~cutoff s1 s2 is the edition distance between the two strings s1 and s2. This satisfies the classical distance axioms: it is always positive, symmetric, and satisfies the formula distance s1 s2 + distance s2 s3 >= distance s1 s3.

parameter cutoff

if provided, it's a cap on the number of iterations. (since 3.0). This is useful if you just want to check whether the edit distance is less or equal than 2 without (use edit_distance s1 s2 ~cutoff:3 <= 2). note that contrary to what was previously documented here, the result can still be higher than cutoff if it's reached in <cutoff iterations. However if the result is < cutoff then it is accurate.

Infix operators

since
3.0
module Infix : sig ... end
include module type of Infix
val (=) : t -> t -> bool
since
3.0
val (<>) : t -> t -> bool
since
3.0
val (<) : t -> t -> bool
since
3.0
val (<=) : t -> t -> bool
since
3.0
val (>=) : t -> t -> bool
since
3.0
val (>) : t -> t -> bool
since
3.0
\ No newline at end of file +CCString (containers.CCString)

Module CCString

Basic String Utils

type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

since
2.8
type 'a gen = unit -> 'a option

Documentation for the standard String module

include module type of sig ... end
type t = string
val make : int -> char -> string
val init : int -> (int -> char) -> string
val length : string -> int
val get : string -> int -> char
val concat : string -> string list -> string
val equal : t -> t -> bool
val compare : t -> t -> int
val contains_from : string -> int -> char -> bool
val rcontains_from : string -> int -> char -> bool
val contains : string -> char -> bool
val sub : string -> int -> int -> string
val split_on_char : char -> string -> string list
val map : (char -> char) -> string -> string
val mapi : (int -> char -> char) -> string -> string
val trim : string -> string
val escaped : string -> string
val uppercase_ascii : string -> string
val lowercase_ascii : string -> string
val capitalize_ascii : string -> string
val uncapitalize_ascii : string -> string
val iter : (char -> unit) -> string -> unit
val iteri : (int -> char -> unit) -> string -> unit
val index_from : string -> int -> char -> int
val index_from_opt : string -> int -> char -> int option
val rindex_from : string -> int -> char -> int
val rindex_from_opt : string -> int -> char -> int option
val index : string -> char -> int
val index_opt : string -> char -> int option
val rindex : string -> char -> int
val rindex_opt : string -> char -> int option
val to_seq : t -> char Stdlib.Seq.t
val to_seqi : t -> (int * char) Stdlib.Seq.t
val of_seq : char Stdlib.Seq.t -> t
val create : int -> bytes
val set : bytes -> int -> char -> unit
val blit : string -> int -> bytes -> int -> int -> unit
val copy : string -> string
val fill : bytes -> int -> int -> char -> unit
val uppercase : string -> string
val lowercase : string -> string
val capitalize : string -> string
val uncapitalize : string -> string
val unsafe_get : string -> int -> char
val unsafe_set : bytes -> int -> char -> unit
val unsafe_blit : string -> int -> bytes -> int -> int -> unit
val unsafe_fill : bytes -> int -> int -> char -> unit
val length : t -> int

length s returns the length (number of characters) of the given string s.

val blit : t -> int -> Stdlib.Bytes.t -> int -> int -> unit

blit src src_pos dst dst_pos len copies len characters from string src starting at character indice src_pos, to the Bytes sequence dst starting at character indice dst_pos. Like String.blit. Compatible with the -safe-string option.

raises Invalid_argument

if indices are not valid.

val fold : ('a -> char -> 'a) -> 'a -> t -> 'a

fold f init s folds on chars by increasing index. Computes f(… (f (f init s.[0]) s.[1]) …) s.[n-1].

since
0.7
val foldi : ('a -> int -> char -> 'a) -> 'a -> t -> 'a

foldi f init s is just like fold, but it also passes in the index of each chars as second argument to the folded function f.

since
3.3

Conversions

val to_gen : t -> char gen

to_gen s returns the gen of characters contained in the string s.

val to_iter : t -> char iter

to_iter s returns the iter of characters contained in the string s.

since
2.8
val to_seq : t -> char Stdlib.Seq.t

to_seq s returns the Seq.t of characters contained in the string s. Renamed from to std_seq since 3.0.

since
3.0
val to_list : t -> char list

to_list s returns the list of characters contained in the string s.

val pp_buf : Stdlib.Buffer.t -> t -> unit

pp_buf buf s prints s to the buffer buf. Renamed from pp since 2.0.

val pp : Stdlib.Format.formatter -> t -> unit

pp f s prints the string s within quotes to the formatter f. Renamed from print since 2.0.

val compare : string -> string -> int

compare s1 s2 compares the strings s1 and s2 and returns an integer that indicates their relative position in the sort order.

val is_empty : string -> bool

is_empty s returns true iff s is empty (i.e. its length is 0).

since
1.5
val hash : string -> int

hash s returns the hash value of s.

val rev : string -> string

rev s returns the reverse of s.

since
0.17
val pad : ?⁠side:[ `Left | `Right ] -> ?⁠c:char -> int -> string -> string

pad ~side ~c n s ensures that the string s is at least n bytes long, and pads it on the side with c if it's not the case.

parameter side

determines where padding occurs (default: `Left).

parameter c

the char used to pad (default: ' ').

since
0.17
val of_char : char -> string

of_char 'a' is "a".

since
0.19
val of_gen : char gen -> string

of_gen gen converts a gen of characters to a string.

val of_iter : char iter -> string

of_iter iter converts an iter of characters to a string.

since
2.8
val of_seq : char Stdlib.Seq.t -> string

of_seq seq converts a seq of characters to a string. Renamed from of_std_seq since 3.0.

since
3.0
val of_list : char list -> string

of_list lc converts a list of characters lc to a string.

val of_array : char array -> string

of_array ac converts an array of characters ac to a string.

val to_array : string -> char array

to_array s returns the array of characters contained in the string s.

val find : ?⁠start:int -> sub:string -> string -> int

find ~start ~sub s returns the starting index of the first occurrence of sub within s or -1.

parameter start

starting position in s.

val find_all : ?⁠start:int -> sub:string -> string -> int gen

find_all ~start ~sub s finds all occurrences of sub in s, even overlapping instances and returns them in a generator gen.

parameter start

starting position in s.

since
0.17
val find_all_l : ?⁠start:int -> sub:string -> string -> int list

find_all_l ~sub s finds all occurrences of sub in s and returns them in a list.

parameter start

starting position in s.

since
0.17
val mem : ?⁠start:int -> sub:string -> string -> bool

mem ~start ~sub s is true iff sub is a substring of s.

since
0.12
val rfind : sub:string -> string -> int

rfind ~sub s finds sub in string s from the right, returns its first index or -1. Should only be used with very small sub.

since
0.12
val replace : ?⁠which:[ `Left | `Right | `All ] -> sub:string -> by:string -> string -> string

replace ~which ~sub ~by s replaces some occurrences of sub by by in s.

parameter which

decides whether the occurrences to replace are:

  • `Left first occurrence from the left (beginning).
  • `Right first occurrence from the right (end).
  • `All all occurrences (default).
raises Invalid_argument

if sub = "".

since
0.14
val is_sub : sub:string -> int -> string -> int -> sub_len:int -> bool

is_sub ~sub ~sub_pos s ~pos ~sub_len returns true iff the substring of sub starting at position sub_pos and of length sub_len is a substring of s starting at position pos.

val repeat : string -> int -> string

repeat s n creates a string by repeating the string s n times.

val prefix : pre:string -> string -> bool

prefix ~pre s returns true iff pre is a prefix of s.

val suffix : suf:string -> string -> bool

suffix ~suf s returns true iff suf is a suffix of s.

since
0.7
val chop_prefix : pre:string -> string -> string option

chop_prefix ~pre s removes pre from s if pre really is a prefix of s, returns None otherwise.

since
0.17
val chop_suffix : suf:string -> string -> string option

chop_suffix ~suf s removes suf from s if suf really is a suffix of s, returns None otherwise.

since
0.17
val take : int -> string -> string

take n s keeps only the n first chars of s.

since
0.17
val drop : int -> string -> string

drop n s removes the n first chars of s.

since
0.17
val take_drop : int -> string -> string * string

take_drop n s is take n s, drop n s.

since
0.17
val lines : string -> string list

lines s returns a list of the lines of s (splits along '\n').

since
0.10
val lines_gen : string -> string gen

lines_gen s returns the gen of the lines of s (splits along '\n').

since
0.10
val lines_iter : string -> string iter

lines_iter s returns the iter of the lines of s (splits along '\n').

since
3.2
val lines_seq : string -> string Stdlib.Seq.t

lines_seq s returns the Seq.t of the lines of s (splits along '\n').

since
3.2
val concat_gen : sep:string -> string gen -> string

concat_gen ~sep gen concatenates all strings of gen, separated with sep.

since
0.10
val concat_seq : sep:string -> string Stdlib.Seq.t -> string

concat_seq ~sep seq concatenates all strings of seq, separated with sep.

since
3.2
val concat_iter : sep:string -> string iter -> string

concat_iter ~sep iter concatenates all strings of iter, separated with sep.

since
3.2
val unlines : string list -> string

unlines ls concatenates all strings of ls, separated with '\n'.

since
0.10
val unlines_gen : string gen -> string

unlines_gen gen concatenates all strings of gen, separated with '\n'.

since
0.10
val unlines_iter : string iter -> string

unlines_iter iter concatenates all strings of iter, separated with '\n'.

since
3.2
val unlines_seq : string Stdlib.Seq.t -> string

unlines_seq seq concatenates all strings of seq, separated with '\n'.

since
3.2
val set : string -> int -> char -> string

set s i c creates a new string which is a copy of s, except for index i, which becomes c.

raises Invalid_argument

if i is an invalid index.

since
0.12
val iter : (char -> unit) -> string -> unit

iter f s applies function f on each character of s. Alias to String.iter.

since
0.12
val filter_map : (char -> char option) -> string -> string

filter_map f s calls (f a0) (f a1) … (f an) where a0 … an are the characters of s. It returns the string of characters ci such as f ai = Some ci (when f returns None, the corresponding element of s is discarded).

since
0.17
val filter : (char -> bool) -> string -> string

filter f s discards characters of s not satisfying f.

since
0.17
val uniq : (char -> char -> bool) -> string -> string

uniq eq s remove consecutive duplicate characters in s.

since
3.4
val flat_map : ?⁠sep:string -> (char -> string) -> string -> string

flat_map ~sep f s maps each chars of s to a string, then concatenates them all.

parameter sep

optional separator between each generated string.

since
0.12
val for_all : (char -> bool) -> string -> bool

for_all f s is true iff all characters of s satisfy the predicate f.

since
0.12
val exists : (char -> bool) -> string -> bool

exists f s is true iff some character of s satisfy the predicate f.

since
0.12
val drop_while : (char -> bool) -> t -> t

drop_while f s discards any characters of s starting from the left, up to the first character c not satisfying f c.

since
2.2
val rdrop_while : (char -> bool) -> t -> t

rdrop_while f s discards any characters of s starting from the right, up to the first character c not satisfying f c.

since
2.2
val ltrim : t -> t

ltrim s trims space on the left (see String.trim for more details).

since
1.2
val rtrim : t -> t

rtrim s trims space on the right (see String.trim for more details).

since
1.2

Operations on 2 strings

val map2 : (char -> char -> char) -> string -> string -> string

map2 f s1 s2 maps pairs of chars.

raises Invalid_argument

if the strings have not the same length.

since
0.12
val iter2 : (char -> char -> unit) -> string -> string -> unit

iter2 f s1 s2 iterates on pairs of chars.

raises Invalid_argument

if the strings have not the same length.

since
0.12
val iteri2 : (int -> char -> char -> unit) -> string -> string -> unit

iteri2 f s1 s2 iterates on pairs of chars with their index.

raises Invalid_argument

if the strings have not the same length.

since
0.12
val fold2 : ('a -> char -> char -> 'a) -> 'a -> string -> string -> 'a

fold2 f init s1 s2 folds on pairs of chars.

raises Invalid_argument

if the strings have not the same length.

since
0.12
val for_all2 : (char -> char -> bool) -> string -> string -> bool

for_all2 f s1 s2 returns true iff all pairs of chars satisfy the predicate f.

raises Invalid_argument

if the strings have not the same length.

since
0.12
val exists2 : (char -> char -> bool) -> string -> string -> bool

exists2 f s1 s2 returns true iff a pair of chars satisfy the predicate f.

raises Invalid_argument

if the strings have not the same length.

since
0.12

Ascii functions

Those functions are deprecated in String since 4.03, so we provide a stable alias for them even in older versions.

val equal_caseless : string -> string -> bool

equal_caseless s1 s2 compares s1 and s2 without respect to ascii lowercase.

since
1.2

Finding

A relatively efficient algorithm for finding sub-strings.

since
1.0
module Find : sig ... end

Splitting

module Split : sig ... end
val split_on_char : char -> string -> string list

split_on_char by s splits the string s along the given char by.

since
1.2
val split : by:string -> string -> string list

split ~by s splits the string s along the given string by. Alias to Split.list_cpy.

since
1.2

Utils

val compare_versions : string -> string -> int

compare_versions s1 s2 compares version strings s1 and s2, considering that numbers are above text.

since
0.13
val compare_natural : string -> string -> int

compare_natural s1 s2 is the Natural Sort Order, comparing chunks of digits as natural numbers. https://en.wikipedia.org/wiki/Natural_sort_order

since
1.3
val edit_distance : ?⁠cutoff:int -> string -> string -> int

edit_distance ~cutoff s1 s2 is the edition distance between the two strings s1 and s2. This satisfies the classical distance axioms: it is always positive, symmetric, and satisfies the formula distance s1 s2 + distance s2 s3 >= distance s1 s3.

parameter cutoff

if provided, it's a cap on the number of iterations. (since 3.0). This is useful if you just want to check whether the edit distance is less or equal than 2 without (use edit_distance s1 s2 ~cutoff:3 <= 2). note that contrary to what was previously documented here, the result can still be higher than cutoff if it's reached in <cutoff iterations. However if the result is < cutoff then it is accurate.

Infix operators

since
3.0
module Infix : sig ... end
include module type of Infix
val (=) : t -> t -> bool
since
3.0
val (<>) : t -> t -> bool
since
3.0
val (<) : t -> t -> bool
since
3.0
val (<=) : t -> t -> bool
since
3.0
val (>=) : t -> t -> bool
since
3.0
val (>) : t -> t -> bool
since
3.0
\ No newline at end of file diff --git a/dev/containers/CCStringLabels/index.html b/dev/containers/CCStringLabels/index.html index 105c5d7e..c19cb643 100644 --- a/dev/containers/CCStringLabels/index.html +++ b/dev/containers/CCStringLabels/index.html @@ -1,2 +1,2 @@ -CCStringLabels (containers.CCStringLabels)

Module CCStringLabels

Basic String Utils

type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

since
2.8
type 'a gen = unit -> 'a option

Documentation for the standard StringLabels module

include module type of sig ... end
type t = string
val make : int -> char -> string
val init : int -> f:(int -> char) -> string
val length : string -> int
val get : string -> int -> char
val concat : sep:string -> string list -> string
val equal : t -> t -> bool
val compare : t -> t -> int
val contains_from : string -> int -> char -> bool
val rcontains_from : string -> int -> char -> bool
val contains : string -> char -> bool
val sub : string -> pos:int -> len:int -> string
val split_on_char : sep:char -> string -> string list
val map : f:(char -> char) -> string -> string
val mapi : f:(int -> char -> char) -> string -> string
val trim : string -> string
val escaped : string -> string
val uppercase_ascii : string -> string
val lowercase_ascii : string -> string
val capitalize_ascii : string -> string
val uncapitalize_ascii : string -> string
val iter : f:(char -> unit) -> string -> unit
val iteri : f:(int -> char -> unit) -> string -> unit
val index_from : string -> int -> char -> int
val index_from_opt : string -> int -> char -> int option
val rindex_from : string -> int -> char -> int
val rindex_from_opt : string -> int -> char -> int option
val index : string -> char -> int
val index_opt : string -> char -> int option
val rindex : string -> char -> int
val rindex_opt : string -> char -> int option
val to_seq : t -> char Stdlib.Seq.t
val to_seqi : t -> (int * char) Stdlib.Seq.t
val of_seq : char Stdlib.Seq.t -> t
val create : int -> bytes
val set : bytes -> int -> char -> unit
val blit : src:string -> src_pos:int -> dst:bytes -> dst_pos:int -> len:int -> unit
val copy : string -> string
val fill : bytes -> pos:int -> len:int -> char -> unit
val uppercase : string -> string
val lowercase : string -> string
val capitalize : string -> string
val uncapitalize : string -> string
val unsafe_get : string -> int -> char
val unsafe_set : bytes -> int -> char -> unit
val unsafe_blit : src:string -> src_pos:int -> dst:bytes -> dst_pos:int -> len:int -> unit
val unsafe_fill : bytes -> pos:int -> len:int -> char -> unit
val length : t -> int

length s returns the length (number of characters) of the given string s.

val blit : src:t -> src_pos:int -> dst:Stdlib.Bytes.t -> dst_pos:int -> len:int -> unit

blit ~src ~src_pos ~dst ~dst_pos ~len copies len characters from string src starting at character indice src_pos, to the Bytes sequence dst starting at character indice dst_pos. Like String.blit. Compatible with the -safe-string option.

raises Invalid_argument

if indices are not valid.

val fold : f:('a -> char -> 'a) -> init:'a -> t -> 'a

fold ~f ~init s folds on chars by increasing index. Computes f(… (f (f init s.[0]) s.[1]) …) s.[n-1].

since
0.7
val foldi : f:('a -> int -> char -> 'a) -> 'a -> t -> 'a

foldi ~f init s is just like fold, but it also passes in the index of each chars as second argument to the folded function f.

since
3.3

Conversions

val to_gen : t -> char gen

to_gen s returns the gen of characters contained in the string s.

val to_iter : t -> char iter

to_iter s returns the iter of characters contained in the string s.

since
2.8
val to_seq : t -> char Stdlib.Seq.t

to_seq s returns the Seq.t of characters contained in the string s. Renamed from to std_seq since 3.0.

since
3.0
val to_list : t -> char list

to_list s returns the list of characters contained in the string s.

val pp_buf : Stdlib.Buffer.t -> t -> unit

pp_buf buf s prints s to the buffer buf. Renamed from pp since 2.0.

val pp : Stdlib.Format.formatter -> t -> unit

pp f s prints the string s within quotes to the formatter f. Renamed from print since 2.0.

Strings

val equal : string -> string -> bool

equal s1 s2 returns true iff the strings s1 and s2 are equal.

val compare : string -> string -> int

compare s1 s2 compares the strings s1 and s2 and returns an integer that indicates their relative position in the sort order.

val is_empty : string -> bool

is_empty s returns true iff s is empty (i.e. its length is 0).

since
1.5
val hash : string -> int

hash s returns the hash value of s.

val rev : string -> string

rev s returns the reverse of s.

since
0.17
val pad : ?⁠side:[ `Left | `Right ] -> ?⁠c:char -> int -> string -> string

pad ?side ?c n s ensures that the string s is at least n bytes long, and pads it on the side with c if it's not the case.

parameter side

determines where padding occurs (default: `Left).

parameter c

the char used to pad (default: ' ').

since
0.17
val of_char : char -> string

of_char 'a' is "a".

since
0.19
val of_gen : char gen -> string

of_gen gen converts a gen of characters to a string.

val of_iter : char iter -> string

of_iter iter converts an iter of characters to a string.

since
2.8
val of_seq : char Stdlib.Seq.t -> string

of_seq seq converts a seq of characters to a string. Renamed from of_std_seq since 3.0.

since
3.0
val of_list : char list -> string

of_list lc converts a list of characters lc to a string.

val of_array : char array -> string

of_array ac converts an array of characters ac to a string.

val to_array : string -> char array

to_array s returns the array of characters contained in the string s.

val find : ?⁠start:int -> sub:string -> string -> int

find ?start ~sub s returns the starting index of the first occurrence of sub within s or -1.

parameter start

starting position in s.

val find_all : ?⁠start:int -> sub:string -> string -> int gen

find_all ?start ~sub s finds all occurrences of sub in s, even overlapping instances and returns them in a generator gen.

parameter start

starting position in s.

since
0.17
val find_all_l : ?⁠start:int -> sub:string -> string -> int list

find_all_l ?start ~sub s finds all occurrences of sub in s and returns them in a list.

parameter start

starting position in s.

since
0.17
val mem : ?⁠start:int -> sub:string -> string -> bool

mem ?start ~sub s is true iff sub is a substring of s.

since
0.12
val rfind : sub:string -> string -> int

rfind ~sub s finds sub in string s from the right, returns its first index or -1. Should only be used with very small sub.

since
0.12
val replace : ?⁠which:[ `Left | `Right | `All ] -> sub:string -> by:string -> string -> string

replace ?which ~sub ~by s replaces some occurrences of sub by by in s.

parameter which

decides whether the occurrences to replace are:

  • `Left first occurrence from the left (beginning).
  • `Right first occurrence from the right (end).
  • `All all occurrences (default).
raises Invalid_argument

if sub = "".

since
0.14
val is_sub : sub:string -> sub_pos:int -> string -> pos:int -> sub_len:int -> bool

is_sub ~sub ~sub_pos s ~pos ~sub_len returns true iff the substring of sub starting at position sub_pos and of length sub_len is a substring of s starting at position pos.

val repeat : string -> int -> string

repeat s n creates a string by repeating the string s n times.

val prefix : pre:string -> string -> bool

prefix ~pre s returns true iff pre is a prefix of s.

val suffix : suf:string -> string -> bool

suffix ~suf s returns true iff suf is a suffix of s.

since
0.7
val chop_prefix : pre:string -> string -> string option

chop_prefix ~pre s removes pre from s if pre really is a prefix of s, returns None otherwise.

since
0.17
val chop_suffix : suf:string -> string -> string option

chop_suffix ~suf s removes suf from s if suf really is a suffix of s, returns None otherwise.

since
0.17
val take : int -> string -> string

take n s keeps only the n first chars of s.

since
0.17
val drop : int -> string -> string

drop n s removes the n first chars of s.

since
0.17
val take_drop : int -> string -> string * string

take_drop n s is take n s, drop n s.

since
0.17
val lines : string -> string list

lines s returns a list of the lines of s (splits along '\n').

since
0.10
val lines_gen : string -> string gen

lines_gen s returns a generator gen of the lines of s (splits along '\n').

since
0.10
val lines_iter : string -> string iter

lines_iter s returns the iter of the lines of s (splits along '\n').

since
3.2
val lines_seq : string -> string Stdlib.Seq.t

lines_seq s returns the Seq.t of the lines of s (splits along '\n').

since
3.2
val concat_iter : sep:string -> string iter -> string

concat_iter ~sep iter concatenates all strings of iter, separated with sep.

since
3.2
val concat_gen : sep:string -> string gen -> string

concat_gen ~sep gen concatenates all strings of gen, separated with sep.

since
0.10
val concat_seq : sep:string -> string Stdlib.Seq.t -> string

concat_seq ~sep seq concatenates all strings of seq, separated with sep.

since
3.2
val unlines : string list -> string

unlines ls concatenates all strings of ls, separated with '\n'.

since
0.10
val unlines_gen : string gen -> string

unlines_gen gen concatenates all strings of gen, separated with '\n'.

since
0.10
val unlines_iter : string iter -> string

unlines_iter iter concatenates all strings of iter, separated with '\n'.

since
3.2
val unlines_seq : string Stdlib.Seq.t -> string

unlines_seq seq concatenates all strings of seq, separated with '\n'.

since
3.2
val set : string -> int -> char -> string

set s i c creates a new string which is a copy of s, except for index i, which becomes c.

raises Invalid_argument

if i is an invalid index.

since
0.12
val iter : f:(char -> unit) -> string -> unit

iter ~f s applies function f on each character of s. Alias to String.iter.

since
0.12
val filter_map : f:(char -> char option) -> string -> string

filter_map ~f s calls (f a0) (f a1) … (f an) where a0 … an are the characters of s. It returns the string of characters ci such as f ai = Some ci (when f returns None, the corresponding element of s is discarded).

since
0.17
val filter : f:(char -> bool) -> string -> string

filter ~f s discards characters of s not satisfying f.

since
0.17
val uniq : eq:(char -> char -> bool) -> string -> string

uniq ~eq s remove consecutive duplicate characters in s.

since
NEXT_RELEASE
val flat_map : ?⁠sep:string -> f:(char -> string) -> string -> string

flat_map ?sep ~f s maps each chars of s to a string, then concatenates them all.

parameter sep

optional separator between each generated string.

since
0.12
val for_all : f:(char -> bool) -> string -> bool

for_all ~f s is true iff all characters of s satisfy the predicate f.

since
0.12
val exists : f:(char -> bool) -> string -> bool

exists ~f s is true iff some character of s satisfy the predicate f.

since
0.12
val drop_while : f:(char -> bool) -> t -> t

drop_while ~f s discards any characters of s starting from the left, up to the first character c not satisfying f c.

since
2.2
val rdrop_while : f:(char -> bool) -> t -> t

rdrop_while ~f s discards any characters of s starting from the right, up to the first character c not satisfying f c.

since
2.2
val ltrim : t -> t

ltrim s trims space on the left (see String.trim for more details).

since
1.2
val rtrim : t -> t

rtrim s trims space on the right (see String.trim for more details).

since
1.2

Operations on 2 strings

val map2 : f:(char -> char -> char) -> string -> string -> string

map2 ~f s1 s2 maps pairs of chars.

raises Invalid_argument

if the strings have not the same length.

since
0.12
val iter2 : f:(char -> char -> unit) -> string -> string -> unit

iter2 ~f s1 s2 iterates on pairs of chars.

raises Invalid_argument

if the strings have not the same length.

since
0.12
val iteri2 : f:(int -> char -> char -> unit) -> string -> string -> unit

iteri2 ~f s1 s2 iterates on pairs of chars with their index.

raises Invalid_argument

if the strings have not the same length.

since
0.12
val fold2 : f:('a -> char -> char -> 'a) -> init:'a -> string -> string -> 'a

fold2 ~f ~init s1 s2 folds on pairs of chars.

raises Invalid_argument

if the strings have not the same length.

since
0.12
val for_all2 : f:(char -> char -> bool) -> string -> string -> bool

for_all2 ~f s1 s2 returns true iff all pairs of chars satisfy the predicate f.

raises Invalid_argument

if the strings have not the same length.

since
0.12
val exists2 : f:(char -> char -> bool) -> string -> string -> bool

exists2 ~f s1 s2 returns true iff a pair of chars satisfy the predicate f.

raises Invalid_argument

if the strings have not the same length.

since
0.12

Ascii functions

Those functions are deprecated in String since 4.03, so we provide a stable alias for them even in older versions.

val capitalize_ascii : string -> string

capitalize_ascii s returns a copy of s with the first character set to uppercase using the US-ASCII character set. See String.

since
0.18
val uncapitalize_ascii : string -> string

uncapitalize_ascii s returns a copy of s with the first character set to lowercase using the US-ASCII character set. See String.

since
0.18
val uppercase_ascii : string -> string

uppercase_ascii s returns a copy of s with all lowercase letters translated to uppercase using the US-ASCII character set. See String.

since
0.18
val lowercase_ascii : string -> string

lowercase_ascii s returns a copy of s with all uppercase letters translated to lowercase using the US-ASCII character set. See String.

since
0.18
val equal_caseless : string -> string -> bool

equal_caseless s1 s2 compares s1 and s2 without respect to ascii lowercase.

since
1.2

Finding

A relatively efficient algorithm for finding sub-strings.

since
1.0
module Find : sig ... end

Splitting

module Split : sig ... end
val split_on_char : by:char -> string -> string list

split_on_char ~by s splits the string s along the given char by.

since
1.2
val split : by:string -> string -> string list

split ~by s splits the string s along the given string by. Alias to Split.list_cpy.

since
1.2

Utils

val compare_versions : string -> string -> int

compare_versions s1 s2 compares version strings s1 and s2, considering that numbers are above text.

since
0.13
val compare_natural : string -> string -> int

compare_natural s1 s2 is the Natural Sort Order, comparing chunks of digits as natural numbers. https://en.wikipedia.org/wiki/Natural_sort_order

since
1.3
val edit_distance : ?⁠cutoff:int -> string -> string -> int

edit_distance ?cutoff s1 s2 is the edition distance between the two strings s1 and s2. This satisfies the classical distance axioms: it is always positive, symmetric, and satisfies the formula distance s1 s2 + distance s2 s3 >= distance s1 s3.

parameter cutoff

if provided, it's a cap on both the number of iterations, and on the result. (since 3.0). This is useful if you just want to check whether the edit distance is less or equal than 2 (use cutoff of 3).

Infix operators

since
3.0
module Infix : sig ... end
include module type of Infix
val (=) : t -> t -> bool
since
3.0
val (<>) : t -> t -> bool
since
3.0
val (<) : t -> t -> bool
since
3.0
val (<=) : t -> t -> bool
since
3.0
val (>=) : t -> t -> bool
since
3.0
val (>) : t -> t -> bool
since
3.0
\ No newline at end of file +CCStringLabels (containers.CCStringLabels)

Module CCStringLabels

Basic String Utils

type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

since
2.8
type 'a gen = unit -> 'a option

Documentation for the standard StringLabels module

include module type of sig ... end
type t = string
val make : int -> char -> string
val init : int -> f:(int -> char) -> string
val length : string -> int
val get : string -> int -> char
val concat : sep:string -> string list -> string
val equal : t -> t -> bool
val compare : t -> t -> int
val contains_from : string -> int -> char -> bool
val rcontains_from : string -> int -> char -> bool
val contains : string -> char -> bool
val sub : string -> pos:int -> len:int -> string
val split_on_char : sep:char -> string -> string list
val map : f:(char -> char) -> string -> string
val mapi : f:(int -> char -> char) -> string -> string
val trim : string -> string
val escaped : string -> string
val uppercase_ascii : string -> string
val lowercase_ascii : string -> string
val capitalize_ascii : string -> string
val uncapitalize_ascii : string -> string
val iter : f:(char -> unit) -> string -> unit
val iteri : f:(int -> char -> unit) -> string -> unit
val index_from : string -> int -> char -> int
val index_from_opt : string -> int -> char -> int option
val rindex_from : string -> int -> char -> int
val rindex_from_opt : string -> int -> char -> int option
val index : string -> char -> int
val index_opt : string -> char -> int option
val rindex : string -> char -> int
val rindex_opt : string -> char -> int option
val to_seq : t -> char Stdlib.Seq.t
val to_seqi : t -> (int * char) Stdlib.Seq.t
val of_seq : char Stdlib.Seq.t -> t
val create : int -> bytes
val set : bytes -> int -> char -> unit
val blit : src:string -> src_pos:int -> dst:bytes -> dst_pos:int -> len:int -> unit
val copy : string -> string
val fill : bytes -> pos:int -> len:int -> char -> unit
val uppercase : string -> string
val lowercase : string -> string
val capitalize : string -> string
val uncapitalize : string -> string
val unsafe_get : string -> int -> char
val unsafe_set : bytes -> int -> char -> unit
val unsafe_blit : src:string -> src_pos:int -> dst:bytes -> dst_pos:int -> len:int -> unit
val unsafe_fill : bytes -> pos:int -> len:int -> char -> unit
val length : t -> int

length s returns the length (number of characters) of the given string s.

val blit : src:t -> src_pos:int -> dst:Stdlib.Bytes.t -> dst_pos:int -> len:int -> unit

blit ~src ~src_pos ~dst ~dst_pos ~len copies len characters from string src starting at character indice src_pos, to the Bytes sequence dst starting at character indice dst_pos. Like String.blit. Compatible with the -safe-string option.

raises Invalid_argument

if indices are not valid.

val fold : f:('a -> char -> 'a) -> init:'a -> t -> 'a

fold ~f ~init s folds on chars by increasing index. Computes f(… (f (f init s.[0]) s.[1]) …) s.[n-1].

since
0.7
val foldi : f:('a -> int -> char -> 'a) -> 'a -> t -> 'a

foldi ~f init s is just like fold, but it also passes in the index of each chars as second argument to the folded function f.

since
3.3

Conversions

val to_gen : t -> char gen

to_gen s returns the gen of characters contained in the string s.

val to_iter : t -> char iter

to_iter s returns the iter of characters contained in the string s.

since
2.8
val to_seq : t -> char Stdlib.Seq.t

to_seq s returns the Seq.t of characters contained in the string s. Renamed from to std_seq since 3.0.

since
3.0
val to_list : t -> char list

to_list s returns the list of characters contained in the string s.

val pp_buf : Stdlib.Buffer.t -> t -> unit

pp_buf buf s prints s to the buffer buf. Renamed from pp since 2.0.

val pp : Stdlib.Format.formatter -> t -> unit

pp f s prints the string s within quotes to the formatter f. Renamed from print since 2.0.

Strings

val equal : string -> string -> bool

equal s1 s2 returns true iff the strings s1 and s2 are equal.

val compare : string -> string -> int

compare s1 s2 compares the strings s1 and s2 and returns an integer that indicates their relative position in the sort order.

val is_empty : string -> bool

is_empty s returns true iff s is empty (i.e. its length is 0).

since
1.5
val hash : string -> int

hash s returns the hash value of s.

val rev : string -> string

rev s returns the reverse of s.

since
0.17
val pad : ?⁠side:[ `Left | `Right ] -> ?⁠c:char -> int -> string -> string

pad ?side ?c n s ensures that the string s is at least n bytes long, and pads it on the side with c if it's not the case.

parameter side

determines where padding occurs (default: `Left).

parameter c

the char used to pad (default: ' ').

since
0.17
val of_char : char -> string

of_char 'a' is "a".

since
0.19
val of_gen : char gen -> string

of_gen gen converts a gen of characters to a string.

val of_iter : char iter -> string

of_iter iter converts an iter of characters to a string.

since
2.8
val of_seq : char Stdlib.Seq.t -> string

of_seq seq converts a seq of characters to a string. Renamed from of_std_seq since 3.0.

since
3.0
val of_list : char list -> string

of_list lc converts a list of characters lc to a string.

val of_array : char array -> string

of_array ac converts an array of characters ac to a string.

val to_array : string -> char array

to_array s returns the array of characters contained in the string s.

val find : ?⁠start:int -> sub:string -> string -> int

find ?start ~sub s returns the starting index of the first occurrence of sub within s or -1.

parameter start

starting position in s.

val find_all : ?⁠start:int -> sub:string -> string -> int gen

find_all ?start ~sub s finds all occurrences of sub in s, even overlapping instances and returns them in a generator gen.

parameter start

starting position in s.

since
0.17
val find_all_l : ?⁠start:int -> sub:string -> string -> int list

find_all_l ?start ~sub s finds all occurrences of sub in s and returns them in a list.

parameter start

starting position in s.

since
0.17
val mem : ?⁠start:int -> sub:string -> string -> bool

mem ?start ~sub s is true iff sub is a substring of s.

since
0.12
val rfind : sub:string -> string -> int

rfind ~sub s finds sub in string s from the right, returns its first index or -1. Should only be used with very small sub.

since
0.12
val replace : ?⁠which:[ `Left | `Right | `All ] -> sub:string -> by:string -> string -> string

replace ?which ~sub ~by s replaces some occurrences of sub by by in s.

parameter which

decides whether the occurrences to replace are:

  • `Left first occurrence from the left (beginning).
  • `Right first occurrence from the right (end).
  • `All all occurrences (default).
raises Invalid_argument

if sub = "".

since
0.14
val is_sub : sub:string -> sub_pos:int -> string -> pos:int -> sub_len:int -> bool

is_sub ~sub ~sub_pos s ~pos ~sub_len returns true iff the substring of sub starting at position sub_pos and of length sub_len is a substring of s starting at position pos.

val repeat : string -> int -> string

repeat s n creates a string by repeating the string s n times.

val prefix : pre:string -> string -> bool

prefix ~pre s returns true iff pre is a prefix of s.

val suffix : suf:string -> string -> bool

suffix ~suf s returns true iff suf is a suffix of s.

since
0.7
val chop_prefix : pre:string -> string -> string option

chop_prefix ~pre s removes pre from s if pre really is a prefix of s, returns None otherwise.

since
0.17
val chop_suffix : suf:string -> string -> string option

chop_suffix ~suf s removes suf from s if suf really is a suffix of s, returns None otherwise.

since
0.17
val take : int -> string -> string

take n s keeps only the n first chars of s.

since
0.17
val drop : int -> string -> string

drop n s removes the n first chars of s.

since
0.17
val take_drop : int -> string -> string * string

take_drop n s is take n s, drop n s.

since
0.17
val lines : string -> string list

lines s returns a list of the lines of s (splits along '\n').

since
0.10
val lines_gen : string -> string gen

lines_gen s returns a generator gen of the lines of s (splits along '\n').

since
0.10
val lines_iter : string -> string iter

lines_iter s returns the iter of the lines of s (splits along '\n').

since
3.2
val lines_seq : string -> string Stdlib.Seq.t

lines_seq s returns the Seq.t of the lines of s (splits along '\n').

since
3.2
val concat_iter : sep:string -> string iter -> string

concat_iter ~sep iter concatenates all strings of iter, separated with sep.

since
3.2
val concat_gen : sep:string -> string gen -> string

concat_gen ~sep gen concatenates all strings of gen, separated with sep.

since
0.10
val concat_seq : sep:string -> string Stdlib.Seq.t -> string

concat_seq ~sep seq concatenates all strings of seq, separated with sep.

since
3.2
val unlines : string list -> string

unlines ls concatenates all strings of ls, separated with '\n'.

since
0.10
val unlines_gen : string gen -> string

unlines_gen gen concatenates all strings of gen, separated with '\n'.

since
0.10
val unlines_iter : string iter -> string

unlines_iter iter concatenates all strings of iter, separated with '\n'.

since
3.2
val unlines_seq : string Stdlib.Seq.t -> string

unlines_seq seq concatenates all strings of seq, separated with '\n'.

since
3.2
val set : string -> int -> char -> string

set s i c creates a new string which is a copy of s, except for index i, which becomes c.

raises Invalid_argument

if i is an invalid index.

since
0.12
val iter : f:(char -> unit) -> string -> unit

iter ~f s applies function f on each character of s. Alias to String.iter.

since
0.12
val filter_map : f:(char -> char option) -> string -> string

filter_map ~f s calls (f a0) (f a1) … (f an) where a0 … an are the characters of s. It returns the string of characters ci such as f ai = Some ci (when f returns None, the corresponding element of s is discarded).

since
0.17
val filter : f:(char -> bool) -> string -> string

filter ~f s discards characters of s not satisfying f.

since
0.17
val uniq : eq:(char -> char -> bool) -> string -> string

uniq ~eq s remove consecutive duplicate characters in s.

since
3.4
val flat_map : ?⁠sep:string -> f:(char -> string) -> string -> string

flat_map ?sep ~f s maps each chars of s to a string, then concatenates them all.

parameter sep

optional separator between each generated string.

since
0.12
val for_all : f:(char -> bool) -> string -> bool

for_all ~f s is true iff all characters of s satisfy the predicate f.

since
0.12
val exists : f:(char -> bool) -> string -> bool

exists ~f s is true iff some character of s satisfy the predicate f.

since
0.12
val drop_while : f:(char -> bool) -> t -> t

drop_while ~f s discards any characters of s starting from the left, up to the first character c not satisfying f c.

since
2.2
val rdrop_while : f:(char -> bool) -> t -> t

rdrop_while ~f s discards any characters of s starting from the right, up to the first character c not satisfying f c.

since
2.2
val ltrim : t -> t

ltrim s trims space on the left (see String.trim for more details).

since
1.2
val rtrim : t -> t

rtrim s trims space on the right (see String.trim for more details).

since
1.2

Operations on 2 strings

val map2 : f:(char -> char -> char) -> string -> string -> string

map2 ~f s1 s2 maps pairs of chars.

raises Invalid_argument

if the strings have not the same length.

since
0.12
val iter2 : f:(char -> char -> unit) -> string -> string -> unit

iter2 ~f s1 s2 iterates on pairs of chars.

raises Invalid_argument

if the strings have not the same length.

since
0.12
val iteri2 : f:(int -> char -> char -> unit) -> string -> string -> unit

iteri2 ~f s1 s2 iterates on pairs of chars with their index.

raises Invalid_argument

if the strings have not the same length.

since
0.12
val fold2 : f:('a -> char -> char -> 'a) -> init:'a -> string -> string -> 'a

fold2 ~f ~init s1 s2 folds on pairs of chars.

raises Invalid_argument

if the strings have not the same length.

since
0.12
val for_all2 : f:(char -> char -> bool) -> string -> string -> bool

for_all2 ~f s1 s2 returns true iff all pairs of chars satisfy the predicate f.

raises Invalid_argument

if the strings have not the same length.

since
0.12
val exists2 : f:(char -> char -> bool) -> string -> string -> bool

exists2 ~f s1 s2 returns true iff a pair of chars satisfy the predicate f.

raises Invalid_argument

if the strings have not the same length.

since
0.12

Ascii functions

Those functions are deprecated in String since 4.03, so we provide a stable alias for them even in older versions.

val capitalize_ascii : string -> string

capitalize_ascii s returns a copy of s with the first character set to uppercase using the US-ASCII character set. See String.

since
0.18
val uncapitalize_ascii : string -> string

uncapitalize_ascii s returns a copy of s with the first character set to lowercase using the US-ASCII character set. See String.

since
0.18
val uppercase_ascii : string -> string

uppercase_ascii s returns a copy of s with all lowercase letters translated to uppercase using the US-ASCII character set. See String.

since
0.18
val lowercase_ascii : string -> string

lowercase_ascii s returns a copy of s with all uppercase letters translated to lowercase using the US-ASCII character set. See String.

since
0.18
val equal_caseless : string -> string -> bool

equal_caseless s1 s2 compares s1 and s2 without respect to ascii lowercase.

since
1.2

Finding

A relatively efficient algorithm for finding sub-strings.

since
1.0
module Find : sig ... end

Splitting

module Split : sig ... end
val split_on_char : by:char -> string -> string list

split_on_char ~by s splits the string s along the given char by.

since
1.2
val split : by:string -> string -> string list

split ~by s splits the string s along the given string by. Alias to Split.list_cpy.

since
1.2

Utils

val compare_versions : string -> string -> int

compare_versions s1 s2 compares version strings s1 and s2, considering that numbers are above text.

since
0.13
val compare_natural : string -> string -> int

compare_natural s1 s2 is the Natural Sort Order, comparing chunks of digits as natural numbers. https://en.wikipedia.org/wiki/Natural_sort_order

since
1.3
val edit_distance : ?⁠cutoff:int -> string -> string -> int

edit_distance ?cutoff s1 s2 is the edition distance between the two strings s1 and s2. This satisfies the classical distance axioms: it is always positive, symmetric, and satisfies the formula distance s1 s2 + distance s2 s3 >= distance s1 s3.

parameter cutoff

if provided, it's a cap on both the number of iterations, and on the result. (since 3.0). This is useful if you just want to check whether the edit distance is less or equal than 2 (use cutoff of 3).

Infix operators

since
3.0
module Infix : sig ... end
include module type of Infix
val (=) : t -> t -> bool
since
3.0
val (<>) : t -> t -> bool
since
3.0
val (<) : t -> t -> bool
since
3.0
val (<=) : t -> t -> bool
since
3.0
val (>=) : t -> t -> bool
since
3.0
val (>) : t -> t -> bool
since
3.0
\ No newline at end of file diff --git a/dev/index.html b/dev/index.html index 827886ce..29436259 100644 --- a/dev/index.html +++ b/dev/index.html @@ -11,9 +11,9 @@

OCaml package documentation

    -
  1. containers 3.3
  2. -
  3. containers-data 3.3
  4. -
  5. containers-thread 3.3
  6. +
  7. containers 3.4
  8. +
  9. containers-data 3.4
  10. +
  11. containers-thread 3.4