From 425d389c3cd481cbf8293345de4587661e3eafe0 Mon Sep 17 00:00:00 2001 From: c-cube Date: Sat, 11 Jun 2022 03:54:18 +0000 Subject: [PATCH] deploy: 75b498a433e8668f72242be8ca03571ba6333839 --- dev/containers/CCArray/index.html | 2 +- dev/containers/CCArrayLabels/index.html | 2 +- dev/containers/CCSeq/index.html | 2 +- dev/containers/CCString/index.html | 2 +- dev/containers/CCStringLabels/index.html | 2 +- dev/containers/Containers_bencode/index.html | 2 +- dev/index.html | 6 +++--- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dev/containers/CCArray/index.html b/dev/containers/CCArray/index.html index 010205c4..a074e100 100644 --- a/dev/containers/CCArray/index.html +++ b/dev/containers/CCArray/index.html @@ -1,5 +1,5 @@ -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

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 : 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 map_inplace : ( 'a -> 'a ) -> 'a t -> unit

map_inplace f a replace all elements of a by its image by f.

  • since NEXT_RELEASE
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 : +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

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 : 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 map_inplace : ( 'a -> 'a ) -> 'a t -> unit

map_inplace f a replace all elements of a by its image by f.

  • since 3.8
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 -> diff --git a/dev/containers/CCArrayLabels/index.html b/dev/containers/CCArrayLabels/index.html index 9b24a8d5..ce3623b6 100644 --- a/dev/containers/CCArrayLabels/index.html +++ b/dev/containers/CCArrayLabels/index.html @@ -9,7 +9,7 @@ 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 map_inplace : f:( 'a -> 'a ) -> 'a t -> unit

map_inplace ~f a replace all elements of a by its image by f.

  • since NEXT_RELEASE
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 : + '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 map_inplace : f:( 'a -> 'a ) -> 'a t -> unit

map_inplace ~f a replace all elements of a by its image by f.

  • since 3.8
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 -> diff --git a/dev/containers/CCSeq/index.html b/dev/containers/CCSeq/index.html index 8c9d5d05..37edb9e8 100644 --- a/dev/containers/CCSeq/index.html +++ b/dev/containers/CCSeq/index.html @@ -1,5 +1,5 @@ -CCSeq (containers.CCSeq)

Module CCSeq

Helpers for the standard Seq type

See oseq for a richer API.

  • since 3.0
type 'a iter = ( 'a -> unit ) -> unit
type 'a gen = unit -> 'a option
type 'a equal = 'a -> 'a -> bool
type 'a ord = 'a -> 'a -> int
type 'a printer = Stdlib.Format.formatter -> 'a -> unit

Basics

type +'a t = unit -> 'a node
and +'a node = 'a Stdlib.Seq.node =
| Nil
| Cons of 'a * 'a t
val nil : 'a t
val empty : 'a t
val cons : 'a -> 'a t -> 'a t
val singleton : 'a -> 'a t
val repeat : ?n:int -> 'a -> 'a t

repeat ~n x repeats x n times then stops. If n is omitted, then x is repeated forever.

val cycle : 'a t -> 'a t

Cycle through the iterator infinitely. The iterator shouldn't be empty.

