From f32f90ab0ed13b355759463833a42f1792cc9cc2 Mon Sep 17 00:00:00 2001 From: FardaleM Date: Sat, 22 Jan 2022 20:18:18 +0000 Subject: [PATCH] deploy: a13fc12ff4aecfd58a51179e11363138227904fe --- dev/containers/CCArray/index.html | 2 +- dev/containers/CCArrayLabels/index.html | 2 +- dev/containers/CCAtomic/index.html | 2 +- dev/containers/CCFormat/index.html | 9 +++++---- dev/containers/CCRandom/index.html | 2 +- dev/containers/CCShimsArrayLabels_/index.html | 2 +- dev/containers/CCShimsArray_/index.html | 2 +- dev/containers/CCShimsInt_/index.html | 2 +- dev/containers/CCString/index.html | 2 +- dev/containers/CCStringLabels/index.html | 2 +- dev/containers/Containers/Hashtbl/Make/index.html | 2 +- dev/containers/Containers/Hashtbl/MakeSeeded/index.html | 2 +- dev/containers/Containers/Hashtbl/index.html | 2 +- dev/containers/ContainersLabels/Hashtbl/Make/index.html | 2 +- .../ContainersLabels/Hashtbl/MakeSeeded/index.html | 2 +- dev/containers/ContainersLabels/Hashtbl/index.html | 2 +- 16 files changed, 20 insertions(+), 19 deletions(-) diff --git a/dev/containers/CCArray/index.html b/dev/containers/CCArray/index.html index d6a35cef..6fdbe888 100644 --- a/dev/containers/CCArray/index.html +++ b/dev/containers/CCArray/index.html @@ -1,4 +1,4 @@ -CCArray (containers.CCArray)

Module CCArray

Array utils

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

Fast internal iterator.

  • since 2.8
type 'a gen = unit -> 'a option
type 'a equal = 'a -> 'a -> bool
type 'a ord = 'a -> 'a -> int
type 'a random_gen = Stdlib.Random.State.t -> 'a
type 'a printer = Stdlib.Format.formatter -> 'a -> unit

Arrays

include module type of struct include Stdlib.Array end
type !'a t = 'a array
val length : 'a array -> int
val get : 'a array -> int -> 'a
val set : 'a array -> int -> 'a -> unit
val make : int -> 'a -> 'a array
val create : int -> 'a -> 'a array
val create_float : int -> float array
val make_float : int -> float array
val init : int -> (int -> 'a) -> 'a array
val make_matrix : int -> int -> 'a -> 'a array array
val create_matrix : int -> int -> 'a -> 'a array array
val append : 'a array -> 'a array -> 'a array
val concat : 'a array list -> 'a array
val sub : 'a array -> int -> int -> 'a array
val copy : 'a array -> 'a array
val fill : 'a array -> int -> int -> 'a -> unit
val blit : 'a array -> int -> 'a array -> int -> int -> unit
val to_list : 'a array -> 'a list
val of_list : 'a list -> 'a array
val iter : ('a -> unit) -> 'a array -> unit
val iteri : (int -> 'a -> unit) -> 'a array -> unit
val map : ('a -> 'b) -> 'a array -> 'b array
val mapi : (int -> 'a -> 'b) -> 'a array -> 'b array
val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b array -> 'a
val fold_right : ('b -> 'a -> 'a) -> 'b array -> 'a -> 'a
val iter2 : ('a -> 'b -> unit) -> 'a array -> 'b array -> unit
val map2 : ('a -> 'b -> 'c) -> 'a array -> 'b array -> 'c array
val for_all : ('a -> bool) -> 'a array -> bool
val exists : ('a -> bool) -> 'a array -> bool
val memq : 'a -> 'a array -> bool
val sort : ('a -> 'a -> int) -> 'a array -> unit
val stable_sort : ('a -> 'a -> int) -> 'a array -> unit
val fast_sort : ('a -> 'a -> int) -> 'a array -> unit
val to_seqi : 'a array -> (int * 'a) Stdlib.Seq.t
val of_seq : 'a Stdlib.Seq.t -> 'a array
val unsafe_get : 'a array -> int -> 'a
val unsafe_set : 'a array -> int -> 'a -> unit
module Floatarray = Stdlib__array.Floatarray
val empty : 'a t

empty is the empty array, physically equal to [||].

val equal : 'a equal -> 'a t equal

equal eq a1 a2 is true if the lengths of a1 and a2 are the same and if their corresponding elements test equal, using eq.

val compare : 'a ord -> 'a t ord

compare cmp a1 a2 compares arrays a1 and a2 using the function comparison cmp.

val swap : 'a t -> int -> int -> unit

swap a i j swaps elements at indices i and j.

  • since 1.4
val get_safe : 'a t -> int -> 'a option

get_safe a i returns Some a.(i) if i is a valid index.

  • since 0.18
val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a

fold f init a computes f (… (f (f init a.(0)) a.(1)) …) a.(n-1), where n is the length of the array a. Same as Array.fold_left

val foldi : ('a -> int -> 'b -> 'a) -> 'a -> 'b t -> 'a

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

val fold_while : ('a -> 'b -> 'a * [ `Stop | `Continue ]) -> 'a -> 'b t -> 'a

fold_while f init a folds left on array a until a stop condition via ('a, `Stop) is indicated by the accumulator.

  • since 0.8
val fold_map : ('acc -> 'a -> 'acc * 'b) -> 'acc -> 'a t -> 'acc * 'b t

fold_map f init a is a fold_left-like function, but it also maps the array to another array.

  • since 1.2, but only
  • since 2.1 with labels
val scan_left : ('acc -> 'a -> 'acc) -> 'acc -> 'a t -> 'acc t

scan_left f init a returns the array [|init; f init x0; f (f init a.(0)) a.(1); …|] .

  • since 1.2, but only
  • since 2.1 with labels
val reverse_in_place : 'a t -> unit

reverse_in_place a reverses the array a in place.

val sorted : ('a -> 'a -> int) -> 'a t -> 'a array

sorted f a makes a copy of a and sorts it with f.

  • since 1.0
val sort_indices : ('a -> 'a -> int) -> 'a t -> int array

sort_indices f a returns a new array b, with the same length as a, such that b.(i) is the index at which the i-th element of sorted f a appears in a. a is not modified.

In other words, map (fun i -> a.(i)) (sort_indices f a) = sorted f a. sort_indices yields the inverse permutation of sort_ranking.

  • since 1.0
val sort_ranking : ('a -> 'a -> int) -> 'a t -> int array

sort_ranking f a returns a new array b, with the same length as a, such that b.(i) is the index at which the i-th element of a appears in sorted f a. a is not modified.

In other words, map (fun i -> (sorted f a).(i)) (sort_ranking f a) = a. sort_ranking yields the inverse permutation of sort_indices.

In the absence of duplicate elements in a, we also have lookup_exn a.(i) (sorted a) = (sorted_ranking a).(i).

  • since 1.0
val mem : ?eq:('a -> 'a -> bool) -> 'a -> 'a t -> bool

mem ~eq x a return true if x is present in a. Linear time.

  • since 3.0
val find_map : ('a -> 'b option) -> 'a t -> 'b option

find_map f a returns Some y if there is an element x such that f x = Some y. Otherwise returns None.

  • since 1.3, but only
  • since 2.1 with labels
val find_map_i : (int -> 'a -> 'b option) -> 'a t -> 'b option

find_map_i f a is like find_map, but the index of the element is also passed to the predicate function f.

  • since 1.3, but only
  • since 2.1 with labels
val find_idx : ('a -> bool) -> 'a t -> (int * 'a) option

find_idx f a returns Some (i,x) where x is the i-th element of a, and f x holds. Otherwise returns None.

  • since 0.3.4
val lookup : cmp:'a ord -> 'a -> 'a t -> int option

lookup ~cmp key a lookups the index of some key key in a sorted array a. Undefined behavior if the array a is not sorted wrt ~cmp. Complexity: O(log (n)) (dichotomic search).

  • returns

    None if the key key is not present, or Some i (i the index of the key) otherwise.

val lookup_exn : cmp:'a ord -> 'a -> 'a t -> int

lookup_exn ~cmp key a is like lookup, but

  • raises Not_found

    if the key key is not present.

val bsearch : cmp:('a -> 'a -> int) -> +CCArray (containers.CCArray)

Module CCArray

Array utils

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

Fast internal iterator.

  • since 2.8
type 'a gen = unit -> 'a option
type 'a equal = 'a -> 'a -> bool
type 'a ord = 'a -> 'a -> int
type 'a random_gen = Stdlib.Random.State.t -> 'a
type 'a printer = Stdlib.Format.formatter -> 'a -> unit

Arrays

include module type of struct include Stdlib.Array end
type !'a t = 'a array
val length : 'a array -> int
val get : 'a array -> int -> 'a
val set : 'a array -> int -> 'a -> unit
val make : int -> 'a -> 'a array
val create : int -> 'a -> 'a array
val create_float : int -> float array
val make_float : int -> float array
val init : int -> (int -> 'a) -> 'a array
val make_matrix : int -> int -> 'a -> 'a array array
val create_matrix : int -> int -> 'a -> 'a array array
val append : 'a array -> 'a array -> 'a array
val concat : 'a array list -> 'a array
val sub : 'a array -> int -> int -> 'a array
val copy : 'a array -> 'a array
val fill : 'a array -> int -> int -> 'a -> unit
val blit : 'a array -> int -> 'a array -> int -> int -> unit
val to_list : 'a array -> 'a list
val of_list : 'a list -> 'a array
val iter : ('a -> unit) -> 'a array -> unit
val iteri : (int -> 'a -> unit) -> 'a array -> unit
val map : ('a -> 'b) -> 'a array -> 'b array
val mapi : (int -> 'a -> 'b) -> 'a array -> 'b array
val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b array -> 'a
val fold_left_map : ('a -> 'b -> 'a * 'c) -> 'a -> 'b array -> 'a * 'c array
val fold_right : ('b -> 'a -> 'a) -> 'b array -> 'a -> 'a
val iter2 : ('a -> 'b -> unit) -> 'a array -> 'b array -> unit
val map2 : ('a -> 'b -> 'c) -> 'a array -> 'b array -> 'c array
val for_all : ('a -> bool) -> 'a array -> bool
val exists : ('a -> bool) -> 'a array -> bool
val memq : 'a -> 'a array -> bool
val find_opt : ('a -> bool) -> 'a array -> 'a option
val split : ('a * 'b) array -> 'a array * 'b array
val combine : 'a array -> 'b array -> ('a * 'b) array
val sort : ('a -> 'a -> int) -> 'a array -> unit
val stable_sort : ('a -> 'a -> int) -> 'a array -> unit
val fast_sort : ('a -> 'a -> int) -> 'a array -> unit
val to_seqi : 'a array -> (int * 'a) Stdlib.Seq.t
val of_seq : 'a Stdlib.Seq.t -> 'a array
val unsafe_get : 'a array -> int -> 'a
val unsafe_set : 'a array -> int -> 'a -> unit
module Floatarray = Stdlib__Array.Floatarray
val empty : 'a t

empty is the empty array, physically equal to [||].

val equal : 'a equal -> 'a t equal

equal eq a1 a2 is true if the lengths of a1 and a2 are the same and if their corresponding elements test equal, using eq.

val compare : 'a ord -> 'a t ord

compare cmp a1 a2 compares arrays a1 and a2 using the function comparison cmp.

val swap : 'a t -> int -> int -> unit

swap a i j swaps elements at indices i and j.

  • since 1.4
val get_safe : 'a t -> int -> 'a option

get_safe a i returns Some a.(i) if i is a valid index.

  • since 0.18
val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a

fold f init a computes f (… (f (f init a.(0)) a.(1)) …) a.(n-1), where n is the length of the array a. Same as Array.fold_left

val foldi : ('a -> int -> 'b -> 'a) -> 'a -> 'b t -> 'a

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

val fold_while : ('a -> 'b -> 'a * [ `Stop | `Continue ]) -> 'a -> 'b t -> 'a

fold_while f init a folds left on array a until a stop condition via ('a, `Stop) is indicated by the accumulator.

  • since 0.8
val fold_map : ('acc -> 'a -> 'acc * 'b) -> 'acc -> 'a t -> 'acc * 'b t

fold_map f init a is a fold_left-like function, but it also maps the array to another array.

  • since 1.2, but only
  • since 2.1 with labels
val scan_left : ('acc -> 'a -> 'acc) -> 'acc -> 'a t -> 'acc t

scan_left f init a returns the array [|init; f init x0; f (f init a.(0)) a.(1); …|] .

  • since 1.2, but only
  • since 2.1 with labels
val reverse_in_place : 'a t -> unit

reverse_in_place a reverses the array a in place.

val sorted : ('a -> 'a -> int) -> 'a t -> 'a array

sorted f a makes a copy of a and sorts it with f.

  • since 1.0
val sort_indices : ('a -> 'a -> int) -> 'a t -> int array

sort_indices f a returns a new array b, with the same length as a, such that b.(i) is the index at which the i-th element of sorted f a appears in a. a is not modified.

In other words, map (fun i -> a.(i)) (sort_indices f a) = sorted f a. sort_indices yields the inverse permutation of sort_ranking.

  • since 1.0
val sort_ranking : ('a -> 'a -> int) -> 'a t -> int array

sort_ranking f a returns a new array b, with the same length as a, such that b.(i) is the index at which the i-th element of a appears in sorted f a. a is not modified.

In other words, map (fun i -> (sorted f a).(i)) (sort_ranking f a) = a. sort_ranking yields the inverse permutation of sort_indices.

In the absence of duplicate elements in a, we also have lookup_exn a.(i) (sorted a) = (sorted_ranking a).(i).

  • since 1.0
val mem : ?eq:('a -> 'a -> bool) -> 'a -> 'a t -> bool

mem ~eq x a return true if x is present in a. Linear time.

  • since 3.0
val find_map : ('a -> 'b option) -> 'a t -> 'b option

find_map f a returns Some y if there is an element x such that f x = Some y. Otherwise returns None.

  • since 1.3, but only
  • since 2.1 with labels
val find_map_i : (int -> 'a -> 'b option) -> 'a t -> 'b option

find_map_i f a is like find_map, but the index of the element is also passed to the predicate function f.

  • since 1.3, but only
  • since 2.1 with labels
val find_idx : ('a -> bool) -> 'a t -> (int * 'a) option

find_idx f a returns Some (i,x) where x is the i-th element of a, and f x holds. Otherwise returns None.

  • since 0.3.4
val lookup : cmp:'a ord -> 'a -> 'a t -> int option

lookup ~cmp key a lookups the index of some key key in a sorted array a. Undefined behavior if the array a is not sorted wrt ~cmp. Complexity: O(log (n)) (dichotomic search).

  • returns

    None if the key key is not present, or Some i (i the index of the key) otherwise.

val lookup_exn : cmp:'a ord -> 'a -> 'a t -> int

lookup_exn ~cmp key a is like lookup, but

  • raises Not_found

    if the key key is not present.

val bsearch : cmp:('a -> 'a -> int) -> 'a -> 'a t -> [ `All_lower | `All_bigger | `Just_after of int | `Empty | `At of int ]

bsearch ~cmp key a finds the index of the object key in the array a, provided a is sorted using cmp. If the array is not sorted, the result is not specified (may raise Invalid_argument).

Complexity: O(log n) where n is the length of the array a (dichotomic search).

  • returns
    • `At i if cmp a.(i) key = 0 (for some i).
    • `All_lower if all elements of a are lower than key.
    • `All_bigger if all elements of a are bigger than key.
    • `Just_after i if a.(i) < key < a.(i+1).
    • `Empty if the array a is empty.
  • raises Invalid_argument

    if the array is found to be unsorted w.r.t cmp.

  • since 0.13
val for_all2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool

for_all2 f [|a1; …; an|] [|b1; …; bn|] is true if each pair of elements ai bi satisfies the predicate f. That is, it returns (f a1 b1) && (f a2 b2) && … && (f an bn).

  • raises Invalid_argument

    if arrays have distinct lengths. Allow different types.

  • since 0.20
val exists2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool

exists2 f [|a1; …; an|] [|b1; …; bn|] is true if any pair of elements ai bi satisfies the predicate f. That is, it returns (f a1 b1) || (f a2 b2) || … || (f an bn).

  • raises Invalid_argument

    if arrays have distinct lengths. Allow different types.

  • since 0.20
val fold2 : ('acc -> 'a -> 'b -> 'acc) -> 'acc -> 'a t -> 'b t -> 'acc

fold2 f init a b fold on two arrays a and b stepwise. It computes f (… (f init a1 b1) …) an bn.

  • raises Invalid_argument

    if a and b have distinct lengths.

  • since 0.20
val shuffle : 'a t -> unit

shuffle a randomly shuffles the array a, in place.

val shuffle_with : Stdlib.Random.State.t -> 'a t -> unit

shuffle_with rs a randomly shuffles the array a (like shuffle) but a specialized random state rs is used to control the random numbers being produced during shuffling (for reproducibility).

val random_choose : 'a t -> 'a random_gen

random_choose a rs randomly chooses an element of a.

  • raises Not_found

    if the array/slice is empty.

val to_string : ?sep:string -> ('a -> string) -> 'a array -> string

to_string ~sep item_to_string a print a to a string using sep as a separator between elements of a.

  • since 2.7
val to_iter : 'a t -> 'a iter

to_iter a returns an iter of the elements of an array a. The input array a is shared with the sequence and modification of it will result in modification of the iterator.

  • since 2.8
val to_seq : 'a t -> 'a Stdlib.Seq.t

to_seq a returns a Seq.t of the elements of an array a. The input array a is shared with the sequence and modification of it will result in modification of the sequence. Renamed from to_std_seq since 3.0.

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

to_gen a returns a gen of the elements of an array a.

IO

val pp : ?pp_start:unit printer -> ?pp_stop:unit printer -> ?pp_sep:unit printer -> 'a printer -> 'a t printer

pp ~pp_start ~pp_stop ~pp_sep pp_item ppf a formats the array a on ppf. Each element is formatted with pp_item, pp_start is called at the beginning, pp_stop is called at the end, pp_sep is called between each elements. By defaults pp_start and pp_stop does nothing and pp_sep defaults to (fun out -> Format.fprintf out ",@ ").

val pp_i : ?pp_start:unit printer -> ?pp_stop:unit printer -> ?pp_sep:unit printer -> (int -> 'a printer) -> 'a t printer

pp_i ~pp_start ~pp_stop ~pp_sep pp_item ppf a prints the array a on ppf. The printing function pp_item is giving both index and element. pp_start is called at the beginning, pp_stop is called at the end, pp_sep is called between each elements. By defaults pp_start and pp_stop does nothing and pp_sep defaults to (fun out -> Format.fprintf out ",@ ").

val rev : 'a t -> 'a t

rev a copies the array a and reverses it in place.

  • since 0.20
val filter : ('a -> bool) -> 'a t -> 'a t

filter f a filters elements out of the array a. Only the elements satisfying the given predicate f will be kept.

val filter_map : ('a -> 'b option) -> 'a t -> 'b t

filter_map f [|a1; …; an|] calls (f a1) … (f an) and returns an array b consisting of all elements bi such as f ai = Some bi. When f returns None, the corresponding element of a is discarded.

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

monoid_product f a b passes all combinaisons of tuples from the two arrays a and b to the function f.

  • since 2.8
val flat_map : ('a -> 'b t) -> 'a t -> 'b array

flat_map f a transforms each element of a into an array, then flattens.

val except_idx : 'a t -> int -> 'a list

except_idx a i removes the element of a at given index i, and returns the list of the other elements.

val random : 'a random_gen -> 'a t random_gen
val random_non_empty : 'a random_gen -> 'a t random_gen
val random_len : int -> 'a random_gen -> 'a t random_gen

Generic Functions

module type MONO_ARRAY = sig ... end
val sort_generic : (module MONO_ARRAY with type elt = 'elt and type t = 'arr) -> cmp:('elt -> 'elt -> int) -> 'arr -> unit

sort_generic (module M) ~cmp a sorts the array a, without allocating (eats stack space though). Performance might be lower than Array.sort.

  • since 0.14

Infix Operators

It is convenient to openCCArray.Infix to access the infix operators without cluttering the scope too much.

  • since 2.7
module Infix : sig ... end
include module type of Infix
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t

a >>= f is the infix version of flat_map.

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

a >>| f is the infix version of map.

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

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

  • since 0.8
val (--) : int -> int -> int t

x -- y creates an array containing integers in the range x .. y. Bounds included.

val (--^) : int -> int -> int t

x --^ y creates an array containing integers in the range x .. y. Right bound excluded.

  • since 0.17

Let operators on OCaml >= 4.08.0, nothing otherwise

  • since 2.8
val let+ : 'a array -> ('a -> 'b) -> 'b array
val and+ : 'a array -> 'b array -> ('a * 'b) array
val let* : 'a array -> ('a -> 'b array) -> 'b array
val and* : 'a array -> 'b array -> ('a * 'b) array
\ No newline at end of file diff --git a/dev/containers/CCArrayLabels/index.html b/dev/containers/CCArrayLabels/index.html index 4472daaf..979b6a42 100644 --- a/dev/containers/CCArrayLabels/index.html +++ b/dev/containers/CCArrayLabels/index.html @@ -1,5 +1,5 @@ CCArrayLabels (containers.CCArrayLabels)

Module CCArrayLabels

Array utils (Labeled version of CCArray)

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

Fast internal iterator.

  • since 2.8
type 'a gen = unit -> 'a option
type 'a equal = 'a -> 'a -> bool
type 'a ord = 'a -> 'a -> int
type 'a random_gen = Stdlib.Random.State.t -> 'a
type 'a printer = Stdlib.Format.formatter -> 'a -> unit

Arrays

include module type of Stdlib.ArrayLabels with module Floatarray = Stdlib.Array.Floatarray
type !'a t = 'a array
val length : 'a array -> int
val get : 'a array -> int -> 'a
val set : 'a array -> int -> 'a -> unit
val make : int -> 'a -> 'a array
val create : int -> 'a -> 'a array
val create_float : int -> float array
val make_float : int -> float array
val init : int -> f:(int -> 'a) -> 'a array
val make_matrix : dimx:int -> dimy:int -> 'a -> 'a array array
val create_matrix : dimx:int -> dimy:int -> 'a -> 'a array array
val append : 'a array -> 'a array -> 'a array
val concat : 'a array list -> 'a array
val sub : 'a array -> pos:int -> len:int -> 'a array
val copy : 'a array -> 'a array
val fill : 'a array -> pos:int -> len:int -> 'a -> unit
val blit : src:'a array -> src_pos:int -> dst:'a array -> dst_pos:int -> len:int -> -unit
val to_list : 'a array -> 'a list
val of_list : 'a list -> 'a array
val iter : f:('a -> unit) -> 'a array -> unit
val iteri : f:(int -> 'a -> unit) -> 'a array -> unit
val map : f:('a -> 'b) -> 'a array -> 'b array
val mapi : f:(int -> 'a -> 'b) -> 'a array -> 'b array
val fold_left : f:('a -> 'b -> 'a) -> init:'a -> 'b array -> 'a
val fold_right : f:('b -> 'a -> 'a) -> 'b array -> init:'a -> 'a
val for_all : f:('a -> bool) -> 'a array -> bool
val exists : f:('a -> bool) -> 'a array -> bool
val memq : 'a -> set:'a array -> bool
val sort : cmp:('a -> 'a -> int) -> 'a array -> unit
val stable_sort : cmp:('a -> 'a -> int) -> 'a array -> unit
val fast_sort : cmp:('a -> 'a -> int) -> 'a array -> unit
val to_seqi : 'a array -> (int * 'a) Stdlib.Seq.t
val of_seq : 'a Stdlib.Seq.t -> 'a array
val unsafe_get : 'a array -> int -> 'a
val unsafe_set : 'a array -> int -> 'a -> unit
module Floatarray : sig ... end
val empty : 'a t

empty is the empty array, physically equal to ||.

val equal : 'a equal -> 'a t equal

equal eq a1 a2 is true if the lengths of a1 and a2 are the same and if their corresponding elements test equal, using eq.

val compare : 'a ord -> 'a t ord

compare cmp a1 a2 compares arrays a1 and a2 using the function comparison cmp.

val swap : 'a t -> int -> int -> unit

swap a i j swaps elements at indices i and j.

  • since 1.4
val get_safe : 'a t -> int -> 'a option

get_safe a i returns Some a.(i) if i is a valid index.

  • since 0.18
val fold : f:('a -> 'b -> 'a) -> init:'a -> 'b t -> 'a

fold ~f ~init a computes f (… (f (f init a.(0)) a.(1)) …) a.(n-1), where n is the length of the array a. Same as ArrayLabels.fold_left

val foldi : f:('a -> int -> 'b -> 'a) -> init:'a -> 'b t -> 'a

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

val fold_while : f:('a -> 'b -> 'a * [ `Stop | `Continue ]) -> init:'a -> 'b t -> 'a

fold_while ~f ~init a folds left on array a until a stop condition via ('a, `Stop) is indicated by the accumulator.

  • since 0.8
val fold_map : f:('acc -> 'a -> 'acc * 'b) -> init:'acc -> 'a t -> 'acc * 'b t

fold_map ~f ~init a is a fold_left-like function, but it also maps the array to another array.

  • since 1.2, but only
  • since 2.1 with labels
val scan_left : f:('acc -> 'a -> 'acc) -> init:'acc -> 'a t -> 'acc t

scan_left ~f ~init a returns the array [|init; f init x0; f (f init a.(0)) a.(1); …|] .

  • since 1.2, but only
  • since 2.1 with labels
val reverse_in_place : 'a t -> unit

reverse_in_place a reverses the array a in place.

val sorted : f:('a -> 'a -> int) -> 'a t -> 'a array

sorted ~f a makes a copy of a and sorts it with f.

  • since 1.0
val sort_indices : f:('a -> 'a -> int) -> 'a t -> int array

sort_indices ~f a returns a new array b, with the same length as a, such that b.(i) is the index at which the i-th element of sorted f a appears in a. a is not modified.

In other words, map (fun i -> a.(i)) (sort_indices f a) = sorted f a. sort_indices yields the inverse permutation of sort_ranking.

  • since 1.0
val sort_ranking : f:('a -> 'a -> int) -> 'a t -> int array

sort_ranking ~f a returns a new array b, with the same length as a, such that b.(i) is the index at which the i-th element of a appears in sorted f a. a is not modified.

In other words, map (fun i -> (sorted f a).(i)) (sort_ranking f a) = a. sort_ranking yields the inverse permutation of sort_indices.

In the absence of duplicate elements in a, we also have lookup_exn a.(i) (sorted a) = (sorted_ranking a).(i).

  • since 1.0
val mem : ?eq:('a -> 'a -> bool) -> 'a -> 'a t -> bool

mem ~eq x a return true if x is present in a. Linear time.

  • since 3.0
val find_map : f:('a -> 'b option) -> 'a t -> 'b option

find_map ~f a returns Some y if there is an element x such that f x = Some y. Otherwise returns None.

  • since 1.3, but only
  • since 2.1 with labels
val find_map_i : f:(int -> 'a -> 'b option) -> 'a t -> 'b option

find_map_i ~f a is like find_map, but the index of the element is also passed to the predicate function f.

  • since 1.3, but only
  • since 2.1 with labels
val find_idx : f:('a -> bool) -> 'a t -> (int * 'a) option

find_idx ~f a returns Some (i,x) where x is the i-th element of a, and f x holds. Otherwise returns None.

  • since 0.3.4
val lookup : cmp:'a ord -> key:'a -> 'a t -> int option

lookup ~cmp ~key a lookups the index of some key key in a sorted array a. Undefined behavior if the array a is not sorted wrt cmp. Complexity: O(log (n)) (dichotomic search).

  • returns

    None if the key key is not present, or Some i (i the index of the key) otherwise.

val lookup_exn : cmp:'a ord -> key:'a -> 'a t -> int

lookup_exn ~cmp ~key a is like lookup, but

  • raises Not_found

    if the key key is not present.

val bsearch : cmp:('a -> 'a -> int) -> key:'a -> +unit
val to_list : 'a array -> 'a list
val of_list : 'a list -> 'a array
val iter : f:('a -> unit) -> 'a array -> unit
val iteri : f:(int -> 'a -> unit) -> 'a array -> unit
val map : f:('a -> 'b) -> 'a array -> 'b array
val mapi : f:(int -> 'a -> 'b) -> 'a array -> 'b array
val fold_left : f:('a -> 'b -> 'a) -> init:'a -> 'b array -> 'a
val fold_left_map : f:('a -> 'b -> 'a * 'c) -> init:'a -> 'b array -> 'a * 'c array
val fold_right : f:('b -> 'a -> 'a) -> 'b array -> init:'a -> 'a
val for_all : f:('a -> bool) -> 'a array -> bool
val exists : f:('a -> bool) -> 'a array -> bool
val memq : 'a -> set:'a array -> bool
val find_opt : f:('a -> bool) -> 'a array -> 'a option
val split : ('a * 'b) array -> 'a array * 'b array
val combine : 'a array -> 'b array -> ('a * 'b) array
val sort : cmp:('a -> 'a -> int) -> 'a array -> unit
val stable_sort : cmp:('a -> 'a -> int) -> 'a array -> unit
val fast_sort : cmp:('a -> 'a -> int) -> 'a array -> unit
val to_seqi : 'a array -> (int * 'a) Stdlib.Seq.t
val of_seq : 'a Stdlib.Seq.t -> 'a array
val unsafe_get : 'a array -> int -> 'a
val unsafe_set : 'a array -> int -> 'a -> unit
module Floatarray : sig ... end
val empty : 'a t

empty is the empty array, physically equal to ||.

val equal : 'a equal -> 'a t equal

equal eq a1 a2 is true if the lengths of a1 and a2 are the same and if their corresponding elements test equal, using eq.

val compare : 'a ord -> 'a t ord

compare cmp a1 a2 compares arrays a1 and a2 using the function comparison cmp.

val swap : 'a t -> int -> int -> unit

swap a i j swaps elements at indices i and j.

  • since 1.4
val get_safe : 'a t -> int -> 'a option

get_safe a i returns Some a.(i) if i is a valid index.

  • since 0.18
val fold : f:('a -> 'b -> 'a) -> init:'a -> 'b t -> 'a

fold ~f ~init a computes f (… (f (f init a.(0)) a.(1)) …) a.(n-1), where n is the length of the array a. Same as ArrayLabels.fold_left

val foldi : f:('a -> int -> 'b -> 'a) -> init:'a -> 'b t -> 'a

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

val fold_while : f:('a -> 'b -> 'a * [ `Stop | `Continue ]) -> init:'a -> 'b t -> 'a

fold_while ~f ~init a folds left on array a until a stop condition via ('a, `Stop) is indicated by the accumulator.

  • since 0.8
val fold_map : f:('acc -> 'a -> 'acc * 'b) -> init:'acc -> 'a t -> 'acc * 'b t

fold_map ~f ~init a is a fold_left-like function, but it also maps the array to another array.

  • since 1.2, but only
  • since 2.1 with labels
val scan_left : f:('acc -> 'a -> 'acc) -> init:'acc -> 'a t -> 'acc t

scan_left ~f ~init a returns the array [|init; f init x0; f (f init a.(0)) a.(1); …|] .

  • since 1.2, but only
  • since 2.1 with labels
val reverse_in_place : 'a t -> unit

reverse_in_place a reverses the array a in place.

val sorted : f:('a -> 'a -> int) -> 'a t -> 'a array

sorted ~f a makes a copy of a and sorts it with f.

  • since 1.0
val sort_indices : f:('a -> 'a -> int) -> 'a t -> int array

sort_indices ~f a returns a new array b, with the same length as a, such that b.(i) is the index at which the i-th element of sorted f a appears in a. a is not modified.

In other words, map (fun i -> a.(i)) (sort_indices f a) = sorted f a. sort_indices yields the inverse permutation of sort_ranking.

  • since 1.0
val sort_ranking : f:('a -> 'a -> int) -> 'a t -> int array

sort_ranking ~f a returns a new array b, with the same length as a, such that b.(i) is the index at which the i-th element of a appears in sorted f a. a is not modified.

In other words, map (fun i -> (sorted f a).(i)) (sort_ranking f a) = a. sort_ranking yields the inverse permutation of sort_indices.

In the absence of duplicate elements in a, we also have lookup_exn a.(i) (sorted a) = (sorted_ranking a).(i).

  • since 1.0
val mem : ?eq:('a -> 'a -> bool) -> 'a -> 'a t -> bool

mem ~eq x a return true if x is present in a. Linear time.

  • since 3.0
val find_map : f:('a -> 'b option) -> 'a t -> 'b option

find_map ~f a returns Some y if there is an element x such that f x = Some y. Otherwise returns None.

  • since 1.3, but only
  • since 2.1 with labels
val find_map_i : f:(int -> 'a -> 'b option) -> 'a t -> 'b option

find_map_i ~f a is like find_map, but the index of the element is also passed to the predicate function f.

  • since 1.3, but only
  • since 2.1 with labels
val find_idx : f:('a -> bool) -> 'a t -> (int * 'a) option

find_idx ~f a returns Some (i,x) where x is the i-th element of a, and f x holds. Otherwise returns None.

  • since 0.3.4
val lookup : cmp:'a ord -> key:'a -> 'a t -> int option

lookup ~cmp ~key a lookups the index of some key key in a sorted array a. Undefined behavior if the array a is not sorted wrt cmp. Complexity: O(log (n)) (dichotomic search).

  • returns

    None if the key key is not present, or Some i (i the index of the key) otherwise.

val lookup_exn : cmp:'a ord -> key:'a -> 'a t -> int

lookup_exn ~cmp ~key a is like lookup, but

  • raises Not_found

    if the key key is not present.

val bsearch : cmp:('a -> 'a -> int) -> key:'a -> 'a t -> [ `All_lower | `All_bigger | `Just_after of int | `Empty | `At of int ]

bsearch ~cmp ~key a finds the index of the object key in the array a, provided a is sorted using cmp. If the array is not sorted, the result is not specified (may raise Invalid_argument).

Complexity: O(log n) where n is the length of the array a (dichotomic search).

  • returns
    • `At i if cmp a.(i) key = 0 (for some i).
    • `All_lower if all elements of a are lower than key.
    • `All_bigger if all elements of a are bigger than key.
    • `Just_after i if a.(i) < key < a.(i+1).
    • `Empty if the array a is empty.
  • raises Invalid_argument

    if the array is found to be unsorted w.r.t cmp.

  • since 0.13
val for_all2 : f:('a -> 'b -> bool) -> 'a t -> 'b t -> bool

for_all2 ~f [|a1; …; an|] [|b1; …; bn|] is true if each pair of elements ai bi satisfies the predicate f. That is, it returns (f a1 b1) && (f a2 b2) && … && (f an bn).

  • raises Invalid_argument

    if arrays have distinct lengths. Allow different types.

  • since 0.20
val exists2 : f:('a -> 'b -> bool) -> 'a t -> 'b t -> bool

exists2 ~f [|a1; …; an|] [|b1; …; bn|] is true if any pair of elements ai bi satisfies the predicate f. That is, it returns (f a1 b1) || (f a2 b2) || … || (f an bn).

  • raises Invalid_argument

    if arrays have distinct lengths. Allow different types.

  • since 0.20
val fold2 : f:('acc -> 'a -> 'b -> 'acc) -> init:'acc -> 'a t -> 'b t -> 'acc

fold2 ~f ~init a b fold on two arrays a and b stepwise. It computes f (… (f init a1 b1) …) an bn.

  • raises Invalid_argument

    if a and b have distinct lengths.

  • since 0.20
val iter2 : f:('a -> 'b -> unit) -> 'a t -> 'b t -> unit

iter2 ~f a b iterates on the two arrays a and b stepwise. It is equivalent to f a0 b0; …; f a.(length a - 1) b.(length b - 1); ().

  • raises Invalid_argument

    if a and b have distinct lengths.

  • since 0.20
val shuffle : 'a t -> unit

shuffle a randomly shuffles the array a, in place.

val shuffle_with : Stdlib.Random.State.t -> 'a t -> unit

shuffle_with rs a randomly shuffles the array a (like shuffle) but a specialized random state rs is used to control the random numbers being produced during shuffling (for reproducibility).

val random_choose : 'a t -> 'a random_gen

random_choose a rs randomly chooses an element of a.

  • raises Not_found

    if the array/slice is empty.

val to_string : ?sep:string -> ('a -> string) -> 'a array -> string

to_string ~sep item_to_string a print a to a string using sep as a separator between elements of a.

  • since 2.7
val to_iter : 'a t -> 'a iter

to_iter a returns an iter of the elements of an array a. The input array a is shared with the sequence and modification of it will result in modification of the iterator.

  • since 2.8
val to_seq : 'a t -> 'a Stdlib.Seq.t

to_seq a returns a Seq.t of the elements of an array a. The input array a is shared with the sequence and modification of it will result in modification of the sequence. Renamed from to_std_seq since 3.0.

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

to_gen a returns a gen of the elements of an array a.

IO

val pp : ?pp_start:unit printer -> ?pp_stop:unit printer -> ?pp_sep:unit printer -> 'a printer -> 'a t printer

pp ~pp_start ~pp_stop ~pp_sep pp_item ppf a formats the array a on ppf. Each element is formatted with pp_item, pp_start is called at the beginning, pp_stop is called at the end, pp_sep is called between each elements. By defaults pp_start and pp_stop does nothing and pp_sep defaults to (fun out -> Format.fprintf out ",@ ").

val pp_i : ?pp_start:unit printer -> ?pp_stop:unit printer -> ?pp_sep:unit printer -> (int -> 'a printer) -> 'a t printer

pp_i ~pp_start ~pp_stop ~pp_sep pp_item ppf a prints the array a on ppf. The printing function pp_item is giving both index and element. pp_start is called at the beginning, pp_stop is called at the end, pp_sep is called between each elements. By defaults pp_start and pp_stop does nothing and pp_sep defaults to (fun out -> Format.fprintf out ",@ ").

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

map2 ~f a b applies function f to all elements of a and b, and builds an array with the results returned by f: [| f a.(0) b.(0); …; f a.(length a - 1) b.(length b - 1)|].

  • raises Invalid_argument

    if a and b have distinct lengths.

  • since 0.20
val rev : 'a t -> 'a t

rev a copies the array a and reverses it in place.

  • since 0.20
val filter : f:('a -> bool) -> 'a t -> 'a t

filter ~f a filters elements out of the array a. Only the elements satisfying the given predicate f will be kept.

val filter_map : f:('a -> 'b option) -> 'a t -> 'b t

filter_map ~f [|a1; …; an|] calls (f a1) … (f an) and returns an array b consisting of all elements bi such as f ai = Some bi. When f returns None, the corresponding element of a is discarded.

val monoid_product : f:('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t

monoid_product ~f a b passes all combinaisons of tuples from the two arrays a and b to the function f.

  • since 2.8
val flat_map : f:('a -> 'b t) -> 'a t -> 'b array

flat_map ~f a transforms each element of a into an array, then flattens.

val except_idx : 'a t -> int -> 'a list

except_idx a i removes the element of a at given index i, and returns the list of the other elements.

val random : 'a random_gen -> 'a t random_gen
val random_non_empty : 'a random_gen -> 'a t random_gen
val random_len : int -> 'a random_gen -> 'a t random_gen

Generic Functions

module type MONO_ARRAY = sig ... end
val sort_generic : (module MONO_ARRAY with type elt = 'elt and type t = 'arr) -> cmp:('elt -> 'elt -> int) -> 'arr -> unit

sort_generic (module M) ~cmp a sorts the array a, without allocating (eats stack space though). Performance might be lower than Array.sort.

  • since 0.14

Infix Operators

It is convenient to openCCArray.Infix to access the infix operators without cluttering the scope too much.

  • since 2.7
module Infix : sig ... end
include module type of Infix
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t

a >>= f is the infix version of flat_map.

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

a >>| f is the infix version of map.

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

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

  • since 0.8
val (--) : int -> int -> int t

x -- y creates an array containing integers in the range x .. y. Bounds included.

val (--^) : int -> int -> int t

x --^ y creates an array containing integers in the range x .. y. Right bound excluded.

  • since 0.17

Let operators on OCaml >= 4.08.0, nothing otherwise

  • since 2.8
val let+ : 'a array -> ('a -> 'b) -> 'b array
val and+ : 'a array -> 'b array -> ('a * 'b) array
val let* : 'a array -> ('a -> 'b array) -> 'b array
val and* : 'a array -> 'b array -> ('a * 'b) array
\ No newline at end of file diff --git a/dev/containers/CCAtomic/index.html b/dev/containers/CCAtomic/index.html index a205a396..babe8619 100644 --- a/dev/containers/CCAtomic/index.html +++ b/dev/containers/CCAtomic/index.html @@ -1,2 +1,2 @@ -CCAtomic (containers.CCAtomic)

Module CCAtomic

include module type of struct include Stdlib.Atomic end
type !'a t = 'a Stdlib__atomic.t
val make : 'a -> 'a t
val get : 'a t -> 'a
val set : 'a t -> 'a -> unit
val exchange : 'a t -> 'a -> 'a
val compare_and_set : 'a t -> 'a -> 'a -> bool
val fetch_and_add : int t -> int -> int
val incr : int t -> unit
val decr : int t -> unit
\ No newline at end of file +CCAtomic (containers.CCAtomic)

Module CCAtomic

include module type of struct include Stdlib.Atomic end
type !'a t = 'a Stdlib__Atomic.t
val make : 'a -> 'a t
val get : 'a t -> 'a
val set : 'a t -> 'a -> unit
val exchange : 'a t -> 'a -> 'a
val compare_and_set : 'a t -> 'a -> 'a -> bool
val fetch_and_add : int t -> int -> int
val incr : int t -> unit
val decr : int t -> unit
\ No newline at end of file diff --git a/dev/containers/CCFormat/index.html b/dev/containers/CCFormat/index.html index c118481d..32492ba7 100644 --- a/dev/containers/CCFormat/index.html +++ b/dev/containers/CCFormat/index.html @@ -1,9 +1,10 @@ -CCFormat (containers.CCFormat)

Module CCFormat

Helpers for Format

  • since 0.8
type 'a iter = ('a -> unit) -> unit
include module type of struct include Stdlib.Format end
type formatter = Stdlib__format.formatter
val pp_open_box : formatter -> int -> unit
val open_box : int -> unit
val pp_close_box : formatter -> unit -> unit
val close_box : unit -> unit
val pp_open_hbox : formatter -> unit -> unit
val open_hbox : unit -> unit
val pp_open_vbox : formatter -> int -> unit
val open_vbox : int -> unit
val pp_open_hvbox : formatter -> int -> unit
val open_hvbox : int -> unit
val pp_open_hovbox : formatter -> int -> unit
val open_hovbox : int -> unit
val pp_print_string : formatter -> string -> unit
val print_string : string -> unit
val pp_print_as : formatter -> int -> string -> unit
val print_as : int -> string -> unit
val pp_print_int : formatter -> int -> unit
val print_int : int -> unit
val pp_print_float : formatter -> float -> unit
val print_float : float -> unit
val pp_print_char : formatter -> char -> unit
val print_char : char -> unit
val pp_print_bool : formatter -> bool -> unit
val print_bool : bool -> unit
val pp_print_space : formatter -> unit -> unit
val print_space : unit -> unit
val pp_print_cut : formatter -> unit -> unit
val print_cut : unit -> unit
val pp_print_break : formatter -> int -> int -> unit
val print_break : int -> int -> unit
val pp_print_custom_break : formatter -> fits:(string * int * string) -> -breaks:(string * int * string) -> unit
val pp_force_newline : formatter -> unit -> unit
val force_newline : unit -> unit
val pp_print_if_newline : formatter -> unit -> unit
val print_if_newline : unit -> unit
val pp_print_flush : formatter -> unit -> unit
val print_flush : unit -> unit
val pp_print_newline : formatter -> unit -> unit
val print_newline : unit -> unit
val pp_set_margin : formatter -> int -> unit
val set_margin : int -> unit
val pp_get_margin : formatter -> unit -> int
val get_margin : unit -> int
val pp_set_max_indent : formatter -> int -> unit
val set_max_indent : int -> unit
val pp_get_max_indent : formatter -> unit -> int
val get_max_indent : unit -> int
type geometry = Stdlib__format.geometry = {
max_indent : int;
margin : int;
}
val check_geometry : geometry -> bool
val pp_set_geometry : formatter -> max_indent:int -> margin:int -> unit
val set_geometry : max_indent:int -> margin:int -> unit
val pp_safe_set_geometry : formatter -> max_indent:int -> margin:int -> unit
val safe_set_geometry : max_indent:int -> margin:int -> unit
val pp_update_geometry : formatter -> (geometry -> geometry) -> unit
val update_geometry : (geometry -> geometry) -> unit
val pp_get_geometry : formatter -> unit -> geometry
val get_geometry : unit -> geometry
val pp_set_max_boxes : formatter -> int -> unit
val set_max_boxes : int -> unit
val pp_get_max_boxes : formatter -> unit -> int
val get_max_boxes : unit -> int
val pp_over_max_boxes : formatter -> unit -> bool
val over_max_boxes : unit -> bool
val pp_open_tbox : formatter -> unit -> unit
val open_tbox : unit -> unit
val pp_close_tbox : formatter -> unit -> unit
val close_tbox : unit -> unit
val pp_set_tab : formatter -> unit -> unit
val set_tab : unit -> unit
val pp_print_tab : formatter -> unit -> unit
val print_tab : unit -> unit
val pp_print_tbreak : formatter -> int -> int -> unit
val print_tbreak : int -> int -> unit
val pp_set_ellipsis_text : formatter -> string -> unit
val set_ellipsis_text : string -> unit
val pp_get_ellipsis_text : formatter -> unit -> string
val get_ellipsis_text : unit -> string
type stag = Stdlib__format.stag = ..
type tag = string
type stag +=
| String_tag of tag
val pp_open_stag : formatter -> stag -> unit
val open_stag : stag -> unit
val pp_close_stag : formatter -> unit -> unit
val close_stag : unit -> unit
val pp_set_tags : formatter -> bool -> unit
val set_tags : bool -> unit
val pp_set_print_tags : formatter -> bool -> unit
val set_print_tags : bool -> unit
val pp_set_mark_tags : formatter -> bool -> unit
val set_mark_tags : bool -> unit
val pp_get_print_tags : formatter -> unit -> bool
val get_print_tags : unit -> bool
val pp_get_mark_tags : formatter -> unit -> bool
val get_mark_tags : unit -> bool
val pp_set_formatter_out_channel : formatter -> Stdlib.out_channel -> unit
val set_formatter_out_channel : Stdlib.out_channel -> unit
val pp_set_formatter_output_functions : formatter -> (string -> int -> int -> unit) -> (unit -> unit) -> unit
val set_formatter_output_functions : (string -> int -> int -> unit) -> (unit -> unit) -> unit
val pp_get_formatter_output_functions : formatter -> unit -> (string -> int -> int -> unit) * (unit -> unit)
val get_formatter_output_functions : unit -> (string -> int -> int -> unit) * (unit -> unit)
type formatter_out_functions = Stdlib__format.formatter_out_functions = {
out_string : string -> int -> int -> unit;
out_flush : unit -> unit;
out_newline : unit -> unit;
out_spaces : int -> unit;
out_indent : int -> unit;
}
val pp_set_formatter_out_functions : formatter -> formatter_out_functions -> unit
val set_formatter_out_functions : formatter_out_functions -> unit
val pp_get_formatter_out_functions : formatter -> unit -> formatter_out_functions
val get_formatter_out_functions : unit -> formatter_out_functions
type formatter_stag_functions = Stdlib__format.formatter_stag_functions = {
mark_open_stag : stag -> string;
mark_close_stag : stag -> string;
print_open_stag : stag -> unit;
print_close_stag : stag -> unit;
}
val pp_set_formatter_stag_functions : formatter -> formatter_stag_functions -> unit
val set_formatter_stag_functions : formatter_stag_functions -> unit
val pp_get_formatter_stag_functions : formatter -> unit -> formatter_stag_functions
val get_formatter_stag_functions : unit -> formatter_stag_functions
val formatter_of_out_channel : Stdlib.out_channel -> formatter
val std_formatter : formatter
val err_formatter : formatter
val formatter_of_buffer : Stdlib.Buffer.t -> formatter
val stdbuf : Stdlib.Buffer.t
val str_formatter : formatter
val flush_str_formatter : unit -> string
val make_formatter : (string -> int -> int -> unit) -> (unit -> unit) -> formatter
val formatter_of_out_functions : formatter_out_functions -> formatter
type symbolic_output_item = Stdlib__format.symbolic_output_item =
| Output_flush
| Output_newline
| Output_string of string
| Output_spaces of int
| Output_indent of int
type symbolic_output_buffer = Stdlib__format.symbolic_output_buffer
val make_symbolic_output_buffer : unit -> symbolic_output_buffer
val clear_symbolic_output_buffer : symbolic_output_buffer -> unit
val get_symbolic_output_buffer : symbolic_output_buffer -> symbolic_output_item list
val flush_symbolic_output_buffer : symbolic_output_buffer -> symbolic_output_item list
val add_symbolic_output_item : symbolic_output_buffer -> symbolic_output_item -> unit
val formatter_of_symbolic_output_buffer : symbolic_output_buffer -> formatter
val pp_print_list : ?pp_sep:(formatter -> unit -> unit) -> (formatter -> 'a -> unit) -> formatter -> 'a list -> unit
val pp_print_seq : ?pp_sep:(formatter -> unit -> unit) -> (formatter -> 'a -> unit) -> formatter -> 'a Stdlib.Seq.t -> unit
val pp_print_text : formatter -> string -> unit
val pp_print_option : ?none:(formatter -> unit -> unit) -> (formatter -> 'a -> unit) -> formatter -> 'a option -> unit
val pp_print_result : ok:(formatter -> 'a -> unit) -> error:(formatter -> 'e -> unit) -> -formatter -> ('a'e) Stdlib.result -> unit
val printf : ('aformatter, unit) Stdlib.format -> 'a
val eprintf : ('aformatter, unit) Stdlib.format -> 'a
val asprintf : ('aformatter, unit, string) Stdlib.format4 -> 'a
val dprintf : ('aformatter, unit, formatter -> unit) Stdlib.format4 -> 'a
val ifprintf : formatter -> ('aformatter, unit) Stdlib.format -> 'a
val kfprintf : (formatter -> 'a) -> formatter -> ('bformatter, unit, 'a) Stdlib.format4 -> 'b
val kdprintf : ((formatter -> unit) -> 'a) -> ('bformatter, unit, 'a) Stdlib.format4 -> 'b
val ikfprintf : (formatter -> 'a) -> formatter -> ('bformatter, unit, 'a) Stdlib.format4 -> 'b
val kasprintf : (string -> 'a) -> ('bformatter, unit, 'a) Stdlib.format4 -> 'b
val bprintf : Stdlib.Buffer.t -> ('aformatter, unit) Stdlib.format -> 'a
val kprintf : (string -> 'a) -> ('b, unit, string, 'a) Stdlib.format4 -> 'b
val set_all_formatter_output_functions : out:(string -> int -> int -> unit) -> +CCFormat (containers.CCFormat)

Module CCFormat

Helpers for Format

  • since 0.8
type 'a iter = ('a -> unit) -> unit
include module type of struct include Stdlib.Format end
type formatter = Stdlib__Format.formatter
val pp_open_box : formatter -> int -> unit
val open_box : int -> unit
val pp_close_box : formatter -> unit -> unit
val close_box : unit -> unit
val pp_open_hbox : formatter -> unit -> unit
val open_hbox : unit -> unit
val pp_open_vbox : formatter -> int -> unit
val open_vbox : int -> unit
val pp_open_hvbox : formatter -> int -> unit
val open_hvbox : int -> unit
val pp_open_hovbox : formatter -> int -> unit
val open_hovbox : int -> unit
val pp_print_string : formatter -> string -> unit
val print_string : string -> unit
val pp_print_bytes : formatter -> bytes -> unit
val print_bytes : bytes -> unit
val pp_print_as : formatter -> int -> string -> unit
val print_as : int -> string -> unit
val pp_print_int : formatter -> int -> unit
val print_int : int -> unit
val pp_print_float : formatter -> float -> unit
val print_float : float -> unit
val pp_print_char : formatter -> char -> unit
val print_char : char -> unit
val pp_print_bool : formatter -> bool -> unit
val print_bool : bool -> unit
val pp_print_space : formatter -> unit -> unit
val print_space : unit -> unit
val pp_print_cut : formatter -> unit -> unit
val print_cut : unit -> unit
val pp_print_break : formatter -> int -> int -> unit
val print_break : int -> int -> unit
val pp_print_custom_break : formatter -> fits:(string * int * string) -> +breaks:(string * int * string) -> unit
val pp_force_newline : formatter -> unit -> unit
val force_newline : unit -> unit
val pp_print_if_newline : formatter -> unit -> unit
val print_if_newline : unit -> unit
val pp_print_flush : formatter -> unit -> unit
val print_flush : unit -> unit
val pp_print_newline : formatter -> unit -> unit
val print_newline : unit -> unit
val pp_set_margin : formatter -> int -> unit
val set_margin : int -> unit
val pp_get_margin : formatter -> unit -> int
val get_margin : unit -> int
val pp_set_max_indent : formatter -> int -> unit
val set_max_indent : int -> unit
val pp_get_max_indent : formatter -> unit -> int
val get_max_indent : unit -> int
type geometry = Stdlib__Format.geometry = {
max_indent : int;
margin : int;
}
val check_geometry : geometry -> bool
val pp_set_geometry : formatter -> max_indent:int -> margin:int -> unit
val set_geometry : max_indent:int -> margin:int -> unit
val pp_safe_set_geometry : formatter -> max_indent:int -> margin:int -> unit
val safe_set_geometry : max_indent:int -> margin:int -> unit
val pp_update_geometry : formatter -> (geometry -> geometry) -> unit
val update_geometry : (geometry -> geometry) -> unit
val pp_get_geometry : formatter -> unit -> geometry
val get_geometry : unit -> geometry
val pp_set_max_boxes : formatter -> int -> unit
val set_max_boxes : int -> unit
val pp_get_max_boxes : formatter -> unit -> int
val get_max_boxes : unit -> int
val pp_over_max_boxes : formatter -> unit -> bool
val over_max_boxes : unit -> bool
val pp_open_tbox : formatter -> unit -> unit
val open_tbox : unit -> unit
val pp_close_tbox : formatter -> unit -> unit
val close_tbox : unit -> unit
val pp_set_tab : formatter -> unit -> unit
val set_tab : unit -> unit
val pp_print_tab : formatter -> unit -> unit
val print_tab : unit -> unit
val pp_print_tbreak : formatter -> int -> int -> unit
val print_tbreak : int -> int -> unit
val pp_set_ellipsis_text : formatter -> string -> unit
val set_ellipsis_text : string -> unit
val pp_get_ellipsis_text : formatter -> unit -> string
val get_ellipsis_text : unit -> string
type stag = Stdlib__Format.stag = ..
type tag = string
type stag +=
| String_tag of tag
val pp_open_stag : formatter -> stag -> unit
val open_stag : stag -> unit
val pp_close_stag : formatter -> unit -> unit
val close_stag : unit -> unit
val pp_set_tags : formatter -> bool -> unit
val set_tags : bool -> unit
val pp_set_print_tags : formatter -> bool -> unit
val set_print_tags : bool -> unit
val pp_set_mark_tags : formatter -> bool -> unit
val set_mark_tags : bool -> unit
val pp_get_print_tags : formatter -> unit -> bool
val get_print_tags : unit -> bool
val pp_get_mark_tags : formatter -> unit -> bool
val get_mark_tags : unit -> bool
val pp_set_formatter_out_channel : formatter -> Stdlib.out_channel -> unit
val set_formatter_out_channel : Stdlib.out_channel -> unit
val pp_set_formatter_output_functions : formatter -> (string -> int -> int -> unit) -> (unit -> unit) -> unit
val set_formatter_output_functions : (string -> int -> int -> unit) -> (unit -> unit) -> unit
val pp_get_formatter_output_functions : formatter -> unit -> (string -> int -> int -> unit) * (unit -> unit)
val get_formatter_output_functions : unit -> (string -> int -> int -> unit) * (unit -> unit)
type formatter_out_functions = Stdlib__Format.formatter_out_functions = {
out_string : string -> int -> int -> unit;
out_flush : unit -> unit;
out_newline : unit -> unit;
out_spaces : int -> unit;
out_indent : int -> unit;
}
val pp_set_formatter_out_functions : formatter -> formatter_out_functions -> unit
val set_formatter_out_functions : formatter_out_functions -> unit
val pp_get_formatter_out_functions : formatter -> unit -> formatter_out_functions
val get_formatter_out_functions : unit -> formatter_out_functions
type formatter_stag_functions = Stdlib__Format.formatter_stag_functions = {
mark_open_stag : stag -> string;
mark_close_stag : stag -> string;
print_open_stag : stag -> unit;
print_close_stag : stag -> unit;
}
val pp_set_formatter_stag_functions : formatter -> formatter_stag_functions -> unit
val set_formatter_stag_functions : formatter_stag_functions -> unit
val pp_get_formatter_stag_functions : formatter -> unit -> formatter_stag_functions
val get_formatter_stag_functions : unit -> formatter_stag_functions
val formatter_of_out_channel : Stdlib.out_channel -> formatter
val std_formatter : formatter
val err_formatter : formatter
val formatter_of_buffer : Stdlib.Buffer.t -> formatter
val stdbuf : Stdlib.Buffer.t
val str_formatter : formatter
val flush_str_formatter : unit -> string
val make_formatter : (string -> int -> int -> unit) -> (unit -> unit) -> formatter
val formatter_of_out_functions : formatter_out_functions -> formatter
type symbolic_output_item = Stdlib__Format.symbolic_output_item =
| Output_flush
| Output_newline
| Output_string of string
| Output_spaces of int
| Output_indent of int
type symbolic_output_buffer = Stdlib__Format.symbolic_output_buffer
val make_symbolic_output_buffer : unit -> symbolic_output_buffer
val clear_symbolic_output_buffer : symbolic_output_buffer -> unit
val get_symbolic_output_buffer : symbolic_output_buffer -> symbolic_output_item list
val flush_symbolic_output_buffer : symbolic_output_buffer -> symbolic_output_item list
val add_symbolic_output_item : symbolic_output_buffer -> symbolic_output_item -> unit
val formatter_of_symbolic_output_buffer : symbolic_output_buffer -> formatter
val pp_print_list : ?pp_sep:(formatter -> unit -> unit) -> (formatter -> 'a -> unit) -> formatter -> 'a list -> unit
val pp_print_seq : ?pp_sep:(formatter -> unit -> unit) -> (formatter -> 'a -> unit) -> formatter -> 'a Stdlib.Seq.t -> unit
val pp_print_text : formatter -> string -> unit
val pp_print_option : ?none:(formatter -> unit -> unit) -> (formatter -> 'a -> unit) -> formatter -> 'a option -> unit
val pp_print_result : ok:(formatter -> 'a -> unit) -> error:(formatter -> 'e -> unit) -> +formatter -> ('a'e) Stdlib.result -> unit
val pp_print_either : left:(formatter -> 'a -> unit) -> right:(formatter -> 'b -> unit) -> +formatter -> ('a'b) Stdlib.Either.t -> unit
val printf : ('aformatter, unit) Stdlib.format -> 'a
val eprintf : ('aformatter, unit) Stdlib.format -> 'a
val asprintf : ('aformatter, unit, string) Stdlib.format4 -> 'a
val dprintf : ('aformatter, unit, formatter -> unit) Stdlib.format4 -> 'a
val ifprintf : formatter -> ('aformatter, unit) Stdlib.format -> 'a
val kfprintf : (formatter -> 'a) -> formatter -> ('bformatter, unit, 'a) Stdlib.format4 -> 'b
val kdprintf : ((formatter -> unit) -> 'a) -> ('bformatter, unit, 'a) Stdlib.format4 -> 'b
val ikfprintf : (formatter -> 'a) -> formatter -> ('bformatter, unit, 'a) Stdlib.format4 -> 'b
val kasprintf : (string -> 'a) -> ('bformatter, unit, 'a) Stdlib.format4 -> 'b
val bprintf : Stdlib.Buffer.t -> ('aformatter, unit) Stdlib.format -> 'a
val kprintf : (string -> 'a) -> ('b, unit, string, 'a) Stdlib.format4 -> 'b
val set_all_formatter_output_functions : out:(string -> int -> int -> unit) -> flush:(unit -> unit) -> newline:(unit -> unit) -> spaces:(int -> unit) -> unit
val get_all_formatter_output_functions : unit -> (string -> int -> int -> unit) * (unit -> unit) * (unit -> unit) * (int -> unit)
val pp_set_all_formatter_output_functions : formatter -> out:(string -> int -> int -> unit) -> -flush:(unit -> unit) -> newline:(unit -> unit) -> spaces:(int -> unit) -> unit
val pp_get_all_formatter_output_functions : formatter -> unit -> (string -> int -> int -> unit) * (unit -> unit) * (unit -> unit) * (int -> unit)
val pp_open_tag : formatter -> tag -> unit
val open_tag : tag -> unit
val pp_close_tag : formatter -> unit -> unit
val close_tag : unit -> unit
type formatter_tag_functions = Stdlib__format.formatter_tag_functions = {
mark_open_tag : tag -> string;
mark_close_tag : tag -> string;
print_open_tag : tag -> unit;
print_close_tag : tag -> unit;
}
val pp_set_formatter_tag_functions : formatter -> formatter_tag_functions -> unit
val set_formatter_tag_functions : formatter_tag_functions -> unit
val pp_get_formatter_tag_functions : formatter -> unit -> formatter_tag_functions
val get_formatter_tag_functions : unit -> formatter_tag_functions
type t = Stdlib.Format.formatter
type -'a printer = t -> 'a -> unit

Combinators

val silent : 'a printer

Prints nothing.

val unit : unit printer

Prints "()".

val int : int printer
val string : string printer
val bool : bool printer
val float3 : float printer
val float : float printer
val exn : exn printer

Printer using Printexc.to_string.

  • since 3.0
val space : unit printer

Alias to pp_print_space.

  • since 3.2
val cut : unit printer

Alias to pp_print_cut.

  • since 3.2
val break : (int * int) printer

Tuple-ized printer form of pp_print_break.

  • since 3.2
val newline : unit printer

Force newline (see Format.pp_force_newline).

  • since 1.2
val substring : (string * int * int) printer

substring (s,i,len) prints the substring (s,i,len), where i is the offset in s and len the number of bytes in the substring.

  • raises Invalid_argument

    if the triple (s,i,len) does not describe a proper substring.

  • since 1.2
val text : string printer

Print string, but replacing spaces with breaks and newlines with newline. See pp_print_text on recent versions of OCaml.

  • since 1.2
val string_lines : string printer

string_lines out s prints s with all newlines ('\n') replaced by a cut, in a vertical box. It does NOT insert breakable spaces in place of spaces, unlike text. This means an already formatted string can be displayed inside another formatter without mangling the indentation.

  • since 3.3
val char : char printer
  • since 0.14
val int32 : int32 printer
  • since 0.14
val int64 : int64 printer
  • since 0.14
val nativeint : nativeint printer
  • since 0.14
val flush : unit printer

Alias to Format.pp_print_flush.

  • since 1.2
val string_quoted : string printer

Similar to CCString.print.

  • since 0.14
val list : ?sep:unit printer -> 'a printer -> 'a list printer
val array : ?sep:unit printer -> 'a printer -> 'a array printer
val arrayi : ?sep:unit printer -> (int * 'a) printer -> 'a array printer
val seq : ?sep:unit printer -> 'a printer -> 'a Stdlib.Seq.t printer
val iter : ?sep:unit printer -> 'a printer -> 'a iter printer
val opt : 'a printer -> 'a option printer

opt pp prints options as follows:

  • Some x will become "some foo" if pp x ---> "foo".
  • None will become "none".

In the tuple printers, the sep argument is only available.

  • since 0.17
val pair : ?sep:unit printer -> 'a printer -> 'b printer -> ('a * 'b) printer
val triple : ?sep:unit printer -> 'a printer -> 'b printer -> 'c printer -> ('a * 'b * 'c) printer
val quad : ?sep:unit printer -> 'a printer -> 'b printer -> 'c printer -> 'd printer -> ('a * 'b * 'c * 'd) printer
val append : unit printer -> unit printer -> unit printer

append ppa ppb first prints ppa (), then prints ppb ().

  • since 3.2
val append_l : unit printer list -> unit printer

append_l pps runs the printers in pps sequentially.

  • since 3.2
val within : string -> string -> 'a printer -> 'a printer

within a b p wraps p inside the strings a and b. Convenient, for instances, for brackets, parenthesis, quotes, etc.

  • since 0.17
val map : ('a -> 'b) -> 'b printer -> 'a printer
val vbox : ?i:int -> 'a printer -> 'a printer

Wrap the printer in a vertical box.

  • parameter i

    level of indentation within the box (default 0).

  • since 0.16
val hvbox : ?i:int -> 'a printer -> 'a printer

Wrap the printer in a horizontal/vertical box.

  • parameter i

    level of indentation within the box (default 0).

  • since 0.16
val hovbox : ?i:int -> 'a printer -> 'a printer

Wrap the printer in a horizontal or vertical box.

  • parameter i

    level of indentation within the box (default 0).

  • since 0.16
val hbox : 'a printer -> 'a printer

Wrap the printer in an horizontal box.

  • since 0.16
val return : ('a__'a) Stdlib.format4 -> unit printer

return "some_format_string" takes a argument-less format string and returns a printer actionable by (). Examples:

  • return ",@ "
  • return "@{<Red>and then@}@,"
  • return "@[<v>a@ b@]"
  • since 1.0
val of_to_string : ('a -> string) -> 'a printer

of_to_string f converts its input to a string using f, then prints the string.

  • since 1.0
val const : 'a printer -> 'a -> unit printer

const pp x is a unit printer that uses pp on x.

  • since 1.0
val some : 'a printer -> 'a option printer

some pp will print options as follows:

  • Some x is printed using pp on x
  • None is not printed at all
  • since 1.0
val const_string : string -> 'a printer

const_string s is a printer that ignores its input and always prints s.

  • since 3.5
val opaque : 'a printer

opaque is const_string "opaque". The exact string used is not stable.

  • since 3.5
val lazy_force : 'a printer -> 'a lazy_t printer

lazy_force pp out x forces x and prints the result with pp.

  • since 2.0
val lazy_or : ?default:unit printer -> 'a printer -> 'a lazy_t printer

lazy_or ?default pp out x prints default if x is not evaluated yet, or uses pp otherwise.

  • since 2.0

ANSI codes

Use ANSI escape codes https://en.wikipedia.org/wiki/ANSI_escape_code to put some colors on the terminal.

This uses tags in format strings to specify the style. Current styles are the following:

  • "reset" resets style
  • "black"
  • "red"
  • "green"
  • "yellow"
  • "blue"
  • "magenta"
  • "cyan"
  • "white"
  • "bold" bold font
  • "Black" bold black
  • "Red" bold red
  • "Green" bold green
  • "Yellow" bold yellow
  • "Blue" bold blue
  • "Magenta" bold magenta
  • "Cyan" bold cyan
  • "White" bold white

Example:

set_color_default true;;
+flush:(unit -> unit) -> newline:(unit -> unit) -> spaces:(int -> unit) -> unit
val pp_get_all_formatter_output_functions : formatter -> unit -> (string -> int -> int -> unit) * (unit -> unit) * (unit -> unit) * (int -> unit)
val pp_open_tag : formatter -> tag -> unit
val open_tag : tag -> unit
val pp_close_tag : formatter -> unit -> unit
val close_tag : unit -> unit
type formatter_tag_functions = Stdlib__Format.formatter_tag_functions = {
mark_open_tag : tag -> string;
mark_close_tag : tag -> string;
print_open_tag : tag -> unit;
print_close_tag : tag -> unit;
}
val pp_set_formatter_tag_functions : formatter -> formatter_tag_functions -> unit
val set_formatter_tag_functions : formatter_tag_functions -> unit
val pp_get_formatter_tag_functions : formatter -> unit -> formatter_tag_functions
val get_formatter_tag_functions : unit -> formatter_tag_functions
type t = Stdlib.Format.formatter
type -'a printer = t -> 'a -> unit

Combinators

val silent : 'a printer

Prints nothing.

val unit : unit printer

Prints "()".

val int : int printer
val string : string printer
val bool : bool printer
val float3 : float printer
val float : float printer
val exn : exn printer

Printer using Printexc.to_string.

  • since 3.0
val space : unit printer

Alias to pp_print_space.

  • since 3.2
val cut : unit printer

Alias to pp_print_cut.

  • since 3.2
val break : (int * int) printer

Tuple-ized printer form of pp_print_break.

  • since 3.2
val newline : unit printer

Force newline (see Format.pp_force_newline).

  • since 1.2
val substring : (string * int * int) printer

substring (s,i,len) prints the substring (s,i,len), where i is the offset in s and len the number of bytes in the substring.

  • raises Invalid_argument

    if the triple (s,i,len) does not describe a proper substring.

  • since 1.2
val text : string printer

Print string, but replacing spaces with breaks and newlines with newline. See pp_print_text on recent versions of OCaml.

  • since 1.2
val string_lines : string printer

string_lines out s prints s with all newlines ('\n') replaced by a cut, in a vertical box. It does NOT insert breakable spaces in place of spaces, unlike text. This means an already formatted string can be displayed inside another formatter without mangling the indentation.

  • since 3.3
val char : char printer
  • since 0.14
val int32 : int32 printer
  • since 0.14
val int64 : int64 printer
  • since 0.14
val nativeint : nativeint printer
  • since 0.14
val flush : unit printer

Alias to Format.pp_print_flush.

  • since 1.2
val string_quoted : string printer

Similar to CCString.print.

  • since 0.14
val list : ?sep:unit printer -> 'a printer -> 'a list printer
val array : ?sep:unit printer -> 'a printer -> 'a array printer
val arrayi : ?sep:unit printer -> (int * 'a) printer -> 'a array printer
val seq : ?sep:unit printer -> 'a printer -> 'a Stdlib.Seq.t printer
val iter : ?sep:unit printer -> 'a printer -> 'a iter printer
val opt : 'a printer -> 'a option printer

opt pp prints options as follows:

  • Some x will become "some foo" if pp x ---> "foo".
  • None will become "none".

In the tuple printers, the sep argument is only available.

  • since 0.17
val pair : ?sep:unit printer -> 'a printer -> 'b printer -> ('a * 'b) printer
val triple : ?sep:unit printer -> 'a printer -> 'b printer -> 'c printer -> ('a * 'b * 'c) printer
val quad : ?sep:unit printer -> 'a printer -> 'b printer -> 'c printer -> 'd printer -> ('a * 'b * 'c * 'd) printer
val append : unit printer -> unit printer -> unit printer

append ppa ppb first prints ppa (), then prints ppb ().

  • since 3.2
val append_l : unit printer list -> unit printer

append_l pps runs the printers in pps sequentially.

  • since 3.2
val within : string -> string -> 'a printer -> 'a printer

within a b p wraps p inside the strings a and b. Convenient, for instances, for brackets, parenthesis, quotes, etc.

  • since 0.17
val map : ('a -> 'b) -> 'b printer -> 'a printer
val vbox : ?i:int -> 'a printer -> 'a printer

Wrap the printer in a vertical box.

  • parameter i

    level of indentation within the box (default 0).

  • since 0.16
val hvbox : ?i:int -> 'a printer -> 'a printer

Wrap the printer in a horizontal/vertical box.

  • parameter i

    level of indentation within the box (default 0).

  • since 0.16
val hovbox : ?i:int -> 'a printer -> 'a printer

Wrap the printer in a horizontal or vertical box.

  • parameter i

    level of indentation within the box (default 0).

  • since 0.16
val hbox : 'a printer -> 'a printer

Wrap the printer in an horizontal box.

  • since 0.16
val return : ('a__'a) Stdlib.format4 -> unit printer

return "some_format_string" takes a argument-less format string and returns a printer actionable by (). Examples:

  • return ",@ "
  • return "@{<Red>and then@}@,"
  • return "@[<v>a@ b@]"
  • since 1.0
val of_to_string : ('a -> string) -> 'a printer

of_to_string f converts its input to a string using f, then prints the string.

  • since 1.0
val const : 'a printer -> 'a -> unit printer

const pp x is a unit printer that uses pp on x.

  • since 1.0
val some : 'a printer -> 'a option printer

some pp will print options as follows:

  • Some x is printed using pp on x
  • None is not printed at all
  • since 1.0
val const_string : string -> 'a printer

const_string s is a printer that ignores its input and always prints s.

  • since 3.5
val opaque : 'a printer

opaque is const_string "opaque". The exact string used is not stable.

  • since 3.5
val lazy_force : 'a printer -> 'a lazy_t printer

lazy_force pp out x forces x and prints the result with pp.

  • since 2.0
val lazy_or : ?default:unit printer -> 'a printer -> 'a lazy_t printer

lazy_or ?default pp out x prints default if x is not evaluated yet, or uses pp otherwise.

  • since 2.0

ANSI codes

Use ANSI escape codes https://en.wikipedia.org/wiki/ANSI_escape_code to put some colors on the terminal.

This uses tags in format strings to specify the style. Current styles are the following:

  • "reset" resets style
  • "black"
  • "red"
  • "green"
  • "yellow"
  • "blue"
  • "magenta"
  • "cyan"
  • "white"
  • "bold" bold font
  • "Black" bold black
  • "Red" bold red
  • "Green" bold green
  • "Yellow" bold yellow
  • "Blue" bold blue
  • "Magenta" bold magenta
  • "Cyan" bold cyan
  • "White" bold white

Example:

set_color_default true;;
 
 Format.printf
   "what is your @{<White>favorite color@}? @{<blue>blue@}! No, @{<red>red@}! Ahhhhhhh@.";;

status: unstable

  • since 0.15
val set_color_tag_handling : t -> unit

Add functions to support color tags to the given formatter.

  • since 0.15
val set_color_default : bool -> unit

set_color_default b enables color handling on the standard formatters (stdout, stderr) if b = true as well as on sprintf formatters; it disables the color handling if b = false.

val with_color : string -> 'a printer -> 'a printer

with_color "Blue" pp behaves like the printer pp, but with the given style.

status: unstable

  • since 0.16
val with_colorf : string -> t -> ('at, unit, unit) Stdlib.format4 -> 'a

with_colorf "Blue" out "%s %d" "yolo" 42 will behave like Format.fprintf, but wrapping the content with the given style.

status: unstable

  • since 0.16
val with_color_sf : string -> ('at, unit, string) Stdlib.format4 -> 'a

with_color_sf "Blue" out "%s %d" "yolo" 42 will behave like sprintf, but wrapping the content with the given style.

Example:

CCFormat.with_color_sf "red" "%a" CCFormat.Dump.(list int) [1;2;3] |> print_endline;;

status: unstable

  • since 0.21
val with_color_ksf : f:(string -> 'b) -> string -> ('at, unit, 'b) Stdlib.format4 -> 'a

with_color_ksf "Blue" ~f "%s %d" "yolo" 42 will behave like ksprintf, but wrapping the content with the given style.

Example: the following with raise Failure with a colored message

CCFormat.with_color_ksf "red" ~f:failwith "%a" CCFormat.Dump.(list int) [1;2;3];;
  • since 1.2
module ANSI_codes : sig ... end

ANSI escape codes. This contains lower level functions for them.

IO

val output : t -> 'a printer -> 'a -> unit
val to_string : 'a printer -> 'a -> string
val of_chan : Stdlib.out_channel -> t

Alias to Format.formatter_of_out_channel.

  • since 1.2
val with_out_chan : Stdlib.out_channel -> (t -> 'a) -> 'a

with_out_chan oc f turns oc into a formatter fmt, and call f fmt. Behaves like f fmt from then on, but whether the call to f fails or returns, fmt is flushed before the call terminates.

  • since 1.2
val stdout : t
val stderr : t
val tee : t -> t -> t

tee a b makes a new formatter that writes in both a and b.

  • since 1.0
val sprintf : ('at, unit, string) Stdlib.format4 -> 'a

Print into a string any format string that would usually be compatible with fprintf. Like Format.asprintf.

val sprintf_no_color : ('at, unit, string) Stdlib.format4 -> 'a

Like sprintf but never prints colors.

  • since 0.16
val sprintf_dyn_color : colors:bool -> ('at, unit, string) Stdlib.format4 -> 'a

Like sprintf but enable/disable colors depending on colors.

Example:

(* with colors *)
diff --git a/dev/containers/CCRandom/index.html b/dev/containers/CCRandom/index.html
index 5a4a567e..9641fd6d 100644
--- a/dev/containers/CCRandom/index.html
+++ b/dev/containers/CCRandom/index.html
@@ -1,5 +1,5 @@
 
-CCRandom (containers.CCRandom)

Module CCRandom

Random Generators

include module type of struct include Stdlib.Random end
val init : int -> unit
val full_init : int array -> unit
val self_init : unit -> unit
val bits : unit -> int
val int32 : Stdlib.Int32.t -> Stdlib.Int32.t
val nativeint : Stdlib.Nativeint.t -> Stdlib.Nativeint.t
val int64 : Stdlib.Int64.t -> Stdlib.Int64.t
val bool : unit -> bool
module State = Stdlib__random.State
val get_state : unit -> State.t
val set_state : State.t -> unit
type state = Stdlib.Random.State.t
type 'a t = state -> 'a

Random generator for values of type 'a.

type 'a random_gen = 'a t
val return : 'a -> 'a t

return x is the generator that always returns x. Example: let random_int = return 4 (* fair dice roll *).

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

flat_map f g st is f (g st) st.

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

Monadic bind.

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

map f g st is f (g st).

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

Delay evaluation. Useful for side-effectful generators that need some code to run for every call. Example:

let gensym = let r = ref 0 in fun () -> incr r; !r ;;
+CCRandom (containers.CCRandom)

Module CCRandom

Random Generators

include module type of struct include Stdlib.Random end
val init : int -> unit
val full_init : int array -> unit
val self_init : unit -> unit
val bits : unit -> int
val full_int : int -> int
val int32 : Stdlib.Int32.t -> Stdlib.Int32.t
val nativeint : Stdlib.Nativeint.t -> Stdlib.Nativeint.t
val int64 : Stdlib.Int64.t -> Stdlib.Int64.t
val bool : unit -> bool
module State = Stdlib__Random.State
val get_state : unit -> State.t
val set_state : State.t -> unit
type state = Stdlib.Random.State.t
type 'a t = state -> 'a

Random generator for values of type 'a.

type 'a random_gen = 'a t
val return : 'a -> 'a t

return x is the generator that always returns x. Example: let random_int = return 4 (* fair dice roll *).

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

flat_map f g st is f (g st) st.

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

Monadic bind.

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

map f g st is f (g st).

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

Delay evaluation. Useful for side-effectful generators that need some code to run for every call. Example:

let gensym = let r = ref 0 in fun () -> incr r; !r ;;
 
 delay (fun () ->
   let name = gensym() in
diff --git a/dev/containers/CCShimsArrayLabels_/index.html b/dev/containers/CCShimsArrayLabels_/index.html
index 378614a4..6db44e83 100644
--- a/dev/containers/CCShimsArrayLabels_/index.html
+++ b/dev/containers/CCShimsArrayLabels_/index.html
@@ -1,3 +1,3 @@
 
 CCShimsArrayLabels_ (containers.CCShimsArrayLabels_)

Module CCShimsArrayLabels_

include module type of Stdlib.ArrayLabels with module Floatarray = Stdlib.Array.Floatarray
type !'a t = 'a array
val length : 'a array -> int
val get : 'a array -> int -> 'a
val set : 'a array -> int -> 'a -> unit
val make : int -> 'a -> 'a array
val create : int -> 'a -> 'a array
val create_float : int -> float array
val make_float : int -> float array
val init : int -> f:(int -> 'a) -> 'a array
val make_matrix : dimx:int -> dimy:int -> 'a -> 'a array array
val create_matrix : dimx:int -> dimy:int -> 'a -> 'a array array
val append : 'a array -> 'a array -> 'a array
val concat : 'a array list -> 'a array
val sub : 'a array -> pos:int -> len:int -> 'a array
val copy : 'a array -> 'a array
val fill : 'a array -> pos:int -> len:int -> 'a -> unit
val blit : src:'a array -> src_pos:int -> dst:'a array -> dst_pos:int -> len:int -> -unit
val to_list : 'a array -> 'a list
val of_list : 'a list -> 'a array
val iter : f:('a -> unit) -> 'a array -> unit
val iteri : f:(int -> 'a -> unit) -> 'a array -> unit
val map : f:('a -> 'b) -> 'a array -> 'b array
val mapi : f:(int -> 'a -> 'b) -> 'a array -> 'b array
val fold_left : f:('a -> 'b -> 'a) -> init:'a -> 'b array -> 'a
val fold_right : f:('b -> 'a -> 'a) -> 'b array -> init:'a -> 'a
val iter2 : f:('a -> 'b -> unit) -> 'a array -> 'b array -> unit
val map2 : f:('a -> 'b -> 'c) -> 'a array -> 'b array -> 'c array
val for_all : f:('a -> bool) -> 'a array -> bool
val exists : f:('a -> bool) -> 'a array -> bool
val for_all2 : f:('a -> 'b -> bool) -> 'a array -> 'b array -> bool
val exists2 : f:('a -> 'b -> bool) -> 'a array -> 'b array -> bool
val mem : 'a -> set:'a array -> bool
val memq : 'a -> set:'a array -> bool
val sort : cmp:('a -> 'a -> int) -> 'a array -> unit
val stable_sort : cmp:('a -> 'a -> int) -> 'a array -> unit
val fast_sort : cmp:('a -> 'a -> int) -> 'a array -> unit
val to_seq : 'a array -> 'a Stdlib.Seq.t
val to_seqi : 'a array -> (int * 'a) Stdlib.Seq.t
val of_seq : 'a Stdlib.Seq.t -> 'a array
val unsafe_get : 'a array -> int -> 'a
val unsafe_set : 'a array -> int -> 'a -> unit
module Floatarray : sig ... end
\ No newline at end of file +unit
val to_list : 'a array -> 'a list
val of_list : 'a list -> 'a array
val iter : f:('a -> unit) -> 'a array -> unit
val iteri : f:(int -> 'a -> unit) -> 'a array -> unit
val map : f:('a -> 'b) -> 'a array -> 'b array
val mapi : f:(int -> 'a -> 'b) -> 'a array -> 'b array
val fold_left : f:('a -> 'b -> 'a) -> init:'a -> 'b array -> 'a
val fold_left_map : f:('a -> 'b -> 'a * 'c) -> init:'a -> 'b array -> 'a * 'c array
val fold_right : f:('b -> 'a -> 'a) -> 'b array -> init:'a -> 'a
val iter2 : f:('a -> 'b -> unit) -> 'a array -> 'b array -> unit
val map2 : f:('a -> 'b -> 'c) -> 'a array -> 'b array -> 'c array
val for_all : f:('a -> bool) -> 'a array -> bool
val exists : f:('a -> bool) -> 'a array -> bool
val for_all2 : f:('a -> 'b -> bool) -> 'a array -> 'b array -> bool
val exists2 : f:('a -> 'b -> bool) -> 'a array -> 'b array -> bool
val mem : 'a -> set:'a array -> bool
val memq : 'a -> set:'a array -> bool
val find_opt : f:('a -> bool) -> 'a array -> 'a option
val find_map : f:('a -> 'b option) -> 'a array -> 'b option
val split : ('a * 'b) array -> 'a array * 'b array
val combine : 'a array -> 'b array -> ('a * 'b) array
val sort : cmp:('a -> 'a -> int) -> 'a array -> unit
val stable_sort : cmp:('a -> 'a -> int) -> 'a array -> unit
val fast_sort : cmp:('a -> 'a -> int) -> 'a array -> unit
val to_seq : 'a array -> 'a Stdlib.Seq.t
val to_seqi : 'a array -> (int * 'a) Stdlib.Seq.t
val of_seq : 'a Stdlib.Seq.t -> 'a array
val unsafe_get : 'a array -> int -> 'a
val unsafe_set : 'a array -> int -> 'a -> unit
module Floatarray : sig ... end
\ No newline at end of file diff --git a/dev/containers/CCShimsArray_/index.html b/dev/containers/CCShimsArray_/index.html index 52004a08..7da04b21 100644 --- a/dev/containers/CCShimsArray_/index.html +++ b/dev/containers/CCShimsArray_/index.html @@ -1,2 +1,2 @@ -CCShimsArray_ (containers.CCShimsArray_)

Module CCShimsArray_

include module type of struct include Stdlib.Array end
type !'a t = 'a array
val length : 'a array -> int
val get : 'a array -> int -> 'a
val set : 'a array -> int -> 'a -> unit
val make : int -> 'a -> 'a array
val create : int -> 'a -> 'a array
val create_float : int -> float array
val make_float : int -> float array
val init : int -> (int -> 'a) -> 'a array
val make_matrix : int -> int -> 'a -> 'a array array
val create_matrix : int -> int -> 'a -> 'a array array
val append : 'a array -> 'a array -> 'a array
val concat : 'a array list -> 'a array
val sub : 'a array -> int -> int -> 'a array
val copy : 'a array -> 'a array
val fill : 'a array -> int -> int -> 'a -> unit
val blit : 'a array -> int -> 'a array -> int -> int -> unit
val to_list : 'a array -> 'a list
val of_list : 'a list -> 'a array
val iter : ('a -> unit) -> 'a array -> unit
val iteri : (int -> 'a -> unit) -> 'a array -> unit
val map : ('a -> 'b) -> 'a array -> 'b array
val mapi : (int -> 'a -> 'b) -> 'a array -> 'b array
val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b array -> 'a
val fold_right : ('b -> 'a -> 'a) -> 'b array -> 'a -> 'a
val iter2 : ('a -> 'b -> unit) -> 'a array -> 'b array -> unit
val map2 : ('a -> 'b -> 'c) -> 'a array -> 'b array -> 'c array
val for_all : ('a -> bool) -> 'a array -> bool
val exists : ('a -> bool) -> 'a array -> bool
val for_all2 : ('a -> 'b -> bool) -> 'a array -> 'b array -> bool
val exists2 : ('a -> 'b -> bool) -> 'a array -> 'b array -> bool
val mem : 'a -> 'a array -> bool
val memq : 'a -> 'a array -> bool
val sort : ('a -> 'a -> int) -> 'a array -> unit
val stable_sort : ('a -> 'a -> int) -> 'a array -> unit
val fast_sort : ('a -> 'a -> int) -> 'a array -> unit
val to_seq : 'a array -> 'a Stdlib.Seq.t
val to_seqi : 'a array -> (int * 'a) Stdlib.Seq.t
val of_seq : 'a Stdlib.Seq.t -> 'a array
val unsafe_get : 'a array -> int -> 'a
val unsafe_set : 'a array -> int -> 'a -> unit
module Floatarray = Stdlib__array.Floatarray
\ No newline at end of file +CCShimsArray_ (containers.CCShimsArray_)

Module CCShimsArray_

include module type of struct include Stdlib.Array end
type !'a t = 'a array
val length : 'a array -> int
val get : 'a array -> int -> 'a
val set : 'a array -> int -> 'a -> unit
val make : int -> 'a -> 'a array
val create : int -> 'a -> 'a array
val create_float : int -> float array
val make_float : int -> float array
val init : int -> (int -> 'a) -> 'a array
val make_matrix : int -> int -> 'a -> 'a array array
val create_matrix : int -> int -> 'a -> 'a array array
val append : 'a array -> 'a array -> 'a array
val concat : 'a array list -> 'a array
val sub : 'a array -> int -> int -> 'a array
val copy : 'a array -> 'a array
val fill : 'a array -> int -> int -> 'a -> unit
val blit : 'a array -> int -> 'a array -> int -> int -> unit
val to_list : 'a array -> 'a list
val of_list : 'a list -> 'a array
val iter : ('a -> unit) -> 'a array -> unit
val iteri : (int -> 'a -> unit) -> 'a array -> unit
val map : ('a -> 'b) -> 'a array -> 'b array
val mapi : (int -> 'a -> 'b) -> 'a array -> 'b array
val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b array -> 'a
val fold_left_map : ('a -> 'b -> 'a * 'c) -> 'a -> 'b array -> 'a * 'c array
val fold_right : ('b -> 'a -> 'a) -> 'b array -> 'a -> 'a
val iter2 : ('a -> 'b -> unit) -> 'a array -> 'b array -> unit
val map2 : ('a -> 'b -> 'c) -> 'a array -> 'b array -> 'c array
val for_all : ('a -> bool) -> 'a array -> bool
val exists : ('a -> bool) -> 'a array -> bool
val for_all2 : ('a -> 'b -> bool) -> 'a array -> 'b array -> bool
val exists2 : ('a -> 'b -> bool) -> 'a array -> 'b array -> bool
val mem : 'a -> 'a array -> bool
val memq : 'a -> 'a array -> bool
val find_opt : ('a -> bool) -> 'a array -> 'a option
val find_map : ('a -> 'b option) -> 'a array -> 'b option
val split : ('a * 'b) array -> 'a array * 'b array
val combine : 'a array -> 'b array -> ('a * 'b) array
val sort : ('a -> 'a -> int) -> 'a array -> unit
val stable_sort : ('a -> 'a -> int) -> 'a array -> unit
val fast_sort : ('a -> 'a -> int) -> 'a array -> unit
val to_seq : 'a array -> 'a Stdlib.Seq.t
val to_seqi : 'a array -> (int * 'a) Stdlib.Seq.t
val of_seq : 'a Stdlib.Seq.t -> 'a array
val unsafe_get : 'a array -> int -> 'a
val unsafe_set : 'a array -> int -> 'a -> unit
module Floatarray = Stdlib__Array.Floatarray
\ No newline at end of file diff --git a/dev/containers/CCShimsInt_/index.html b/dev/containers/CCShimsInt_/index.html index da0b758e..b56c16d5 100644 --- a/dev/containers/CCShimsInt_/index.html +++ b/dev/containers/CCShimsInt_/index.html @@ -1,2 +1,2 @@ -CCShimsInt_ (containers.CCShimsInt_)

Module CCShimsInt_

include module type of struct include Stdlib.Int end
type t = int
val zero : int
val one : int
val minus_one : int
val neg : int -> int
val add : int -> int -> int
val sub : int -> int -> int
val mul : int -> int -> int
val div : int -> int -> int
val rem : int -> int -> int
val succ : int -> int
val pred : int -> int
val abs : int -> int
val max_int : int
val min_int : int
val logand : int -> int -> int
val logor : int -> int -> int
val logxor : int -> int -> int
val lognot : int -> int
val shift_left : int -> int -> int
val shift_right : int -> int -> int
val shift_right_logical : int -> int -> int
val equal : int -> int -> bool
val compare : int -> int -> int
val to_float : int -> float
val of_float : float -> int
val to_string : int -> string
\ No newline at end of file +CCShimsInt_ (containers.CCShimsInt_)

Module CCShimsInt_

include module type of struct include Stdlib.Int end
type t = int
val zero : int
val one : int
val minus_one : int
val neg : int -> int
val add : int -> int -> int
val sub : int -> int -> int
val mul : int -> int -> int
val div : int -> int -> int
val rem : int -> int -> int
val succ : int -> int
val pred : int -> int
val abs : int -> int
val max_int : int
val min_int : int
val logand : int -> int -> int
val logor : int -> int -> int
val logxor : int -> int -> int
val lognot : int -> int
val shift_left : int -> int -> int
val shift_right : int -> int -> int
val shift_right_logical : int -> int -> int
val equal : int -> int -> bool
val compare : int -> int -> int
val min : int -> int -> int
val max : int -> int -> int
val to_float : int -> float
val of_float : float -> int
val to_string : int -> string
\ No newline at end of file diff --git a/dev/containers/CCString/index.html b/dev/containers/CCString/index.html index be22883b..9b65ba4f 100644 --- a/dev/containers/CCString/index.html +++ b/dev/containers/CCString/index.html @@ -1,3 +1,3 @@ -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
include module type of struct include Stdlib.String end
type t = string
val make : int -> char -> string
val init : int -> (int -> char) -> string
val get : string -> int -> char
val concat : string -> string list -> string
val equal : t -> t -> bool
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 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 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_seqi : t -> (int * char) Stdlib.Seq.t
val create : int -> bytes
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 -> +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
include module type of struct include Stdlib.String end
type t = string
val make : int -> char -> string
val init : int -> (int -> char) -> string
val empty : string
val of_bytes : bytes -> string
val to_bytes : string -> bytes
val get : string -> int -> char
val concat : string -> string list -> string
val cat : string -> string -> string
val equal : t -> t -> bool
val starts_with : prefix:string -> string -> bool
val ends_with : suffix:string -> string -> bool
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 map : (char -> char) -> string -> string
val mapi : (int -> char -> char) -> string -> string
val fold_left : ('a -> char -> 'a) -> 'a -> string -> 'a
val fold_right : (char -> 'a -> 'a) -> string -> 'a -> 'a
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 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_seqi : t -> (int * char) Stdlib.Seq.t
val create : int -> bytes
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 get_uint8 : string -> int -> int
val get_int8 : string -> int -> int
val get_uint16_ne : string -> int -> int
val get_uint16_be : string -> int -> int
val get_uint16_le : string -> int -> int
val get_int16_ne : string -> int -> int
val get_int16_be : string -> int -> int
val get_int16_le : string -> int -> int
val get_int32_ne : string -> int -> int32
val get_int32_be : string -> int -> int32
val get_int32_le : string -> int -> int32
val get_int64_ne : string -> int -> int64
val get_int64_be : string -> int -> int64
val get_int64_le : string -> int -> int64
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 aa379a90..4ea39055 100644 --- a/dev/containers/CCStringLabels/index.html +++ b/dev/containers/CCStringLabels/index.html @@ -1,4 +1,4 @@ -CCStringLabels (containers.CCStringLabels)

Module CCStringLabels

Basic String Utils (Labeled version of CCString)

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

Fast internal iterator.

  • since 2.8
type 'a gen = unit -> 'a option
include module type of struct include Stdlib.StringLabels end
type t = string
val make : int -> char -> string
val init : int -> f:(int -> char) -> string
val get : string -> int -> char
val concat : sep:string -> string list -> string
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 map : f:(char -> char) -> string -> string
val mapi : f:(int -> char -> char) -> string -> string
val trim : string -> string
val escaped : string -> string
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_seqi : t -> (int * char) Stdlib.Seq.t
val create : int -> bytes
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 -> +CCStringLabels (containers.CCStringLabels)

Module CCStringLabels

Basic String Utils (Labeled version of CCString)

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

Fast internal iterator.

  • since 2.8
type 'a gen = unit -> 'a option
include module type of struct include Stdlib.StringLabels end
type t = string
val make : int -> char -> string
val init : int -> f:(int -> char) -> string
val empty : string
val of_bytes : bytes -> string
val to_bytes : string -> bytes
val get : string -> int -> char
val concat : sep:string -> string list -> string
val cat : string -> string -> string
val starts_with : prefix:string -> string -> bool
val ends_with : suffix:string -> string -> bool
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 map : f:(char -> char) -> string -> string
val mapi : f:(int -> char -> char) -> string -> string
val fold_left : f:('a -> char -> 'a) -> init:'a -> string -> 'a
val fold_right : f:(char -> 'a -> 'a) -> string -> init:'a -> 'a
val trim : string -> string
val escaped : string -> string
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_seqi : t -> (int * char) Stdlib.Seq.t
val create : int -> bytes
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 get_uint8 : string -> int -> int
val get_int8 : string -> int -> int
val get_uint16_ne : string -> int -> int
val get_uint16_be : string -> int -> int
val get_uint16_le : string -> int -> int
val get_int16_ne : string -> int -> int
val get_int16_be : string -> int -> int
val get_int16_le : string -> int -> int
val get_int32_ne : string -> int -> int32
val get_int32_be : string -> int -> int32
val get_int32_le : string -> int -> int32
val get_int64_ne : string -> int -> int64
val get_int64_be : string -> int -> int64
val get_int64_le : string -> int -> int64
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/containers/Containers/Hashtbl/Make/index.html b/dev/containers/Containers/Hashtbl/Make/index.html index e78af2e7..39c477b2 100644 --- a/dev/containers/Containers/Hashtbl/Make/index.html +++ b/dev/containers/Containers/Hashtbl/Make/index.html @@ -1,2 +1,2 @@ -Make (containers.Containers.Hashtbl.Make)

Module Hashtbl.Make

Parameters

module H : Stdlib__hashtbl.HashedType

Signature

type key = H.t
type !'a t = 'a Stdlib__hashtbl.Make(H).t
val create : int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val copy : 'a t -> 'a t
val add : 'a t -> key -> 'a -> unit
val remove : 'a t -> key -> unit
val find : 'a t -> key -> 'a
val find_opt : 'a t -> key -> 'a option
val find_all : 'a t -> key -> 'a list
val replace : 'a t -> key -> 'a -> unit
val mem : 'a t -> key -> bool
val iter : (key -> 'a -> unit) -> 'a t -> unit
val filter_map_inplace : (key -> 'a -> 'a option) -> 'a t -> unit
val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
val length : 'a t -> int
val stats : 'a t -> Stdlib__hashtbl.statistics
val to_seq : 'a t -> (key * 'a) Stdlib.Seq.t
val to_seq_keys : 'a t -> key Stdlib.Seq.t
val to_seq_values : 'a t -> 'a Stdlib.Seq.t
val add_seq : 'a t -> (key * 'a) Stdlib.Seq.t -> unit
val replace_seq : 'a t -> (key * 'a) Stdlib.Seq.t -> unit
val of_seq : (key * 'a) Stdlib.Seq.t -> 'a t
\ No newline at end of file +Make (containers.Containers.Hashtbl.Make)

Module Hashtbl.Make

Parameters

module H : Stdlib__Hashtbl.HashedType

Signature

type key = H.t
type !'a t = 'a Stdlib__Hashtbl.Make(H).t
val create : int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val copy : 'a t -> 'a t
val add : 'a t -> key -> 'a -> unit
val remove : 'a t -> key -> unit
val find : 'a t -> key -> 'a
val find_opt : 'a t -> key -> 'a option
val find_all : 'a t -> key -> 'a list
val replace : 'a t -> key -> 'a -> unit
val mem : 'a t -> key -> bool
val iter : (key -> 'a -> unit) -> 'a t -> unit
val filter_map_inplace : (key -> 'a -> 'a option) -> 'a t -> unit
val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
val length : 'a t -> int
val stats : 'a t -> Stdlib__Hashtbl.statistics
val to_seq : 'a t -> (key * 'a) Stdlib.Seq.t
val to_seq_keys : 'a t -> key Stdlib.Seq.t
val to_seq_values : 'a t -> 'a Stdlib.Seq.t
val add_seq : 'a t -> (key * 'a) Stdlib.Seq.t -> unit
val replace_seq : 'a t -> (key * 'a) Stdlib.Seq.t -> unit
val of_seq : (key * 'a) Stdlib.Seq.t -> 'a t
\ No newline at end of file diff --git a/dev/containers/Containers/Hashtbl/MakeSeeded/index.html b/dev/containers/Containers/Hashtbl/MakeSeeded/index.html index 7ce70dde..b25faf67 100644 --- a/dev/containers/Containers/Hashtbl/MakeSeeded/index.html +++ b/dev/containers/Containers/Hashtbl/MakeSeeded/index.html @@ -1,2 +1,2 @@ -MakeSeeded (containers.Containers.Hashtbl.MakeSeeded)

Module Hashtbl.MakeSeeded

Parameters

module H : SeededHashedType

Signature

type key = H.t
type !'a t = 'a Stdlib__hashtbl.MakeSeeded(H).t
val create : ?random:bool -> int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val copy : 'a t -> 'a t
val add : 'a t -> key -> 'a -> unit
val remove : 'a t -> key -> unit
val find : 'a t -> key -> 'a
val find_opt : 'a t -> key -> 'a option
val find_all : 'a t -> key -> 'a list
val replace : 'a t -> key -> 'a -> unit
val mem : 'a t -> key -> bool
val iter : (key -> 'a -> unit) -> 'a t -> unit
val filter_map_inplace : (key -> 'a -> 'a option) -> 'a t -> unit
val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
val length : 'a t -> int
val stats : 'a t -> statistics
val to_seq : 'a t -> (key * 'a) Stdlib.Seq.t
val to_seq_keys : 'a t -> key Stdlib.Seq.t
val to_seq_values : 'a t -> 'a Stdlib.Seq.t
val add_seq : 'a t -> (key * 'a) Stdlib.Seq.t -> unit
val replace_seq : 'a t -> (key * 'a) Stdlib.Seq.t -> unit
val of_seq : (key * 'a) Stdlib.Seq.t -> 'a t
\ No newline at end of file +MakeSeeded (containers.Containers.Hashtbl.MakeSeeded)

Module Hashtbl.MakeSeeded

Parameters

module H : SeededHashedType

Signature

type key = H.t
type !'a t = 'a Stdlib__Hashtbl.MakeSeeded(H).t
val create : ?random:bool -> int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val copy : 'a t -> 'a t
val add : 'a t -> key -> 'a -> unit
val remove : 'a t -> key -> unit
val find : 'a t -> key -> 'a
val find_opt : 'a t -> key -> 'a option
val find_all : 'a t -> key -> 'a list
val replace : 'a t -> key -> 'a -> unit
val mem : 'a t -> key -> bool
val iter : (key -> 'a -> unit) -> 'a t -> unit
val filter_map_inplace : (key -> 'a -> 'a option) -> 'a t -> unit
val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
val length : 'a t -> int
val stats : 'a t -> statistics
val to_seq : 'a t -> (key * 'a) Stdlib.Seq.t
val to_seq_keys : 'a t -> key Stdlib.Seq.t
val to_seq_values : 'a t -> 'a Stdlib.Seq.t
val add_seq : 'a t -> (key * 'a) Stdlib.Seq.t -> unit
val replace_seq : 'a t -> (key * 'a) Stdlib.Seq.t -> unit
val of_seq : (key * 'a) Stdlib.Seq.t -> 'a t
\ No newline at end of file diff --git a/dev/containers/Containers/Hashtbl/index.html b/dev/containers/Containers/Hashtbl/index.html index 8cabf807..420de0e8 100644 --- a/dev/containers/Containers/Hashtbl/index.html +++ b/dev/containers/Containers/Hashtbl/index.html @@ -1,6 +1,6 @@ Hashtbl (containers.Containers.Hashtbl)

Module Containers.Hashtbl

  • since 0.14
include module type of Stdlib.Hashtbl with type statistics = Stdlib.Hashtbl.statistics and module Make -= Stdlib.Hashtbl.Make and type ('a, 'b) t = ('a'b) Stdlib.Hashtbl.t
type (!'a, !'b) t = ('a'b) Stdlib.Hashtbl.t
val create : ?random:bool -> int -> ('a'b) t
val clear : ('a'b) t -> unit
val reset : ('a'b) t -> unit
val copy : ('a'b) t -> ('a'b) t
val add : ('a'b) t -> 'a -> 'b -> unit
val find : ('a'b) t -> 'a -> 'b
val find_opt : ('a'b) t -> 'a -> 'b option
val find_all : ('a'b) t -> 'a -> 'b list
val mem : ('a'b) t -> 'a -> bool
val remove : ('a'b) t -> 'a -> unit
val replace : ('a'b) t -> 'a -> 'b -> unit
val iter : ('a -> 'b -> unit) -> ('a'b) t -> unit
val filter_map_inplace : ('a -> 'b -> 'b option) -> ('a'b) t -> unit
val fold : ('a -> 'b -> 'c -> 'c) -> ('a'b) t -> 'c -> 'c
val length : ('a'b) t -> int
val randomize : unit -> unit
val is_randomized : unit -> bool
val rebuild : ?random:bool -> ('a'b) t -> ('a'b) t
type statistics = Stdlib.Hashtbl.statistics = {
num_bindings : int;
num_buckets : int;
max_bucket_length : int;
bucket_histogram : int array;
}
val stats : ('a'b) t -> statistics
val to_seq : ('a'b) t -> ('a * 'b) Stdlib.Seq.t
val to_seq_keys : ('a'b) t -> 'a Stdlib.Seq.t
val to_seq_values : ('a'b) t -> 'b Stdlib.Seq.t
val replace_seq : ('a'b) t -> ('a * 'b) Stdlib.Seq.t -> unit
module type HashedType = sig ... end
module type S = sig ... end
module Make (H : Stdlib__hashtbl.HashedType) : sig ... end
module type SeededHashedType = sig ... end
module type SeededS = sig ... end
module MakeSeeded (H : SeededHashedType) : sig ... end
val hash : 'a -> int
val seeded_hash : int -> 'a -> int
val hash_param : int -> int -> 'a -> int
val seeded_hash_param : int -> int -> int -> 'a -> int
include module type of struct include CCHashtbl.Poly end
val get : ('a'b) Stdlib.Hashtbl.t -> 'a -> 'b option

get tbl k finds a binding for the key k if present, or returns None if no value is found. Safe version of Hashtbl.find.

val get_or : ('a'b) Stdlib.Hashtbl.t -> 'a -> default:'b -> 'b

get_or tbl k ~default returns the value associated to k if present, and returns default otherwise (if k doesn't belong in tbl).

  • since 0.16
val keys : ('a'b) Stdlib.Hashtbl.t -> 'a CCHashtbl.iter

keys tbl f iterates on keys (similar order as Hashtbl.iter).

val values : ('a'b) Stdlib.Hashtbl.t -> 'b CCHashtbl.iter

values tbl f iterates on values in the table tbl.

val keys_list : ('a'b) Stdlib.Hashtbl.t -> 'a list

keys_list tbl is the list of keys in tbl. If the key is in the Hashtable multiple times, all occurrences will be returned.

  • since 0.8
val values_list : ('a'b) Stdlib.Hashtbl.t -> 'b list

values_list tbl is the list of values in tbl.

  • since 0.8
val map_list : ('a -> 'b -> 'c) -> ('a'b) Stdlib.Hashtbl.t -> 'c list

map_list f tbl maps on a tbl's items. Collect into a list.

val incr : ?by:int -> ('a, int) Stdlib.Hashtbl.t -> 'a -> unit

incr ?by tbl x increments or initializes the counter associated with x. If get tbl x = None, then after update, get tbl x = Some 1; otherwise, if get tbl x = Some n, now get tbl x = Some (n+1).

  • parameter by

    if specified, the int value is incremented by by rather than 1.

  • since 0.16
val decr : ?by:int -> ('a, int) Stdlib.Hashtbl.t -> 'a -> unit

decr ?by tbl x is like incr but subtract 1 (or the value of by). If the value reaches 0, the key is removed from the table. This does nothing if the key is not already present in the table.

  • since 0.16
val to_iter : ('a'b) Stdlib.Hashtbl.t -> ('a * 'b) CCHashtbl.iter

Iterate on bindings in the table.

  • since 2.8
val add_list : ('a'b list) Stdlib.Hashtbl.t -> 'a -> 'b -> unit

add_list tbl x y adds y to the list x is bound to. If x is not bound, it becomes bound to y.

  • since 0.16
val add_iter : ('a'b) Stdlib.Hashtbl.t -> ('a * 'b) CCHashtbl.iter -> unit

Add the corresponding pairs to the table, using Hashtbl.add.

  • since 2.8
val add_iter_with : f:('a -> 'b -> 'b -> 'b) -> += Stdlib.Hashtbl.Make and type ('a, 'b) t = ('a'b) Stdlib.Hashtbl.t
type (!'a, !'b) t = ('a'b) Stdlib.Hashtbl.t
val create : ?random:bool -> int -> ('a'b) t
val clear : ('a'b) t -> unit
val reset : ('a'b) t -> unit
val copy : ('a'b) t -> ('a'b) t
val add : ('a'b) t -> 'a -> 'b -> unit
val find : ('a'b) t -> 'a -> 'b
val find_opt : ('a'b) t -> 'a -> 'b option
val find_all : ('a'b) t -> 'a -> 'b list
val mem : ('a'b) t -> 'a -> bool
val remove : ('a'b) t -> 'a -> unit
val replace : ('a'b) t -> 'a -> 'b -> unit
val iter : ('a -> 'b -> unit) -> ('a'b) t -> unit
val filter_map_inplace : ('a -> 'b -> 'b option) -> ('a'b) t -> unit
val fold : ('a -> 'b -> 'c -> 'c) -> ('a'b) t -> 'c -> 'c
val length : ('a'b) t -> int
val randomize : unit -> unit
val is_randomized : unit -> bool
val rebuild : ?random:bool -> ('a'b) t -> ('a'b) t
type statistics = Stdlib.Hashtbl.statistics = {
num_bindings : int;
num_buckets : int;
max_bucket_length : int;
bucket_histogram : int array;
}
val stats : ('a'b) t -> statistics
val to_seq : ('a'b) t -> ('a * 'b) Stdlib.Seq.t
val to_seq_keys : ('a'b) t -> 'a Stdlib.Seq.t
val to_seq_values : ('a'b) t -> 'b Stdlib.Seq.t
val replace_seq : ('a'b) t -> ('a * 'b) Stdlib.Seq.t -> unit
module type HashedType = sig ... end
module type S = sig ... end
module Make (H : Stdlib__Hashtbl.HashedType) : sig ... end
module type SeededHashedType = sig ... end
module type SeededS = sig ... end
module MakeSeeded (H : SeededHashedType) : sig ... end
val hash : 'a -> int
val seeded_hash : int -> 'a -> int
val hash_param : int -> int -> 'a -> int
val seeded_hash_param : int -> int -> int -> 'a -> int
include module type of struct include CCHashtbl.Poly end
val get : ('a'b) Stdlib.Hashtbl.t -> 'a -> 'b option

get tbl k finds a binding for the key k if present, or returns None if no value is found. Safe version of Hashtbl.find.

val get_or : ('a'b) Stdlib.Hashtbl.t -> 'a -> default:'b -> 'b

get_or tbl k ~default returns the value associated to k if present, and returns default otherwise (if k doesn't belong in tbl).

  • since 0.16
val keys : ('a'b) Stdlib.Hashtbl.t -> 'a CCHashtbl.iter

keys tbl f iterates on keys (similar order as Hashtbl.iter).

val values : ('a'b) Stdlib.Hashtbl.t -> 'b CCHashtbl.iter

values tbl f iterates on values in the table tbl.

val keys_list : ('a'b) Stdlib.Hashtbl.t -> 'a list

keys_list tbl is the list of keys in tbl. If the key is in the Hashtable multiple times, all occurrences will be returned.

  • since 0.8
val values_list : ('a'b) Stdlib.Hashtbl.t -> 'b list

values_list tbl is the list of values in tbl.

  • since 0.8
val map_list : ('a -> 'b -> 'c) -> ('a'b) Stdlib.Hashtbl.t -> 'c list

map_list f tbl maps on a tbl's items. Collect into a list.

val incr : ?by:int -> ('a, int) Stdlib.Hashtbl.t -> 'a -> unit

incr ?by tbl x increments or initializes the counter associated with x. If get tbl x = None, then after update, get tbl x = Some 1; otherwise, if get tbl x = Some n, now get tbl x = Some (n+1).

  • parameter by

    if specified, the int value is incremented by by rather than 1.

  • since 0.16
val decr : ?by:int -> ('a, int) Stdlib.Hashtbl.t -> 'a -> unit

decr ?by tbl x is like incr but subtract 1 (or the value of by). If the value reaches 0, the key is removed from the table. This does nothing if the key is not already present in the table.

  • since 0.16
val to_iter : ('a'b) Stdlib.Hashtbl.t -> ('a * 'b) CCHashtbl.iter

Iterate on bindings in the table.

  • since 2.8
val add_list : ('a'b list) Stdlib.Hashtbl.t -> 'a -> 'b -> unit

add_list tbl x y adds y to the list x is bound to. If x is not bound, it becomes bound to y.

  • since 0.16
val add_iter : ('a'b) Stdlib.Hashtbl.t -> ('a * 'b) CCHashtbl.iter -> unit

Add the corresponding pairs to the table, using Hashtbl.add.

  • since 2.8
val add_iter_with : f:('a -> 'b -> 'b -> 'b) -> ('a'b) Stdlib.Hashtbl.t -> ('a * 'b) CCHashtbl.iter -> unit

Add the corresponding pairs to the table, using Hashtbl.add. If a key occurs multiple times in the input, the values are combined using f in an unspecified order.

  • since 3.3
val add_seq : ('a'b) Stdlib.Hashtbl.t -> ('a * 'b) Stdlib.Seq.t -> unit

Add the corresponding pairs to the table, using Hashtbl.add. Renamed from add_std_seq since 3.0.

  • since 3.0
val add_seq_with : f:('a -> 'b -> 'b -> 'b) -> ('a'b) Stdlib.Hashtbl.t -> ('a * 'b) Stdlib.Seq.t -> unit

Add the corresponding pairs to the table. If a key occurs multiple times in the input, the values are combined using f in an unspecified order.

  • since 3.3
val of_iter : ('a * 'b) CCHashtbl.iter -> ('a'b) Stdlib.Hashtbl.t

From the given bindings, added in order.

  • since 2.8
val of_iter_with : f:('a -> 'b -> 'b -> 'b) -> ('a * 'b) CCHashtbl.iter -> ('a'b) Stdlib.Hashtbl.t

From the given bindings, added in order. If a key occurs multiple times in the input, the values are combined using f in an unspecified order.

  • since 3.3
val of_seq : ('a * 'b) Stdlib.Seq.t -> ('a'b) Stdlib.Hashtbl.t

From the given bindings, added in order. Renamed from of_std_seq since 3.0.

  • since 3.0
val of_seq_with : f:('a -> 'b -> 'b -> 'b) -> ('a * 'b) Stdlib.Seq.t -> ('a'b) Stdlib.Hashtbl.t

From the given bindings, added in order. If a key occurs multiple times in the input, the values are combined using f in an unspecified order.

  • since 3.3
val add_iter_count : ('a, int) Stdlib.Hashtbl.t -> 'a CCHashtbl.iter -> unit

add_iter_count tbl i increments the count of each element of i by calling incr. This is useful for counting how many times each element of i occurs.

  • since 2.8
val add_seq_count : ('a, int) Stdlib.Hashtbl.t -> 'a Stdlib.Seq.t -> unit

add_seq_count tbl seq increments the count of each element of seq by calling incr. This is useful for counting how many times each element of seq occurs. Renamed from add_std_seq_count since 3.0.

  • since 3.0
val of_iter_count : 'a CCHashtbl.iter -> ('a, int) Stdlib.Hashtbl.t

Like add_seq_count, but allocates a new table and returns it.

  • since 2.8
val of_seq_count : 'a Stdlib.Seq.t -> ('a, int) Stdlib.Hashtbl.t

Like add_seq_count, but allocates a new table and returns it. Renamed from of_std_seq_count since 3.0.

  • since 3.0
val to_list : ('a'b) Stdlib.Hashtbl.t -> ('a * 'b) list

to_list tbl returns the list of (key,value) bindings (order unspecified).

val of_list : ('a * 'b) list -> ('a'b) Stdlib.Hashtbl.t

of_list l builds a table from the given list l of bindings k_i -> v_i, added in order using add. If a key occurs several times, it will be added several times, and the visible binding will be the last one.

val of_list_with : f:('a -> 'b -> 'b -> 'b) -> ('a * 'b) list -> ('a'b) Stdlib.Hashtbl.t

From the given bindings, added in order. If a key occurs multiple times in the input, the values are combined using f in an unspecified order.

  • since 3.3
val update : ('a'b) Stdlib.Hashtbl.t -> f:('a -> 'b option -> 'b option) -> k:'a -> unit

update tbl ~f ~k updates key k by calling f k (Some v) if k was mapped to v, or f k None otherwise; if the call returns None then k is removed/stays removed, if the call returns Some v' then the binding k -> v' is inserted using Hashtbl.replace.

  • since 0.14
val get_or_add : ('a'b) Stdlib.Hashtbl.t -> f:('a -> 'b) -> k:'a -> 'b

get_or_add tbl ~k ~f finds and returns the binding of k in tbl, if it exists. If it does not exist, then f k is called to obtain a new binding v; k -> v is added to tbl and v is returned.

  • since 1.0
val pp : ?pp_start:unit CCHashtbl.printer -> ?pp_stop:unit CCHashtbl.printer -> ?pp_sep:unit CCHashtbl.printer -> ?pp_arrow:unit CCHashtbl.printer -> 'a CCHashtbl.printer -> 'b CCHashtbl.printer -> ('a'b) Stdlib.Hashtbl.t CCHashtbl.printer

pp ~pp_start ~pp_stop ~pp_sep ~pp arrow pp_k pp_v returns a table printer given a pp_k printer for individual key and a pp_v printer for individual value. pp_start and pp_stop control the opening and closing delimiters, by default print nothing. pp_sep control the separator between binding. pp_arrow control the arrow between the key and value. Renamed from print since 2.0.

  • since 0.13
module type S' = CCHashtbl.S
module Make' = CCHashtbl.Make
\ No newline at end of file diff --git a/dev/containers/ContainersLabels/Hashtbl/Make/index.html b/dev/containers/ContainersLabels/Hashtbl/Make/index.html index 7235b06b..46164ade 100644 --- a/dev/containers/ContainersLabels/Hashtbl/Make/index.html +++ b/dev/containers/ContainersLabels/Hashtbl/Make/index.html @@ -1,2 +1,2 @@ -Make (containers.ContainersLabels.Hashtbl.Make)

Module Hashtbl.Make

Parameters

module H : Stdlib__hashtbl.HashedType

Signature

type key = H.t
type !'a t = 'a Stdlib__hashtbl.Make(H).t
val create : int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val copy : 'a t -> 'a t
val add : 'a t -> key -> 'a -> unit
val remove : 'a t -> key -> unit
val find : 'a t -> key -> 'a
val find_opt : 'a t -> key -> 'a option
val find_all : 'a t -> key -> 'a list
val replace : 'a t -> key -> 'a -> unit
val mem : 'a t -> key -> bool
val iter : (key -> 'a -> unit) -> 'a t -> unit
val filter_map_inplace : (key -> 'a -> 'a option) -> 'a t -> unit
val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
val length : 'a t -> int
val stats : 'a t -> Stdlib__hashtbl.statistics
val to_seq : 'a t -> (key * 'a) Stdlib.Seq.t
val to_seq_keys : 'a t -> key Stdlib.Seq.t
val to_seq_values : 'a t -> 'a Stdlib.Seq.t
val add_seq : 'a t -> (key * 'a) Stdlib.Seq.t -> unit
val replace_seq : 'a t -> (key * 'a) Stdlib.Seq.t -> unit
val of_seq : (key * 'a) Stdlib.Seq.t -> 'a t
\ No newline at end of file +Make (containers.ContainersLabels.Hashtbl.Make)

Module Hashtbl.Make

Parameters

module H : Stdlib__Hashtbl.HashedType

Signature

type key = H.t
type !'a t = 'a Stdlib__Hashtbl.Make(H).t
val create : int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val copy : 'a t -> 'a t
val add : 'a t -> key -> 'a -> unit
val remove : 'a t -> key -> unit
val find : 'a t -> key -> 'a
val find_opt : 'a t -> key -> 'a option
val find_all : 'a t -> key -> 'a list
val replace : 'a t -> key -> 'a -> unit
val mem : 'a t -> key -> bool
val iter : (key -> 'a -> unit) -> 'a t -> unit
val filter_map_inplace : (key -> 'a -> 'a option) -> 'a t -> unit
val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
val length : 'a t -> int
val stats : 'a t -> Stdlib__Hashtbl.statistics
val to_seq : 'a t -> (key * 'a) Stdlib.Seq.t
val to_seq_keys : 'a t -> key Stdlib.Seq.t
val to_seq_values : 'a t -> 'a Stdlib.Seq.t
val add_seq : 'a t -> (key * 'a) Stdlib.Seq.t -> unit
val replace_seq : 'a t -> (key * 'a) Stdlib.Seq.t -> unit
val of_seq : (key * 'a) Stdlib.Seq.t -> 'a t
\ No newline at end of file diff --git a/dev/containers/ContainersLabels/Hashtbl/MakeSeeded/index.html b/dev/containers/ContainersLabels/Hashtbl/MakeSeeded/index.html index 05bad718..b6676d82 100644 --- a/dev/containers/ContainersLabels/Hashtbl/MakeSeeded/index.html +++ b/dev/containers/ContainersLabels/Hashtbl/MakeSeeded/index.html @@ -1,2 +1,2 @@ -MakeSeeded (containers.ContainersLabels.Hashtbl.MakeSeeded)

Module Hashtbl.MakeSeeded

Parameters

module H : SeededHashedType

Signature

type key = H.t
type !'a t = 'a Stdlib__hashtbl.MakeSeeded(H).t
val create : ?random:bool -> int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val copy : 'a t -> 'a t
val add : 'a t -> key -> 'a -> unit
val remove : 'a t -> key -> unit
val find : 'a t -> key -> 'a
val find_opt : 'a t -> key -> 'a option
val find_all : 'a t -> key -> 'a list
val replace : 'a t -> key -> 'a -> unit
val mem : 'a t -> key -> bool
val iter : (key -> 'a -> unit) -> 'a t -> unit
val filter_map_inplace : (key -> 'a -> 'a option) -> 'a t -> unit
val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
val length : 'a t -> int
val stats : 'a t -> statistics
val to_seq : 'a t -> (key * 'a) Stdlib.Seq.t
val to_seq_keys : 'a t -> key Stdlib.Seq.t
val to_seq_values : 'a t -> 'a Stdlib.Seq.t
val add_seq : 'a t -> (key * 'a) Stdlib.Seq.t -> unit
val replace_seq : 'a t -> (key * 'a) Stdlib.Seq.t -> unit
val of_seq : (key * 'a) Stdlib.Seq.t -> 'a t
\ No newline at end of file +MakeSeeded (containers.ContainersLabels.Hashtbl.MakeSeeded)

Module Hashtbl.MakeSeeded

Parameters

module H : SeededHashedType

Signature

type key = H.t
type !'a t = 'a Stdlib__Hashtbl.MakeSeeded(H).t
val create : ?random:bool -> int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit
val copy : 'a t -> 'a t
val add : 'a t -> key -> 'a -> unit
val remove : 'a t -> key -> unit
val find : 'a t -> key -> 'a
val find_opt : 'a t -> key -> 'a option
val find_all : 'a t -> key -> 'a list
val replace : 'a t -> key -> 'a -> unit
val mem : 'a t -> key -> bool
val iter : (key -> 'a -> unit) -> 'a t -> unit
val filter_map_inplace : (key -> 'a -> 'a option) -> 'a t -> unit
val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
val length : 'a t -> int
val stats : 'a t -> statistics
val to_seq : 'a t -> (key * 'a) Stdlib.Seq.t
val to_seq_keys : 'a t -> key Stdlib.Seq.t
val to_seq_values : 'a t -> 'a Stdlib.Seq.t
val add_seq : 'a t -> (key * 'a) Stdlib.Seq.t -> unit
val replace_seq : 'a t -> (key * 'a) Stdlib.Seq.t -> unit
val of_seq : (key * 'a) Stdlib.Seq.t -> 'a t
\ No newline at end of file diff --git a/dev/containers/ContainersLabels/Hashtbl/index.html b/dev/containers/ContainersLabels/Hashtbl/index.html index 5c533ed8..3d170521 100644 --- a/dev/containers/ContainersLabels/Hashtbl/index.html +++ b/dev/containers/ContainersLabels/Hashtbl/index.html @@ -1,6 +1,6 @@ Hashtbl (containers.ContainersLabels.Hashtbl)

Module ContainersLabels.Hashtbl

  • since 0.14
include module type of Stdlib.Hashtbl with type statistics = Stdlib.Hashtbl.statistics and module Make -= Stdlib.Hashtbl.Make and type ('a, 'b) t = ('a'b) Stdlib.Hashtbl.t
type (!'a, !'b) t = ('a'b) Stdlib.Hashtbl.t
val create : ?random:bool -> int -> ('a'b) t
val clear : ('a'b) t -> unit
val reset : ('a'b) t -> unit
val copy : ('a'b) t -> ('a'b) t
val add : ('a'b) t -> 'a -> 'b -> unit
val find : ('a'b) t -> 'a -> 'b
val find_opt : ('a'b) t -> 'a -> 'b option
val find_all : ('a'b) t -> 'a -> 'b list
val mem : ('a'b) t -> 'a -> bool
val remove : ('a'b) t -> 'a -> unit
val replace : ('a'b) t -> 'a -> 'b -> unit
val iter : ('a -> 'b -> unit) -> ('a'b) t -> unit
val filter_map_inplace : ('a -> 'b -> 'b option) -> ('a'b) t -> unit
val fold : ('a -> 'b -> 'c -> 'c) -> ('a'b) t -> 'c -> 'c
val length : ('a'b) t -> int
val randomize : unit -> unit
val is_randomized : unit -> bool
val rebuild : ?random:bool -> ('a'b) t -> ('a'b) t
type statistics = Stdlib.Hashtbl.statistics = {
num_bindings : int;
num_buckets : int;
max_bucket_length : int;
bucket_histogram : int array;
}
val stats : ('a'b) t -> statistics
val to_seq : ('a'b) t -> ('a * 'b) Stdlib.Seq.t
val to_seq_keys : ('a'b) t -> 'a Stdlib.Seq.t
val to_seq_values : ('a'b) t -> 'b Stdlib.Seq.t
val replace_seq : ('a'b) t -> ('a * 'b) Stdlib.Seq.t -> unit
module type HashedType = sig ... end
module type S = sig ... end
module Make (H : Stdlib__hashtbl.HashedType) : sig ... end
module type SeededHashedType = sig ... end
module type SeededS = sig ... end
module MakeSeeded (H : SeededHashedType) : sig ... end
val hash : 'a -> int
val seeded_hash : int -> 'a -> int
val hash_param : int -> int -> 'a -> int
val seeded_hash_param : int -> int -> int -> 'a -> int
include module type of struct include CCHashtbl.Poly end
val get : ('a'b) Stdlib.Hashtbl.t -> 'a -> 'b option

get tbl k finds a binding for the key k if present, or returns None if no value is found. Safe version of Hashtbl.find.

val get_or : ('a'b) Stdlib.Hashtbl.t -> 'a -> default:'b -> 'b

get_or tbl k ~default returns the value associated to k if present, and returns default otherwise (if k doesn't belong in tbl).

  • since 0.16
val keys : ('a'b) Stdlib.Hashtbl.t -> 'a CCHashtbl.iter

keys tbl f iterates on keys (similar order as Hashtbl.iter).

val values : ('a'b) Stdlib.Hashtbl.t -> 'b CCHashtbl.iter

values tbl f iterates on values in the table tbl.

val keys_list : ('a'b) Stdlib.Hashtbl.t -> 'a list

keys_list tbl is the list of keys in tbl. If the key is in the Hashtable multiple times, all occurrences will be returned.

  • since 0.8
val values_list : ('a'b) Stdlib.Hashtbl.t -> 'b list

values_list tbl is the list of values in tbl.

  • since 0.8
val map_list : ('a -> 'b -> 'c) -> ('a'b) Stdlib.Hashtbl.t -> 'c list

map_list f tbl maps on a tbl's items. Collect into a list.

val incr : ?by:int -> ('a, int) Stdlib.Hashtbl.t -> 'a -> unit

incr ?by tbl x increments or initializes the counter associated with x. If get tbl x = None, then after update, get tbl x = Some 1; otherwise, if get tbl x = Some n, now get tbl x = Some (n+1).

  • parameter by

    if specified, the int value is incremented by by rather than 1.

  • since 0.16
val decr : ?by:int -> ('a, int) Stdlib.Hashtbl.t -> 'a -> unit

decr ?by tbl x is like incr but subtract 1 (or the value of by). If the value reaches 0, the key is removed from the table. This does nothing if the key is not already present in the table.

  • since 0.16
val to_iter : ('a'b) Stdlib.Hashtbl.t -> ('a * 'b) CCHashtbl.iter

Iterate on bindings in the table.

  • since 2.8
val add_list : ('a'b list) Stdlib.Hashtbl.t -> 'a -> 'b -> unit

add_list tbl x y adds y to the list x is bound to. If x is not bound, it becomes bound to y.

  • since 0.16
val add_iter : ('a'b) Stdlib.Hashtbl.t -> ('a * 'b) CCHashtbl.iter -> unit

Add the corresponding pairs to the table, using Hashtbl.add.

  • since 2.8
val add_iter_with : f:('a -> 'b -> 'b -> 'b) -> += Stdlib.Hashtbl.Make and type ('a, 'b) t = ('a'b) Stdlib.Hashtbl.t
type (!'a, !'b) t = ('a'b) Stdlib.Hashtbl.t
val create : ?random:bool -> int -> ('a'b) t
val clear : ('a'b) t -> unit
val reset : ('a'b) t -> unit
val copy : ('a'b) t -> ('a'b) t
val add : ('a'b) t -> 'a -> 'b -> unit
val find : ('a'b) t -> 'a -> 'b
val find_opt : ('a'b) t -> 'a -> 'b option
val find_all : ('a'b) t -> 'a -> 'b list
val mem : ('a'b) t -> 'a -> bool
val remove : ('a'b) t -> 'a -> unit
val replace : ('a'b) t -> 'a -> 'b -> unit
val iter : ('a -> 'b -> unit) -> ('a'b) t -> unit
val filter_map_inplace : ('a -> 'b -> 'b option) -> ('a'b) t -> unit
val fold : ('a -> 'b -> 'c -> 'c) -> ('a'b) t -> 'c -> 'c
val length : ('a'b) t -> int
val randomize : unit -> unit
val is_randomized : unit -> bool
val rebuild : ?random:bool -> ('a'b) t -> ('a'b) t
type statistics = Stdlib.Hashtbl.statistics = {
num_bindings : int;
num_buckets : int;
max_bucket_length : int;
bucket_histogram : int array;
}
val stats : ('a'b) t -> statistics
val to_seq : ('a'b) t -> ('a * 'b) Stdlib.Seq.t
val to_seq_keys : ('a'b) t -> 'a Stdlib.Seq.t
val to_seq_values : ('a'b) t -> 'b Stdlib.Seq.t
val replace_seq : ('a'b) t -> ('a * 'b) Stdlib.Seq.t -> unit
module type HashedType = sig ... end
module type S = sig ... end
module Make (H : Stdlib__Hashtbl.HashedType) : sig ... end
module type SeededHashedType = sig ... end
module type SeededS = sig ... end
module MakeSeeded (H : SeededHashedType) : sig ... end
val hash : 'a -> int
val seeded_hash : int -> 'a -> int
val hash_param : int -> int -> 'a -> int
val seeded_hash_param : int -> int -> int -> 'a -> int
include module type of struct include CCHashtbl.Poly end
val get : ('a'b) Stdlib.Hashtbl.t -> 'a -> 'b option

get tbl k finds a binding for the key k if present, or returns None if no value is found. Safe version of Hashtbl.find.

val get_or : ('a'b) Stdlib.Hashtbl.t -> 'a -> default:'b -> 'b

get_or tbl k ~default returns the value associated to k if present, and returns default otherwise (if k doesn't belong in tbl).

  • since 0.16
val keys : ('a'b) Stdlib.Hashtbl.t -> 'a CCHashtbl.iter

keys tbl f iterates on keys (similar order as Hashtbl.iter).

val values : ('a'b) Stdlib.Hashtbl.t -> 'b CCHashtbl.iter

values tbl f iterates on values in the table tbl.

val keys_list : ('a'b) Stdlib.Hashtbl.t -> 'a list

keys_list tbl is the list of keys in tbl. If the key is in the Hashtable multiple times, all occurrences will be returned.

  • since 0.8
val values_list : ('a'b) Stdlib.Hashtbl.t -> 'b list

values_list tbl is the list of values in tbl.

  • since 0.8
val map_list : ('a -> 'b -> 'c) -> ('a'b) Stdlib.Hashtbl.t -> 'c list

map_list f tbl maps on a tbl's items. Collect into a list.

val incr : ?by:int -> ('a, int) Stdlib.Hashtbl.t -> 'a -> unit

incr ?by tbl x increments or initializes the counter associated with x. If get tbl x = None, then after update, get tbl x = Some 1; otherwise, if get tbl x = Some n, now get tbl x = Some (n+1).

  • parameter by

    if specified, the int value is incremented by by rather than 1.

  • since 0.16
val decr : ?by:int -> ('a, int) Stdlib.Hashtbl.t -> 'a -> unit

decr ?by tbl x is like incr but subtract 1 (or the value of by). If the value reaches 0, the key is removed from the table. This does nothing if the key is not already present in the table.

  • since 0.16
val to_iter : ('a'b) Stdlib.Hashtbl.t -> ('a * 'b) CCHashtbl.iter

Iterate on bindings in the table.

  • since 2.8
val add_list : ('a'b list) Stdlib.Hashtbl.t -> 'a -> 'b -> unit

add_list tbl x y adds y to the list x is bound to. If x is not bound, it becomes bound to y.

  • since 0.16
val add_iter : ('a'b) Stdlib.Hashtbl.t -> ('a * 'b) CCHashtbl.iter -> unit

Add the corresponding pairs to the table, using Hashtbl.add.

  • since 2.8
val add_iter_with : f:('a -> 'b -> 'b -> 'b) -> ('a'b) Stdlib.Hashtbl.t -> ('a * 'b) CCHashtbl.iter -> unit

Add the corresponding pairs to the table, using Hashtbl.add. If a key occurs multiple times in the input, the values are combined using f in an unspecified order.

  • since 3.3
val add_seq : ('a'b) Stdlib.Hashtbl.t -> ('a * 'b) Stdlib.Seq.t -> unit

Add the corresponding pairs to the table, using Hashtbl.add. Renamed from add_std_seq since 3.0.

  • since 3.0
val add_seq_with : f:('a -> 'b -> 'b -> 'b) -> ('a'b) Stdlib.Hashtbl.t -> ('a * 'b) Stdlib.Seq.t -> unit

Add the corresponding pairs to the table. If a key occurs multiple times in the input, the values are combined using f in an unspecified order.

  • since 3.3
val of_iter : ('a * 'b) CCHashtbl.iter -> ('a'b) Stdlib.Hashtbl.t

From the given bindings, added in order.

  • since 2.8
val of_iter_with : f:('a -> 'b -> 'b -> 'b) -> ('a * 'b) CCHashtbl.iter -> ('a'b) Stdlib.Hashtbl.t

From the given bindings, added in order. If a key occurs multiple times in the input, the values are combined using f in an unspecified order.

  • since 3.3
val of_seq : ('a * 'b) Stdlib.Seq.t -> ('a'b) Stdlib.Hashtbl.t

From the given bindings, added in order. Renamed from of_std_seq since 3.0.

  • since 3.0
val of_seq_with : f:('a -> 'b -> 'b -> 'b) -> ('a * 'b) Stdlib.Seq.t -> ('a'b) Stdlib.Hashtbl.t

From the given bindings, added in order. If a key occurs multiple times in the input, the values are combined using f in an unspecified order.

  • since 3.3
val add_iter_count : ('a, int) Stdlib.Hashtbl.t -> 'a CCHashtbl.iter -> unit

add_iter_count tbl i increments the count of each element of i by calling incr. This is useful for counting how many times each element of i occurs.

  • since 2.8
val add_seq_count : ('a, int) Stdlib.Hashtbl.t -> 'a Stdlib.Seq.t -> unit

add_seq_count tbl seq increments the count of each element of seq by calling incr. This is useful for counting how many times each element of seq occurs. Renamed from add_std_seq_count since 3.0.

  • since 3.0
val of_iter_count : 'a CCHashtbl.iter -> ('a, int) Stdlib.Hashtbl.t

Like add_seq_count, but allocates a new table and returns it.

  • since 2.8
val of_seq_count : 'a Stdlib.Seq.t -> ('a, int) Stdlib.Hashtbl.t

Like add_seq_count, but allocates a new table and returns it. Renamed from of_std_seq_count since 3.0.

  • since 3.0
val to_list : ('a'b) Stdlib.Hashtbl.t -> ('a * 'b) list

to_list tbl returns the list of (key,value) bindings (order unspecified).

val of_list : ('a * 'b) list -> ('a'b) Stdlib.Hashtbl.t

of_list l builds a table from the given list l of bindings k_i -> v_i, added in order using add. If a key occurs several times, it will be added several times, and the visible binding will be the last one.

val of_list_with : f:('a -> 'b -> 'b -> 'b) -> ('a * 'b) list -> ('a'b) Stdlib.Hashtbl.t

From the given bindings, added in order. If a key occurs multiple times in the input, the values are combined using f in an unspecified order.

  • since 3.3
val update : ('a'b) Stdlib.Hashtbl.t -> f:('a -> 'b option -> 'b option) -> k:'a -> unit

update tbl ~f ~k updates key k by calling f k (Some v) if k was mapped to v, or f k None otherwise; if the call returns None then k is removed/stays removed, if the call returns Some v' then the binding k -> v' is inserted using Hashtbl.replace.

  • since 0.14
val get_or_add : ('a'b) Stdlib.Hashtbl.t -> f:('a -> 'b) -> k:'a -> 'b

get_or_add tbl ~k ~f finds and returns the binding of k in tbl, if it exists. If it does not exist, then f k is called to obtain a new binding v; k -> v is added to tbl and v is returned.

  • since 1.0
val pp : ?pp_start:unit CCHashtbl.printer -> ?pp_stop:unit CCHashtbl.printer -> ?pp_sep:unit CCHashtbl.printer -> ?pp_arrow:unit CCHashtbl.printer -> 'a CCHashtbl.printer -> 'b CCHashtbl.printer -> ('a'b) Stdlib.Hashtbl.t CCHashtbl.printer

pp ~pp_start ~pp_stop ~pp_sep ~pp arrow pp_k pp_v returns a table printer given a pp_k printer for individual key and a pp_v printer for individual value. pp_start and pp_stop control the opening and closing delimiters, by default print nothing. pp_sep control the separator between binding. pp_arrow control the arrow between the key and value. Renamed from print since 2.0.

  • since 0.13
module type S' = CCHashtbl.S
module Make' = CCHashtbl.Make
\ No newline at end of file