val unfold : ( 'b -> ('a * 'b) option ) -> 'b -> 'a t

unfold f acc calls f acc and:

  • if f acc = Some (x, acc'), yield x, continue with unfold f acc'.
  • if f acc = None, stops.
val is_empty : 'a t -> bool
val head : 'a t -> 'a option

Head of the list.

val head_exn : 'a t -> 'a

Unsafe version of head.

  • raises Not_found

    if the list is empty.

val tail : 'a t -> 'a t option

Tail of the list.

val tail_exn : 'a t -> 'a t

Unsafe version of tail.

  • raises Not_found

    if the list is empty.

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

Equality step by step. Eager.

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

Lexicographic comparison. Eager.

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

Fold on values.

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

Alias for fold

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

Iterate with index (starts at 0).

val length : _ t -> int

Number of elements in the list. Will not terminate if the list if infinite: use (for instance) take to make the list finite if necessary.

val take : int -> 'a t -> 'a t
val take_while : ( 'a -> bool ) -> 'a t -> 'a t
val drop : int -> 'a t -> 'a t
val drop_while : ( 'a -> bool ) -> 'a t -> 'a t
val map : ( 'a -> 'b ) -> 'a t -> 'b t
val mapi : ( int -> 'a -> 'b ) -> 'a t -> 'b t

Map with index (starts at 0).

val fmap : ( 'a -> 'b option ) -> 'a t -> 'b t
val filter : ( 'a -> bool ) -> 'a t -> 'a t
val append : 'a t -> 'a t -> 'a t
val product_with : ( 'a -> 'b -> 'c ) -> 'a t -> 'b t -> 'c t

Fair product of two (possibly infinite) lists into a new list. Lazy. The first parameter is used to combine each pair of elements.

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

Specialization of product_with producing tuples.

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

group eq l groups together consecutive elements that satisfy eq. Lazy. For instance group (=) [1;1;1;2;2;3;3;1] yields [1;1;1]; [2;2]; [3;3]; [1].

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

uniq eq l returns l but removes consecutive duplicates. Lazy. In other words, if several values that are equal follow one another, only the first of them is kept.

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

for_all p [a1; ...; an] checks if all elements of the sequence satisfy the predicate p. That is, it returns (p a1) && ... && (p an) for a non-empty list and true if the sequence is empty. It consumes the sequence until it finds an element not satisfying the predicate.

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

exists p [a1; ...; an] checks if at least one element of the sequence satisfies the predicate p. That is, it returns (p a1) || ... || (p an) for a non-empty sequence and false if the list is empty. It consumes the sequence until it finds an element satisfying the predicate.

  • since 3.3
val flat_map : ( 'a -> 'b t ) -> 'a t -> 'b t
val filter_map : ( 'a -> 'b option ) -> 'a t -> 'b t
val flatten : 'a t t -> 'a t
val range : int -> int -> int t
val (--) : int -> int -> int t

a -- b is the range of integers containing a and b (therefore, never empty).

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

a -- b is the integer range from a to b, where b is excluded.

Operations on two Collections

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

Fold on two collections at once. Stop at soon as one of them ends.

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

Map on two collections at once. Stop as soon as one of the arguments is exhausted.

val iter2 : ( 'a -> 'b -> unit ) -> 'a t -> 'b t -> unit

Iterate on two collections at once. Stop as soon as one of them ends.

val for_all2 : ( 'a -> 'b -> bool ) -> 'a t -> 'b t -> bool
val exists2 : ( 'a -> 'b -> bool ) -> 'a t -> 'b t -> bool
val merge : 'a ord -> 'a t -> 'a t -> 'a t

Merge two sorted iterators into a sorted iterator.

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

Combine elements pairwise. Stop as soon as one of the lists stops.

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

Split each tuple in the list.

val zip_i : 'a t -> (int * 'a) t

zip_i seq zips the index of each element with the element itself.

  • since NEXT

Misc

val sort : cmp:'a ord -> 'a t -> 'a t

Eager sort. Require the iterator to be finite. O(n ln(n)) time and space.

val sort_uniq : cmp:'a ord -> 'a t -> 'a t

Eager sort that removes duplicate values. Require the iterator to be finite. O(n ln(n)) time and space.

val memoize : 'a t -> 'a t

Avoid recomputations by caching intermediate results.

Fair Combinations

val interleave : 'a t -> 'a t -> 'a t

Fair interleaving of both streams.

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

Fair version of flat_map.

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

Fair version of (<*>).

Implementations

val return : 'a -> 'a t
val pure : 'a -> 'a t
val (>>=) : 'a t -> ( 'a -> 'b t ) -> 'b t
val (>|=) : 'a t -> ( 'a -> 'b ) -> 'b t
val (<*>) : ( 'a -> 'b ) t -> 'a t -> 'b t
val (>>-) : 'a t -> ( 'a -> 'b t ) -> 'b t

Infix version of fair_flat_map.

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

Infix version of fair_app.

Infix operators

module Infix : sig ... end
module type MONAD = sig ... end
module Traverse (M : MONAD) : sig ... end

Conversions

val of_list : 'a list -> 'a t
val to_list : 'a t -> 'a list

Gather all values into a list.

val of_array : 'a array -> 'a t

Iterate on the array.

val to_array : 'a t -> 'a array

Convert into array.

val to_rev_list : 'a t -> 'a list

Convert to a list, in reverse order. More efficient than to_list.

val to_iter : 'a t -> 'a iter
val to_gen : 'a t -> 'a gen
val of_gen : 'a gen -> 'a t

of_gen g consumes the generator and caches intermediate results.

val of_string : string -> char t

Iterate on characters.

  • since 3.7

IO

val pp : +CCSeq (containers.CCSeq)

Module CCSeq

Helpers for the standard Seq type

See oseq for a richer API.

  • since 3.0
type 'a iter = ( 'a -> unit ) -> unit
type 'a gen = unit -> 'a option
type 'a equal = 'a -> 'a -> bool
type 'a ord = 'a -> 'a -> int
type 'a printer = Stdlib.Format.formatter -> 'a -> unit

Basics

type +'a t = unit -> 'a node
and +'a node = 'a Stdlib.Seq.node =
| Nil
| Cons of 'a * 'a t
val nil : 'a t
val empty : 'a t
val cons : 'a -> 'a t -> 'a t
val singleton : 'a -> 'a t
val repeat : ?n:int -> 'a -> 'a t

repeat ~n x repeats x n times then stops. If n is omitted, then x is repeated forever.

val cycle : 'a t -> 'a t

Cycle through the iterator infinitely. The iterator shouldn't be empty.

val unfold : ( 'b -> ('a * 'b) option ) -> 'b -> 'a t

unfold f acc calls f acc and:

  • if f acc = Some (x, acc'), yield x, continue with unfold f acc'.
  • if f acc = None, stops.
val is_empty : 'a t -> bool
val head : 'a t -> 'a option

Head of the list.

val head_exn : 'a t -> 'a

Unsafe version of head.

  • raises Not_found

    if the list is empty.

val tail : 'a t -> 'a t option

Tail of the list.

val tail_exn : 'a t -> 'a t

Unsafe version of tail.

  • raises Not_found

    if the list is empty.

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

Equality step by step. Eager.

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

Lexicographic comparison. Eager.

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

Fold on values.

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

Alias for fold

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

Iterate with index (starts at 0).

val length : _ t -> int

Number of elements in the list. Will not terminate if the list if infinite: use (for instance) take to make the list finite if necessary.

val take : int -> 'a t -> 'a t
val take_while : ( 'a -> bool ) -> 'a t -> 'a t
val drop : int -> 'a t -> 'a t
val drop_while : ( 'a -> bool ) -> 'a t -> 'a t
val map : ( 'a -> 'b ) -> 'a t -> 'b t
val mapi : ( int -> 'a -> 'b ) -> 'a t -> 'b t

Map with index (starts at 0).

val fmap : ( 'a -> 'b option ) -> 'a t -> 'b t
val filter : ( 'a -> bool ) -> 'a t -> 'a t
val append : 'a t -> 'a t -> 'a t
val product_with : ( 'a -> 'b -> 'c ) -> 'a t -> 'b t -> 'c t

Fair product of two (possibly infinite) lists into a new list. Lazy. The first parameter is used to combine each pair of elements.

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

Specialization of product_with producing tuples.

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

group eq l groups together consecutive elements that satisfy eq. Lazy. For instance group (=) [1;1;1;2;2;3;3;1] yields [1;1;1]; [2;2]; [3;3]; [1].

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

uniq eq l returns l but removes consecutive duplicates. Lazy. In other words, if several values that are equal follow one another, only the first of them is kept.

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

for_all p [a1; ...; an] checks if all elements of the sequence satisfy the predicate p. That is, it returns (p a1) && ... && (p an) for a non-empty list and true if the sequence is empty. It consumes the sequence until it finds an element not satisfying the predicate.

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

exists p [a1; ...; an] checks if at least one element of the sequence satisfies the predicate p. That is, it returns (p a1) || ... || (p an) for a non-empty sequence and false if the list is empty. It consumes the sequence until it finds an element satisfying the predicate.

  • since 3.3
val flat_map : ( 'a -> 'b t ) -> 'a t -> 'b t
val filter_map : ( 'a -> 'b option ) -> 'a t -> 'b t
val flatten : 'a t t -> 'a t
val range : int -> int -> int t
val (--) : int -> int -> int t

a -- b is the range of integers containing a and b (therefore, never empty).

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

a -- b is the integer range from a to b, where b is excluded.

Operations on two Collections

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

Fold on two collections at once. Stop at soon as one of them ends.

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

Map on two collections at once. Stop as soon as one of the arguments is exhausted.

val iter2 : ( 'a -> 'b -> unit ) -> 'a t -> 'b t -> unit

Iterate on two collections at once. Stop as soon as one of them ends.

val for_all2 : ( 'a -> 'b -> bool ) -> 'a t -> 'b t -> bool
val exists2 : ( 'a -> 'b -> bool ) -> 'a t -> 'b t -> bool
val merge : 'a ord -> 'a t -> 'a t -> 'a t

Merge two sorted iterators into a sorted iterator.

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

Combine elements pairwise. Stop as soon as one of the lists stops.

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

Split each tuple in the list.

val zip_i : 'a t -> (int * 'a) t

zip_i seq zips the index of each element with the element itself.

  • since 3.8

Misc

val sort : cmp:'a ord -> 'a t -> 'a t

Eager sort. Require the iterator to be finite. O(n ln(n)) time and space.

val sort_uniq : cmp:'a ord -> 'a t -> 'a t

Eager sort that removes duplicate values. Require the iterator to be finite. O(n ln(n)) time and space.

val memoize : 'a t -> 'a t

Avoid recomputations by caching intermediate results.

Fair Combinations

val interleave : 'a t -> 'a t -> 'a t

Fair interleaving of both streams.

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

Fair version of flat_map.

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

Fair version of (<*>).

Implementations

val return : 'a -> 'a t
val pure : 'a -> 'a t
val (>>=) : 'a t -> ( 'a -> 'b t ) -> 'b t
val (>|=) : 'a t -> ( 'a -> 'b ) -> 'b t
val (<*>) : ( 'a -> 'b ) t -> 'a t -> 'b t
val (>>-) : 'a t -> ( 'a -> 'b t ) -> 'b t

Infix version of fair_flat_map.

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

Infix version of fair_app.

Infix operators

module Infix : sig ... end
module type MONAD = sig ... end
module Traverse (M : MONAD) : sig ... end

Conversions

val of_list : 'a list -> 'a t
val to_list : 'a t -> 'a list

Gather all values into a list.

val of_array : 'a array -> 'a t

Iterate on the array.

val to_array : 'a t -> 'a array

Convert into array.

val to_rev_list : 'a t -> 'a list

Convert to a list, in reverse order. More efficient than to_list.

val to_iter : 'a t -> 'a iter
val to_gen : 'a t -> 'a gen
val of_gen : 'a gen -> 'a t

of_gen g consumes the generator and caches intermediate results.

val of_string : string -> char t

Iterate on characters.

  • since 3.7

IO

val pp : ?pp_start:unit printer -> ?pp_stop:unit printer -> ?pp_sep:unit printer -> diff --git a/dev/containers/CCString/index.html b/dev/containers/CCString/index.html index 26a2ef2f..a7dcfe6c 100644 --- a/dev/containers/CCString/index.html +++ b/dev/containers/CCString/index.html @@ -4,4 +4,4 @@ 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
val to_hex : string -> string

Convert a string with arbitrary content into a hexadecimal string.

  • since NEXT_RELEASE
val of_hex : string -> string option

Convert a string in hex into a string with arbitrary content.

  • since NEXT_RELEASE
val of_hex_exn : string -> string

Same as of_hex but fails harder.

  • raises Invalid_argument

    if the input is not valid hex.

  • since NEXT_RELEASE

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 + 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
val to_hex : string -> string

Convert a string with arbitrary content into a hexadecimal string.

  • since 3.8
val of_hex : string -> string option

Convert a string in hex into a string with arbitrary content.

  • since 3.8
val of_hex_exn : string -> string

Same as of_hex but fails harder.

  • raises Invalid_argument

    if the input is not valid hex.

  • since 3.8

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 12b9fcf8..05d10ed8 100644 --- a/dev/containers/CCStringLabels/index.html +++ b/dev/containers/CCStringLabels/index.html @@ -22,4 +22,4 @@ 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
val to_hex : string -> string

Convert a string with arbitrary content into a hexadecimal string.

  • since NEXT_RELEASE
val of_hex : string -> string option

Convert a string in hex into a string with arbitrary content.

  • since NEXT_RELEASE
val of_hex_exn : string -> string

Same as of_hex but fails harder.

  • raises Invalid_argument

    if the input is not valid hex.

  • since NEXT_RELEASE

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 + 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
val to_hex : string -> string

Convert a string with arbitrary content into a hexadecimal string.

  • since 3.8
val of_hex : string -> string option

Convert a string in hex into a string with arbitrary content.

  • since 3.8
val of_hex_exn : string -> string

Same as of_hex but fails harder.

  • raises Invalid_argument

    if the input is not valid hex.

  • since 3.8

Finding

A relatively efficient algorithm for finding sub-strings.

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

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_bencode/index.html b/dev/containers/Containers_bencode/index.html index b2c314e1..24aa8bf7 100644 --- a/dev/containers/Containers_bencode/index.html +++ b/dev/containers/Containers_bencode/index.html @@ -1,2 +1,2 @@ -Containers_bencode (containers.Containers_bencode)

Module Containers_bencode

Basic Bencode decoder/encoder.

See https://en.wikipedia.org/wiki/Bencode .

module Str_map : sig ... end
type t =
| Int of int64
| String of string
| List of t list
| Map of t Str_map.t
val equal : t -> t -> bool
val hash : t -> int
val pp_debug : Stdlib.Format.formatter -> t -> unit

Printer for diagnostic/human consumption

val to_string_debug : t -> string
val int : int -> t
val int64 : int64 -> t
val string : string -> t
val list : t list -> t
val map_of_list : (string * t) list -> t
val map : t Str_map.t -> t
module Encode : sig ... end

Encoding

module Decode : sig ... end

Decoding

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

Module Containers_bencode

Basic Bencode decoder/encoder.

See https://en.wikipedia.org/wiki/Bencode .

module Str_map : sig ... end
type t =
| Int of int64
| String of string
| List of t list
| Map of t Str_map.t
val equal : t -> t -> bool
val hash : t -> int
val pp_debug : Stdlib.Format.formatter -> t -> unit

Printer for diagnostic/human consumption

val to_string_debug : t -> string
val int : int -> t
val int64 : int64 -> t
val string : string -> t
val list : t list -> t
val map_of_list : (string * t) list -> t
val map : t Str_map.t -> t
module Encode : sig ... end

Encoding

module Decode : sig ... end

Decoding

\ No newline at end of file diff --git a/dev/index.html b/dev/index.html index bbf063f8..ae8783fe 100644 --- a/dev/index.html +++ b/dev/index.html @@ -11,9 +11,9 @@

OCaml package documentation

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