From 8c31ed6a6c975bdcb5c15525babcc46145472141 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Fri, 31 May 2019 09:29:03 -0500 Subject: [PATCH] update dev docs --- dev/containers/CCArray/index.html | 53 +- .../CCArray/module-type-MONO_ARRAY/index.html | 2 +- dev/containers/CCArrayLabels/index.html | 52 +- .../module-type-MONO_ARRAY/index.html | 2 +- dev/containers/CCArray_slice/index.html | 42 +- dev/containers/CCBool/index.html | 2 +- dev/containers/CCChar/index.html | 9 +- dev/containers/CCEqual/Infix/index.html | 2 +- dev/containers/CCEqual/index.html | 7 +- dev/containers/CCFloat/Infix/index.html | 2 +- dev/containers/CCFloat/index.html | 8 +- dev/containers/CCFormat/Dump/index.html | 2 +- dev/containers/CCFormat/index.html | 50 +- .../CCFun/Monad/argument-1-X/index.html | 2 +- dev/containers/CCFun/Monad/index.html | 2 +- dev/containers/CCFun/index.html | 18 +- dev/containers/CCHash/index.html | 8 +- dev/containers/CCHashtbl/Poly/index.html | 21 +- dev/containers/CCHashtbl/index.html | 21 +- .../CCHashtbl/module-type-S/index.html | 21 +- .../CCHeap/Make/argument-1-E/index.html | 2 +- dev/containers/CCHeap/Make/index.html | 13 +- dev/containers/CCHeap/index.html | 2 +- .../CCHeap/module-type-PARTIAL_ORD/index.html | 2 +- .../CCHeap/module-type-S/index.html | 13 +- dev/containers/CCIO/File/index.html | 14 +- dev/containers/CCIO/index.html | 34 +- dev/containers/CCInt/Infix/index.html | 2 +- dev/containers/CCInt/index.html | 10 +- dev/containers/CCInt32/Infix/index.html | 2 +- dev/containers/CCInt32/index.html | 39 +- dev/containers/CCInt64/Infix/index.html | 2 +- dev/containers/CCInt64/index.html | 46 +- dev/containers/CCList/Assoc/index.html | 4 +- dev/containers/CCList/Infix/index.html | 2 +- dev/containers/CCList/Ref/index.html | 3 +- .../CCList/Traverse/argument-1-M/index.html | 2 +- dev/containers/CCList/Traverse/index.html | 4 +- dev/containers/CCList/index.html | 100 +-- .../CCList/module-type-MONAD/index.html | 2 +- dev/containers/CCListLabels/Assoc/index.html | 4 +- dev/containers/CCListLabels/Infix/index.html | 2 +- dev/containers/CCListLabels/Ref/index.html | 3 +- .../Traverse/argument-1-M/index.html | 2 +- .../CCListLabels/Traverse/index.html | 4 +- dev/containers/CCListLabels/index.html | 64 +- .../CCListLabels/module-type-MONAD/index.html | 2 +- dev/containers/CCMap/index.html | 2 +- dev/containers/CCMap/module-type-S/index.html | 10 +- dev/containers/CCNativeint/Infix/index.html | 2 +- dev/containers/CCNativeint/index.html | 40 +- dev/containers/CCOpt/Infix/index.html | 2 +- dev/containers/CCOpt/index.html | 10 +- dev/containers/CCOrd/Infix/index.html | 4 +- dev/containers/CCOrd/index.html | 15 +- dev/containers/CCPair/index.html | 4 +- dev/containers/CCParse/Infix/index.html | 13 +- dev/containers/CCParse/U/index.html | 6 +- dev/containers/CCParse/index.html | 62 +- dev/containers/CCRandom/index.html | 26 +- dev/containers/CCRef/index.html | 2 +- dev/containers/CCResult/Infix/index.html | 5 +- .../CCResult/Traverse/argument-1-M/index.html | 2 +- dev/containers/CCResult/Traverse/index.html | 2 +- dev/containers/CCResult/index.html | 27 +- .../CCResult/module-type-MONAD/index.html | 2 +- dev/containers/CCSet/index.html | 2 +- dev/containers/CCSet/module-type-S/index.html | 3 +- dev/containers/CCString/Find/index.html | 2 +- dev/containers/CCString/Split/index.html | 9 +- dev/containers/CCString/Sub/index.html | 3 +- dev/containers/CCString/index.html | 21 +- .../CCString/module-type-S/index.html | 3 +- dev/containers/CCUtf8_string/index.html | 3 +- dev/containers/CCVector/index.html | 23 +- .../Containers/Hashtbl/Make/index.html | 2 +- .../MakeSeeded/argument-1-H/index.html | 2 +- .../Containers/Hashtbl/MakeSeeded/index.html | 2 +- dev/containers/Containers/Hashtbl/index.html | 21 +- .../Hashtbl/module-type-HashedType/index.html | 2 +- .../Hashtbl/module-type-S'/index.html | 21 +- .../Hashtbl/module-type-S/index.html | 2 +- .../module-type-SeededHashedType/index.html | 2 +- .../Hashtbl/module-type-SeededS/index.html | 2 +- dev/containers/Containers/index.html | 2 +- dev/containers/index.html | 3 +- dev/index.html | 24 +- dev/odoc.css | 810 +++++++++++++++--- index.md | 2 + 89 files changed, 821 insertions(+), 1086 deletions(-) diff --git a/dev/containers/CCArray/index.html b/dev/containers/CCArray/index.html index fa4be80e..a503b174 100644 --- a/dev/containers/CCArray/index.html +++ b/dev/containers/CCArray/index.html @@ -1,53 +1,2 @@ -CCArray (containers.CCArray)

Module CCArray

Array utils

type 'a sequence = ('a ‑> unit) ‑> unit
type 'a klist = unit ‑> [ `Nil | `Cons of 'a * 'a klist ]
type 'a gen = unit ‑> 'a option
type 'a equal = 'a ‑> 'a ‑> bool
type 'a ord = 'a ‑> 'a ‑> int
type 'a random_gen = Random.State.t ‑> 'a
type 'a printer = Format.formatter ‑> 'a ‑> unit

Arrays

type 'a t = 'a array
val empty : 'a t

The empty array, physically equal to ||.

val equal : 'a equal ‑> 'a t equal

Hoist an equality test for elements to arrays. -Arrays are only equal if their lengths are the same and -corresponding elements test equal.

val compare : 'a ord ‑> 'a t ord
val swap : 'a t ‑> int ‑> int ‑> unit

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

  • Since: 1.4
val get : 'a t ‑> int ‑> 'a

get a n returns the element number n of array a. -The first element has number 0. -The last element has number length a - 1. -You can also write a.(n) instead of get a n.

Raise Invalid_argument "index out of bounds" -if n is outside the range 0 to (length a - 1).

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 set : 'a t ‑> int ‑> 'a ‑> unit

set a n x modifies array a in place, replacing -element number n with x. -You can also write a.(n) <- x instead of set a n x.

Raise Invalid_argument "index out of bounds" -if n is outside the range 0 to length a - 1.

val length : _ t ‑> int

Return the length (number of elements) of the given array.

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

fold f x a computes f (... (f (f x a.(0)) a.(1)) ...) a.(n-1), -where n is the length of the array a.

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

Fold left on array, with index.

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

Fold left on array 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 acc a is a fold_left-like function, but it also maps the -array to another array.

  • Since: 1.2
val scan_left : ('acc ‑> 'a ‑> 'acc) ‑> 'acc ‑> 'a t ‑> 'acc t

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

  • Since: 1.2
val iter : ('a ‑> unit) ‑> 'a t ‑> unit

iter f a applies function f in turn to all -the elements of a. It is equivalent to -f a.(0); f a.(1); ...; f a.(length a - 1); ().

val iteri : (int ‑> 'a ‑> unit) ‑> 'a t ‑> unit

Like Array.iter, but the function is applied to the index of the -element as first argument, and the element itself as second argument.

val blit : 'a t ‑> int ‑> 'a t ‑> int ‑> int ‑> unit

blit v1 o1 v2 o2 len copies len elements -from array v1, starting at element number o1, to array v2, -starting at element number o2. It works correctly even if -v1 and v2 are the same array, and the source and -destination chunks overlap.

Raise Invalid_argument "Array.blit" if o1 and len do not -designate a valid subarray of v1, or if o2 and len do not -designate a valid subarray of v2.

val reverse_in_place : 'a t ‑> unit

Reverse the array in place.

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

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

  • Since: 1.0
val sort_indices : ('a ‑> 'a ‑> int) ‑> 'a t ‑> int array

sort_indices cmp 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 cmp a -appears in a. a is not modified.

In other words, map (fun i -> a.(i)) (sort_indices cmp a) = sorted cmp 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 cmp a returns a new array b, with the same length as a, -such that b.(i) is the index at which the i-the element of a appears -in sorted cmp a. a is not modified.

In other words, map (fun i -> (sorted cmp a).(i)) (sort_ranking cmp 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 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, else it returns None.

  • Since: 1.3
val find : ('a ‑> 'b option) ‑> 'a t ‑> 'b option

Alias to find_map.

  • Deprecated since 1.3
val find_map_i : (int ‑> 'a ‑> 'b option) ‑> 'a t ‑> 'b option

Like find_map, but also pass the index to the predicate function.

  • Since: 1.3
val findi : (int ‑> 'a ‑> 'b option) ‑> 'a t ‑> 'b option

Alias to find_map_i.

  • Since: 0.3.4
  • Deprecated since 1.3
val find_idx : ('a ‑> bool) ‑> 'a t ‑> (int * 'a) option

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

  • Since: 0.3.4
val lookup : cmp:'a ord ‑> 'a ‑> 'a t ‑> int option

Lookup the index of some value in a sorted array. -Undefined behavior if the array is not sorted wrt cmp. -Complexity: O(log (n)) (dichotomic search).

  • Returns None if the key is not present, or -Some i (i the index of the key) otherwise.
val lookup_exn : cmp:'a ord ‑> 'a ‑> 'a t ‑> int

Like lookup, but

  • Raises Not_found: if the 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 x arr finds the index of the object x in the array arr, -provided arr is sorted using cmp. If the array is not sorted, -the result is not specified (may

  • Raises Invalid_argument: ).

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

  • Returns

    • `At i if cmp arr.(i) x = 0 (for some i).
    • `All_lower if all elements of arr are lower than x.
    • `All_bigger if all elements of arr are bigger than x.
    • `Just_after i if arr.(i) < x < arr.(i+1).
    • `Empty if the array is empty.
  • Raises Invalid_argument: if the array is found to be unsorted w.r.t cmp.
  • Since: 0.13
val for_all : ('a ‑> bool) ‑> 'a t ‑> bool

for_all p [|a1; ...; an|] checks if all elements of the array -satisfy the predicate p. That is, it returns -(p a1) && (p a2) && ... && (p an).

val for_all2 : ('a ‑> 'b ‑> bool) ‑> 'a t ‑> 'b t ‑> bool

Forall on pairs of arrays.

  • Raises Invalid_argument: if they have distinct lengths. -Allow different types.
  • Since: 0.20
val exists : ('a ‑> bool) ‑> 'a t ‑> bool

exists p [|a1; ...; an|] checks if at least one element of -the array satisfies the predicate p. That is, it returns -(p a1) || (p a2) || ... || (p an).

val exists2 : ('a ‑> 'b ‑> bool) ‑> 'a t ‑> 'b t ‑> bool

Exists on pairs of arrays.

  • Raises Invalid_argument: if they have distinct lengths. -Allow different types.
  • Since: 0.20
val fold2 : ('acc ‑> 'a ‑> 'b ‑> 'acc) ‑> 'acc ‑> 'a t ‑> 'b t ‑> 'acc

Fold on two arrays stepwise.

  • Raises Invalid_argument: if they have distinct lengths.
  • Since: 0.20
val iter2 : ('a ‑> 'b ‑> unit) ‑> 'a t ‑> 'b t ‑> unit

Iterate on two arrays stepwise.

  • Raises Invalid_argument: if they have distinct lengths.
  • Since: 0.20
val shuffle : 'a t ‑> unit

Shuffle randomly the array, in place.

val shuffle_with : Random.State.t ‑> 'a t ‑> unit

Like shuffle but using a specialized random state.

val random_choose : 'a t ‑> 'a random_gen

Choose an element randomly.

  • Raises Not_found: if the array/slice is empty.
val to_seq : 'a t ‑> 'a sequence

Return a sequence of the elements of an array. -The input array is shared with the sequence and modifications of it will result -in modification of the sequence.

val to_gen : 'a t ‑> 'a gen

Return a gen of the elements of an array.

val to_klist : 'a t ‑> 'a klist

Return a klist of the elements of an array.

IO

val pp : ?⁠sep:string ‑> 'a printer ‑> 'a t printer

Print an array of items with printing function.

val pp_i : ?⁠sep:string ‑> (int ‑> 'a printer) ‑> 'a t printer

Print an array, giving the printing function both index and item.

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

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

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

map2 f a b applies function f to all the 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 they have distinct lengths.
  • Since: 0.20
val rev : 'a t ‑> 'a t

Copy + reverse in place.

  • Since: 0.20
val filter : ('a ‑> bool) ‑> 'a t ‑> 'a t

Filter elements out of the array. Only the elements satisfying -the given predicate will be kept.

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

Map each element into another value, or discard it.

val flat_map : ('a ‑> 'b t) ‑> 'a t ‑> 'b array

Transform each element into an array, then flatten.

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

Infix version of flat_map.

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

Infix version of map.

  • Since: 0.8
val (>|=) : 'a t ‑> ('a ‑> 'b) ‑> 'b t

Infix version of map.

  • Since: 0.8
val except_idx : 'a t ‑> int ‑> 'a list

Remove given index, obtaining the list of the other elements.

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

Range array. Bounds included.

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

Range array, excluding right bound.

  • Since: 0.17
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 the array, without allocating (eats stack space though). Performance -might be lower than Array.sort.

  • Since: 0.14
\ No newline at end of file +CCArray (containers.CCArray)

Module CCArray

Array utils

type 'a sequence = ('a -> unit) -> unit
type 'a klist = unit -> [ `Nil | `Cons of 'a * 'a klist ]
type 'a gen = unit -> 'a option
type 'a equal = 'a -> 'a -> bool
type 'a ord = 'a -> 'a -> int
type 'a random_gen = Random.State.t -> 'a
type 'a printer = Format.formatter -> 'a -> unit

Arrays

include module type of 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 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 unsafe_get : 'a array -> int -> 'a
val unsafe_set : 'a array -> int -> 'a -> unit
module Floatarray : sig ... end
type 'a t = 'a array

The type for arrays

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 : 'a t -> int -> 'a

get a n returns the element number n of array a. The first element has number 0. The last element has number length a - 1. You can also write a.(n) instead of get a n.

Raise Invalid_argument "index out of bounds" if n is outside the range 0 to (length a - 1).

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 set : 'a t -> int -> 'a -> unit

set a n x modifies array a in place, replacing element number n with x. You can also write a.(n) <- x instead of set a n x.

Raise Invalid_argument "index out of bounds" if n is outside the range 0 to length a - 1.

val length : _ t -> int

length a returns the length (number of elements) of the given array a.

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.

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

iter f a applies function f in turn to all elements of a. It is equivalent to f a.(0); f a.(1); ...; f a.(length a - 1); ().

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

iteri f a is like iter, but the function f is applied with the index of the element as first argument, and the element itself as second argument.

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

blit a1 o1 a2 o2 len copies len elements from array a1, starting at element number o1, to array a2, starting at element number o2. It works correctly even if a1 and a2 are the same array, and the source and destination chunks overlap.

Raise Invalid_argument "CCArray.blit" if o1 and len do not designate a valid subarray of a1, or if o2 and len do not designate a valid subarray of a2.

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 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 : ('a -> 'b option) -> 'a t -> 'b option

find f a is an alias to find_map.

deprecated

since 1.3, use find_map instead. The version with labels is

deprecated

since 2.1, use find_map instead.

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 findi : (int -> 'a -> 'b option) -> 'a t -> 'b option

findi f a is an alias to find_map_i.

since
0.3.4
deprecated

since 1.3, use find_map instead. The version with labels is

deprecated

since 2.1, use find_map instead.

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_all : ('a -> bool) -> 'a t -> bool

for_all f [|a1; ...; an|] is true if all elements of the array satisfy the predicate f. That is, it returns (f a1) && (f a2) && ... && (f an).

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 exists : ('a -> bool) -> 'a t -> bool

exists f [|a1; ...; an|] is true if at least one element of the array satisfies the predicate f. That is, it returns (f a1) || (f a2) || ... || (f an).

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 iter2 : ('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 : 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_seq : 'a t -> 'a sequence

to_seq a returns a sequence 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.

val to_gen : 'a t -> 'a gen

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

val to_klist : 'a t -> 'a klist

to_klist returns a klist of the elements of an array a.

IO

val pp : ?⁠sep:string -> 'a printer -> 'a t printer

pp ~sep pp_item ppf a formats the array a on ppf. Each element is formatted with pp_item and elements are separated by sep (defaults to ", ").

val pp_i : ?⁠sep:string -> (int -> 'a printer) -> 'a t printer

pp_i ~sep pp_item ppf a prints the array a on ppf. The printing function pp_item is giving both index and element. Elements are separated by sep (defaults to ", ").

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

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

val map2 : ('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 : ('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 flat_map : ('a -> 'b t) -> 'a t -> 'b array

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

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 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 (--) : 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
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
\ No newline at end of file diff --git a/dev/containers/CCArray/module-type-MONO_ARRAY/index.html b/dev/containers/CCArray/module-type-MONO_ARRAY/index.html index 81b820cf..db179785 100644 --- a/dev/containers/CCArray/module-type-MONO_ARRAY/index.html +++ b/dev/containers/CCArray/module-type-MONO_ARRAY/index.html @@ -1,2 +1,2 @@ -MONO_ARRAY (containers.CCArray.MONO_ARRAY)

Module type CCArray.MONO_ARRAY

type elt
type t
val length : t ‑> int
val get : t ‑> int ‑> elt
val set : t ‑> int ‑> elt ‑> unit
\ No newline at end of file +MONO_ARRAY (containers.CCArray.MONO_ARRAY)

Module type CCArray.MONO_ARRAY

type elt
type t
val length : t -> int
val get : t -> int -> elt
val set : t -> int -> elt -> unit
\ No newline at end of file diff --git a/dev/containers/CCArrayLabels/index.html b/dev/containers/CCArrayLabels/index.html index 96a30518..7a9edfe8 100644 --- a/dev/containers/CCArrayLabels/index.html +++ b/dev/containers/CCArrayLabels/index.html @@ -1,52 +1,2 @@ -CCArrayLabels (containers.CCArrayLabels)

Module CCArrayLabels

Array utils

type 'a sequence = ('a ‑> unit) ‑> unit
type 'a klist = unit ‑> [ `Nil | `Cons of 'a * 'a klist ]
type 'a gen = unit ‑> 'a option
type 'a equal = 'a ‑> 'a ‑> bool
type 'a ord = 'a ‑> 'a ‑> int
type 'a random_gen = Random.State.t ‑> 'a
type 'a printer = Format.formatter ‑> 'a ‑> unit

Arrays

type 'a t = 'a array
val empty : 'a t

The empty array, physically equal to ||.

val equal : 'a equal ‑> 'a t equal

Hoist an equality test for elements to arrays. -Arrays are only equal if their lengths are the same and -corresponding elements test equal.

val compare : 'a ord ‑> 'a t ord
val swap : 'a t ‑> int ‑> int ‑> unit

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

  • Since: 1.4
val get : 'a t ‑> int ‑> 'a

get a n returns the element number n of array a. -The first element has number 0. -The last element has number length a - 1. -You can also write a.(n) instead of get a n.

Raise Invalid_argument "index out of bounds" -if n is outside the range 0 to (length a - 1).

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 set : 'a t ‑> int ‑> 'a ‑> unit

set a n x modifies array a in place, replacing -element number n with x. -You can also write a.(n) <- x instead of set a n x.

Raise Invalid_argument "index out of bounds" -if n is outside the range 0 to length a - 1.

val length : _ t ‑> int

Return the length (number of elements) of the given array.

val fold : f:('a ‑> 'b ‑> 'a) ‑> init:'a ‑> 'b t ‑> 'a

fold f x a computes f (... (f (f x a.(0)) a.(1)) ...) a.(n-1), -where n is the length of the array a.

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

Fold left on array, with index.

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

Fold left on array 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 acc a is a fold_left-like function, but it also maps the -array to another array.

  • Since: 2.1
val scan_left : f:('acc ‑> 'a ‑> 'acc) ‑> init:'acc ‑> 'a t ‑> 'acc t

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

  • Since: 2.1
val iter : f:('a ‑> unit) ‑> 'a t ‑> unit

iter f a applies function f in turn to all -the elements of a. It is equivalent to -f a.(0); f a.(1); ...; f a.(length a - 1); ().

val iteri : f:(int ‑> 'a ‑> unit) ‑> 'a t ‑> unit

Like Array.iter, but the function is applied to the index of the -element as first argument, and the element itself as second argument.

val blit : 'a t ‑> int ‑> 'a t ‑> int ‑> int ‑> unit

blit v1 o1 v2 o2 len copies len elements -from array v1, starting at element number o1, to array v2, -starting at element number o2. It works correctly even if -v1 and v2 are the same array, and the source and -destination chunks overlap.

Raise Invalid_argument "Array.blit" if o1 and len do not -designate a valid subarray of v1, or if o2 and len do not -designate a valid subarray of v2.

val reverse_in_place : 'a t ‑> unit

Reverse the array in place.

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

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

  • Since: 1.0
val sort_indices : f:('a ‑> 'a ‑> int) ‑> 'a t ‑> int array

sort_indices cmp 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 cmp a -appears in a. a is not modified.

In other words, map (fun i -> a.(i)) (sort_indices cmp a) = sorted cmp 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 cmp a returns a new array b, with the same length as a, -such that b.(i) is the index at which the i-the element of a appears -in sorted cmp a. a is not modified.

In other words, map (fun i -> (sorted cmp a).(i)) (sort_ranking cmp 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 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, else it returns None.

  • Since: 2.1
val find : f:('a ‑> 'b option) ‑> 'a t ‑> 'b option

find f a returns Some y if there is an element x such -that f x = Some y, else it returns None.

  • Deprecated since 2.1
val find_map_i : f:(int ‑> 'a ‑> 'b option) ‑> 'a t ‑> 'b option

Like find_map, but also pass the index to the predicate function.

  • Since: 2.1
val findi : f:(int ‑> 'a ‑> 'b option) ‑> 'a t ‑> 'b option

Like find, but also pass the index to the predicate function.

  • Since: 0.3.4
  • Deprecated since 2.1
val find_idx : f:('a ‑> bool) ‑> 'a t ‑> (int * 'a) option

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

  • Since: 0.3.4
val lookup : cmp:'a ord ‑> key:'a ‑> 'a t ‑> int option

Lookup the index of some value in a sorted array. -Undefined behavior if the array is not sorted wrt cmp. -Complexity: O(log (n)) (dichotomic search).

  • Returns None if the 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

Like lookup, but

  • Raises Not_found: if the 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 arr finds the index of the object key in the array arr, -provided arr 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 -(dichotomic search).

  • Returns

    • `At i if cmp arr.(i) key = 0 (for some i).
    • `All_lower if all elements of arr are lower than key.
    • `All_bigger if all elements of arr are bigger than key.
    • `Just_after i if arr.(i) < key < arr.(i+1).
    • `Empty if the array is empty.
  • Raises Invalid_argument: if the array is found to be unsorted w.r.t cmp.
  • Since: 0.13
val for_all : f:('a ‑> bool) ‑> 'a t ‑> bool

for_all p [|a1; ...; an|] checks if all elements of the array -satisfy the predicate p. That is, it returns -(p a1) && (p a2) && ... && (p an).

val for_all2 : f:('a ‑> 'b ‑> bool) ‑> 'a t ‑> 'b t ‑> bool

Forall on pairs of arrays.

  • Raises Invalid_argument: if they have distinct lengths. -Allow different types.
  • Since: 0.20
val exists : f:('a ‑> bool) ‑> 'a t ‑> bool

exists p [|a1; ...; an|] checks if at least one element of -the array satisfies the predicate p. That is, it returns -(p a1) || (p a2) || ... || (p an).

val exists2 : f:('a ‑> 'b ‑> bool) ‑> 'a t ‑> 'b t ‑> bool

Exists on pairs of arrays.

  • Raises Invalid_argument: if they have distinct lengths. -Allow different types.
  • Since: 0.20
val fold2 : f:('acc ‑> 'a ‑> 'b ‑> 'acc) ‑> init:'acc ‑> 'a t ‑> 'b t ‑> 'acc

Fold on two arrays stepwise.

  • Raises Invalid_argument: if they have distinct lengths.
  • Since: 0.20
val iter2 : f:('a ‑> 'b ‑> unit) ‑> 'a t ‑> 'b t ‑> unit

Iterate on two arrays stepwise.

  • Raises Invalid_argument: if they have distinct lengths.
  • Since: 0.20
val shuffle : 'a t ‑> unit

Shuffle randomly the array, in place.

val shuffle_with : Random.State.t ‑> 'a t ‑> unit

Like shuffle but using a specialized random state.

val random_choose : 'a t ‑> 'a random_gen

Choose an element randomly.

  • Raises Not_found: if the array/slice is empty.
val to_seq : 'a t ‑> 'a sequence

Return a sequence of the elements of an array.

val to_gen : 'a t ‑> 'a gen

Return a gen of the elements of an array.

val to_klist : 'a t ‑> 'a klist

Return a klist of the elements of an array.

IO

val pp : ?⁠sep:string ‑> 'a printer ‑> 'a t printer

Print an array of items with printing function.

val pp_i : ?⁠sep:string ‑> (int ‑> 'a printer) ‑> 'a t printer

Print an array, giving the printing function both index and item.

val map : f:('a ‑> 'b) ‑> 'a t ‑> 'b t

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

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

map2 f a b applies function f to all the 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 they have distinct lengths.
  • Since: 0.20
val rev : 'a t ‑> 'a t

Copy + reverse in place.

  • Since: 0.20
val filter : f:('a ‑> bool) ‑> 'a t ‑> 'a t

Filter elements out of the array. Only the elements satisfying -the given predicate will be kept.

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

Map each element into another value, or discard it.

val flat_map : f:('a ‑> 'b t) ‑> 'a t ‑> 'b array

Transform each element into an array, then flatten.

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

Infix version of flat_map.

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

Infix version of map.

  • Since: 0.8
val (>|=) : 'a t ‑> ('a ‑> 'b) ‑> 'b t

Infix version of map.

  • Since: 0.8
val except_idx : 'a t ‑> int ‑> 'a list

Remove given index, obtaining the list of the other elements.

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

Range array. Bounds included.

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

Range array, excluding right bound.

  • Since: 0.17
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 the array, without allocating (eats stack space though). Performance -might be lower than Array.sort.

  • Since: 0.14
\ No newline at end of file +CCArrayLabels (containers.CCArrayLabels)

Module CCArrayLabels

Array utils

type 'a sequence = ('a -> unit) -> unit
type 'a klist = unit -> [ `Nil | `Cons of 'a * 'a klist ]
type 'a gen = unit -> 'a option
type 'a equal = 'a -> 'a -> bool
type 'a ord = 'a -> 'a -> int
type 'a random_gen = Random.State.t -> 'a
type 'a printer = Format.formatter -> 'a -> unit

Arrays

include module type of ArrayLabels
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 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 map : f:('a -> 'b) -> 'a array -> 'b array
val iteri : f:(int -> 'a -> unit) -> 'a array -> unit
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 exists : f:('a -> bool) -> 'a array -> bool
val for_all : f:('a -> bool) -> 'a array -> bool
val mem : 'a -> set:'a array -> bool
val memq : 'a -> set:'a array -> bool
val create_float : int -> float array
val make_float : int -> float 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 unsafe_get : 'a array -> int -> 'a
val unsafe_set : 'a array -> int -> 'a -> unit
module Floatarray : sig ... end
type 'a t = 'a array

The type for arrays

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 : 'a t -> int -> 'a

get a n returns the element number n of array a. The first element has number 0. The last element has number length a - 1. You can also write a.(n) instead of get a n.

Raise Invalid_argument "index out of bounds" if n is outside the range 0 to (length a - 1).

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 set : 'a t -> int -> 'a -> unit

set a n x modifies array a in place, replacing element number n with x. You can also write a.(n) <- x instead of set a n x.

Raise Invalid_argument "index out of bounds" if n is outside the range 0 to length a - 1.

val length : _ t -> int

length a returns the length (number of elements) of the given array a.

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.

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

iter ~f a applies function ~f in turn to all elements of a. It is equivalent to ~f a.(0); ~f a.(1); ...; ~f a.(length a - 1); ().

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

iteri ~f a is like iter, but the function ~f is applied with the index of the element as first argument, and the element itself as second argument.

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

blit a1 o1 a2 o2 len copies len elements from array a1, starting at element number o1, to array a2, starting at element number o2. It works correctly even if a1 and a2 are the same array, and the source and destination chunks overlap.

Raise Invalid_argument "CCArray.blit" if o1 and len do not designate a valid subarray of a1, or if o2 and len do not designate a valid subarray of a2.

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 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 : f:('a -> 'b option) -> 'a t -> 'b option

find ~f a is an alias to find_map.

deprecated

since 1.3, use find_map instead. The version with labels is

deprecated

since 2.1, use find_map instead.

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 findi : f:(int -> 'a -> 'b option) -> 'a t -> 'b option

findi ~f a is an alias to find_map_i.

since
0.3.4
deprecated

since 1.3, use find_map instead. The version with labels is

deprecated

since 2.1, use find_map instead.

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_all : f:('a -> bool) -> 'a t -> bool

for_all ~f [|a1; ...; an|] is true if all elements of the array satisfy the predicate ~f. That is, it returns (~f a1) && (~f a2) && ... && (~f an).

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 exists : f:('a -> bool) -> 'a t -> bool

exists ~f [|a1; ...; an|] is true if at least one element of the array satisfies the predicate ~f. That is, it returns (~f a1) || (~f a2) || ... || (~f an).

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 : 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_seq : 'a t -> 'a sequence

to_seq a returns a sequence 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.

val to_gen : 'a t -> 'a gen

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

val to_klist : 'a t -> 'a klist

to_klist returns a klist of the elements of an array a.

IO

val pp : ?⁠sep:string -> 'a printer -> 'a t printer

pp ~sep pp_item ppf a formats the array a on ppf. Each element is formatted with pp_item and elements are separated by sep (defaults to ", ").

val pp_i : ?⁠sep:string -> (int -> 'a printer) -> 'a t printer

pp_i ~sep pp_item ppf a prints the array a on ppf. The printing function pp_item is giving both index and element. Elements are separated by sep (defaults to ", ").

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

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

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 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 (>>=) : '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 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 (--) : 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
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
\ No newline at end of file diff --git a/dev/containers/CCArrayLabels/module-type-MONO_ARRAY/index.html b/dev/containers/CCArrayLabels/module-type-MONO_ARRAY/index.html index 132c122c..c781e7c7 100644 --- a/dev/containers/CCArrayLabels/module-type-MONO_ARRAY/index.html +++ b/dev/containers/CCArrayLabels/module-type-MONO_ARRAY/index.html @@ -1,2 +1,2 @@ -MONO_ARRAY (containers.CCArrayLabels.MONO_ARRAY)

Module type CCArrayLabels.MONO_ARRAY

type elt
type t
val length : t ‑> int
val get : t ‑> int ‑> elt
val set : t ‑> int ‑> elt ‑> unit
\ No newline at end of file +MONO_ARRAY (containers.CCArrayLabels.MONO_ARRAY)

Module type CCArrayLabels.MONO_ARRAY

type elt
type t
val length : t -> int
val get : t -> int -> elt
val set : t -> int -> elt -> unit
\ No newline at end of file diff --git a/dev/containers/CCArray_slice/index.html b/dev/containers/CCArray_slice/index.html index 755a91cb..4535b553 100644 --- a/dev/containers/CCArray_slice/index.html +++ b/dev/containers/CCArray_slice/index.html @@ -1,42 +1,2 @@ -CCArray_slice (containers.CCArray_slice)

Module CCArray_slice

Array Slice

type 'a sequence = ('a ‑> unit) ‑> unit
type 'a klist = unit ‑> [ `Nil | `Cons of 'a * 'a klist ]
type 'a gen = unit ‑> 'a option
type 'a equal = 'a ‑> 'a ‑> bool
type 'a ord = 'a ‑> 'a ‑> int
type 'a random_gen = Random.State.t ‑> 'a
type 'a printer = Format.formatter ‑> 'a ‑> unit
type 'a t

Array slice, containing elements of type 'a.

val empty : 'a t

The empty array slice.

val equal : 'a equal ‑> 'a t equal
val compare : 'a ord ‑> 'a t ord
val get : 'a t ‑> int ‑> 'a

get a n returns the element number n of array a. -The first element has number 0. -The last element has number length a - 1. -You can also write a.(n) instead of get a n.

Raise Invalid_argument "index out of bounds" -if n is outside the range 0 to (length a - 1).

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 make : 'a array ‑> int ‑> len:int ‑> 'a t

Create a slice from given offset and length.

  • Raises Invalid_argument: if the slice isn't valid.
val of_slice : ('a array * int * int) ‑> 'a t

Make a sub-array from a triple (arr, i, len) where arr is the array, -i the offset in arr, and len the number of elements of the slice.

  • Raises Invalid_argument: if the slice isn't valid (See make).
val to_slice : 'a t ‑> 'a array * int * int

Convert into a triple (arr, i, len) where len is the length of -the sub-array of arr starting at offset i.

val to_list : 'a t ‑> 'a list

Convert directly to a list.

  • Since: 1.0
val full : 'a array ‑> 'a t

Slice that covers the full array.

val underlying : 'a t ‑> 'a array

Underlying array (shared). Modifying this array will modify the slice.

val copy : 'a t ‑> 'a array

Copy into a new array.

val sub : 'a t ‑> int ‑> int ‑> 'a t

Sub-slice.

val set : 'a t ‑> int ‑> 'a ‑> unit

set a n x modifies array a in place, replacing -element number n with x. -You can also write a.(n) <- x instead of set a n x.

Raise Invalid_argument "index out of bounds" -if n is outside the range 0 to length a - 1.

val length : _ t ‑> int

Return the length (number of elements) of the given array.

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

fold f x a computes f (... (f (f x a.(0)) a.(1)) ...) a.(n-1), -where n is the length of the array a.

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

Fold left on array, with index.

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

Fold left on array until a stop condition via ('a, `Stop) is -indicated by the accumulator.

  • Since: 0.8
val iter : ('a ‑> unit) ‑> 'a t ‑> unit

iter f a applies function f in turn to all -the elements of a. It is equivalent to -f a.(0); f a.(1); ...; f a.(length a - 1); ().

val iteri : (int ‑> 'a ‑> unit) ‑> 'a t ‑> unit

Like Array.iter, but the -function is applied with the index of the element as first argument, -and the element itself as second argument.

val blit : 'a t ‑> int ‑> 'a t ‑> int ‑> int ‑> unit

blit v1 o1 v2 o2 len copies len elements -from array v1, starting at element number o1, to array v2, -starting at element number o2. It works correctly even if -v1 and v2 are the same array, and the source and -destination chunks overlap.

Raise Invalid_argument "Array.blit" if o1 and len do not -designate a valid subarray of v1, or if o2 and len do not -designate a valid subarray of v2.

val reverse_in_place : 'a t ‑> unit

Reverse the array in place.

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

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

  • Since: 1.0
val sort_indices : ('a ‑> 'a ‑> int) ‑> 'a t ‑> int array

sort_indices cmp 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 cmp a -appears in a. a is not modified.

In other words, map (fun i -> a.(i)) (sort_indices cmp a) = sorted cmp 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 cmp a returns a new array b, with the same length as a, -such that b.(i) is the index at which the i-the element of a appears -in sorted cmp a. a is not modified.

In other words, map (fun i -> (sorted cmp a).(i)) (sort_ranking cmp 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 find : ('a ‑> 'b option) ‑> 'a t ‑> 'b option

find f a returns Some y if there is an element x such -that f x = Some y, else it returns None.

val findi : (int ‑> 'a ‑> 'b option) ‑> 'a t ‑> 'b option

Like find, but also pass the index to the predicate function.

  • Since: 0.3.4
val find_idx : ('a ‑> bool) ‑> 'a t ‑> (int * 'a) option

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

  • Since: 0.3.4
val lookup : cmp:'a ord ‑> 'a ‑> 'a t ‑> int option

Lookup the index of some value in a sorted array.

  • Returns None if the key is not present, or -Some i (i the index of the key) otherwise.
val lookup_exn : cmp:'a ord ‑> 'a ‑> 'a t ‑> int

Like lookup, but

  • Raises Not_found: if the 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 x arr finds the index of the object x in the array arr, -provided arr 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 -(dichotomic search).

  • Returns

    • `At i if cmp arr.(i) x = 0 (for some i).
    • `All_lower if all elements of arr are lower than x.
    • `All_bigger if all elements of arr are bigger than x.
    • `Just_after i if arr.(i) < x < arr.(i+1).
    • `Empty if the array is empty.
  • Raises Invalid_argument: if the array is found to be unsorted w.r.t cmp.
  • Since: 0.13
val for_all : ('a ‑> bool) ‑> 'a t ‑> bool

for_all p [|a1; ...; an|] checks if all elements of the array -satisfy the predicate p. That is, it returns -(p a1) && (p a2) && ... && (p an).

val for_all2 : ('a ‑> 'b ‑> bool) ‑> 'a t ‑> 'b t ‑> bool

Forall on pairs of arrays.

  • Raises Invalid_argument: if they have distinct lengths. -Allow different types.
  • Since: 0.20
val exists : ('a ‑> bool) ‑> 'a t ‑> bool

exists p [|a1; ...; an|] checks if at least one element of -the array satisfies the predicate p. That is, it returns -(p a1) || (p a2) || ... || (p an).

val exists2 : ('a ‑> 'b ‑> bool) ‑> 'a t ‑> 'b t ‑> bool

Exists on pairs of arrays.

  • Raises Invalid_argument: if they have distinct lengths. -Allow different types.
  • Since: 0.20
val fold2 : ('acc ‑> 'a ‑> 'b ‑> 'acc) ‑> 'acc ‑> 'a t ‑> 'b t ‑> 'acc

Fold on two arrays stepwise.

  • Raises Invalid_argument: if they have distinct lengths.
  • Since: 0.20
val iter2 : ('a ‑> 'b ‑> unit) ‑> 'a t ‑> 'b t ‑> unit

Iterate on two arrays stepwise.

  • Raises Invalid_argument: if they have distinct lengths.
  • Since: 0.20
val shuffle : 'a t ‑> unit

Shuffle randomly the array, in place.

val shuffle_with : Random.State.t ‑> 'a t ‑> unit

Like shuffle but using a specialized random state.

val random_choose : 'a t ‑> 'a random_gen

Choose an element randomly.

  • Raises Not_found: if the array/slice is empty.
val to_seq : 'a t ‑> 'a sequence

Return a sequence of the elements of a slice.

val to_gen : 'a t ‑> 'a gen

Return a gen of the elements of a slice.

val to_klist : 'a t ‑> 'a klist

Return a klist of the elements of a slice.

IO

val pp : ?⁠sep:string ‑> 'a printer ‑> 'a t printer

Print an array of items with printing function.

val pp_i : ?⁠sep:string ‑> (int ‑> 'a printer) ‑> 'a t printer

Print an array, giving the printing function both index and item.

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

Module CCArray_slice

Array Slice

type 'a sequence = ('a -> unit) -> unit
type 'a klist = unit -> [ `Nil | `Cons of 'a * 'a klist ]
type 'a gen = unit -> 'a option
type 'a equal = 'a -> 'a -> bool
type 'a ord = 'a -> 'a -> int
type 'a random_gen = Random.State.t -> 'a
type 'a printer = Format.formatter -> 'a -> unit
type 'a t

The type for an array slice, containing elements of type 'a

val empty : 'a t

empty is the empty array slice.

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

equal eq as1 as2 is true if the lengths of as1 and as2 are the same and if the corresponding elements test equal using eq.

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

compare cmp as1 as2 compares the two slices as1 and as2 using the comparison function cmp, element by element.

val get : 'a t -> int -> 'a

get as n returns the element number n of slice as. The first element has number 0. The last element has number length as - 1. You can also write as.(n) instead of get as n.

Raise Invalid_argument "index out of bounds" if n is outside the range 0 to (length as - 1).

val get_safe : 'a t -> int -> 'a option

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

since
0.18
val make : 'a array -> int -> len:int -> 'a t

make a i ~len creates a slice from given offset i and length len of the given array a.

raises Invalid_argument

if the slice isn't valid.

val of_slice : ('a array * int * int) -> 'a t

of_slice (a, i, len) makes a slice from a triple (a, i, len) where a is the array, i the offset in a, and len the number of elements of the slice.

raises Invalid_argument

if the slice isn't valid (See make).

val to_slice : 'a t -> 'a array * int * int

to_slice as converts the slice as into a triple (a, i, len) where len is the length of the sub-array of a starting at offset i.

val to_list : 'a t -> 'a list

to_list as converts the slice as directly to a list.

since
1.0
val full : 'a array -> 'a t

full a creates a slice that covers the full array a.

val underlying : 'a t -> 'a array

underlying as returns the underlying array (shared). Modifying this array will modify the slice as.

val copy : 'a t -> 'a array

copy as copies the slice as into a new array.

val sub : 'a t -> int -> int -> 'a t

sub as i len builds a new sub-slice that contains the given subrange specified by the index i and the length len.

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

set as n x modifies the slice as in place, replacing element number n with x. You can also write as.(n) <- x instead of set as n x.

Raise Invalid_argument "index out of bounds" if n is outside the range 0 to length as - 1.

val length : _ t -> int

length as returns the length (number of elements) of the given slice as.

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

fold f acc as computes f (... (f (f acc as.(0)) as.(1)) ...) as.(length as - 1).

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

foldi f acc as 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 acc as folds left on slice as until a stop condition via ('a, `Stop) is indicated by the accumulator.

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

iter f as applies function f in turn to all elements of as. It is equivalent to f as.(0); f as.(1); ...; f as.(length as - 1); ().

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

iteri f as is like iter, but the function f is applied with the index of the element as first argument, and the element itself as second argument.

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

blit as1 o1 as2 o2 len copies len elements from slice as1, starting at element number o1, to slice as2, starting at element number o2. It works correctly even if as1 and as2 are the same slice, and the source and destination chunks overlap.

Raise Invalid_argument "CCArray_slice.blit" if o1 and len do not designate a valid subarray of as1, or if o2 and len do not designate a valid subarray of as2.

val reverse_in_place : 'a t -> unit

reverse_in_place as reverses the slice as in place.

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

sorted cmp as makes a copy of as and sorts it with cmp.

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

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

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

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

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

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

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

since
1.0
val find : ('a -> 'b option) -> 'a t -> 'b option

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

val findi : (int -> 'a -> 'b option) -> 'a t -> 'b option

findi f as is like find, but the index of the element is also passed to the predicate function f.

since
0.3.4
val find_idx : ('a -> bool) -> 'a t -> (int * 'a) option

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

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

lookup ~cmp x as lookups the index i of some key x in the slice as, provided as is sorted using cmp.

returns

None if the key x 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 x as is like lookup, but

raises Not_found

if the key x 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 x as finds the index of the object x in the slice as, provided as is sorted using cmp. If the slice is not sorted, the result is not specified (may raise Invalid_argument).

Complexity: O(log n) where n is the length of the slice as (dichotomic search).

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

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

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

for_all p [|as1; ...; asn|] checks if all elements of the slice satisfy the predicate p. That is, it returns (p as1) && (p as2) && ... && (p asn).

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

for_all2 p [|as1; ...; asn|] [|bs1; ...; bsn|] is true if each pair of elements asi bsi satisfies the predicate p. That is, it returns (p as1 bs1) && (p as2 bs2) && ... && (p asn bsn).

raises Invalid_argument

if slices have distinct lengths. Allow different types.

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

exists p [|as1; ...; asn|] is true if at least one element of the slice satisfies the predicate p. That is, it returns (p as1) || (p as2) || ... || (p asn).

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

exists2 p [|as1; ...; asn|] [|bs1; ...; bsn|] is true if any pair of elements asi bsi satisfies the predicate p. That is, it returns (p as1 bs1) || (p as2 bs2) || ... || (p asn bsn).

raises Invalid_argument

if slices have distinct lengths. Allow different types.

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

fold2 f acc as bs fold on two slices as and bs stepwise. It computes f (... (f acc as1 bs1)...) asn bsn.

raises Invalid_argument

if slices have distinct lengths.

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

iter2 f as bs iterates on the two slices as and bs stepwise. It is equivalent to f as0 bs0; ...; f as.(length as - 1) bs.(length bs - 1); ().

raises Invalid_argument

if slices have distinct lengths.

since
0.20
val shuffle : 'a t -> unit

shuffle as randomly shuffles the slice as, in place.

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

shuffle_with rs as randomly shuffles the slice as (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 as rs randomly chooses an element of as.

raises Not_found

if the array/slice is empty.

val to_seq : 'a t -> 'a sequence

to_seq as returns a sequence of the elements of a slice as. The input slice as is shared with the sequence and modification of it will result in modification of the sequence.

val to_gen : 'a t -> 'a gen

to_gen as returns a gen of the elements of a slice as.

val to_klist : 'a t -> 'a klist

to_klist as returns a klist of the elements of a slice as.

IO

val pp : ?⁠sep:string -> 'a printer -> 'a t printer

pp ~sep pp_item ppf as formats the slice as on ppf. Each element is formatted with pp_item and elements are separated by sep (defaults to ", ").

val pp_i : ?⁠sep:string -> (int -> 'a printer) -> 'a t printer

pp_i ~sep pp_item ppf as prints the slice as on ppf. The printing function pp_item is giving both index and element. Elements are separated by sep (defaults to ", ").

\ No newline at end of file diff --git a/dev/containers/CCBool/index.html b/dev/containers/CCBool/index.html index fb335818..9227de80 100644 --- a/dev/containers/CCBool/index.html +++ b/dev/containers/CCBool/index.html @@ -1,2 +1,2 @@ -CCBool (containers.CCBool)

Module CCBool

Basic Bool functions

type t = bool
val compare : t ‑> t ‑> int

Total ordering on booleans, similar to Pervasives.compare.

val equal : t ‑> t ‑> bool
val negate : t ‑> t

Negation on booleans (functional version of not).

  • Deprecated since 1.3, simply use not instead.
type 'a printer = Format.formatter ‑> 'a ‑> unit
val pp : t printer
\ No newline at end of file +CCBool (containers.CCBool)

Module CCBool

Basic Bool functions

type t = bool
val compare : t -> t -> int

Total ordering on booleans, similar to Pervasives.compare.

val equal : t -> t -> bool
val negate : t -> t

Negation on booleans (functional version of not).

deprecated

since 1.3, simply use not instead.

type 'a printer = Format.formatter -> 'a -> unit
val pp : t printer
\ No newline at end of file diff --git a/dev/containers/CCChar/index.html b/dev/containers/CCChar/index.html index 34ab697a..c544f98a 100644 --- a/dev/containers/CCChar/index.html +++ b/dev/containers/CCChar/index.html @@ -1,9 +1,2 @@ -CCChar (containers.CCChar)

Module CCChar

Utils around char

include module type of sig ... end
external code : char ‑> int = "%identity"
val chr : int ‑> char
val escaped : char ‑> string
val lowercase : char ‑> char
  • Deprecated Use Char.lowercase_ascii instead.
val uppercase : char ‑> char
  • Deprecated Use Char.uppercase_ascii instead.
val lowercase_ascii : char ‑> char
val uppercase_ascii : char ‑> char
type t = char
val compare : t ‑> t ‑> int
val equal : t ‑> t ‑> bool
external unsafe_chr : int ‑> char = "%identity"
val equal : t ‑> t ‑> bool

The equal function for chars.

val compare : t ‑> t ‑> int

The comparison function for characters, with the same specification as -Pervasives.compare. Along with the type t, this function compare -allows the module Char to be passed as argument to the functors -Set.Make and Map.Make.

val lowercase_ascii : t ‑> t

Convert the given character to its equivalent lowercase character, -using the US-ASCII character set.

  • Since: 0.20
val uppercase_ascii : t ‑> t

Convert the given character to its equivalent uppercase character, -using the US-ASCII character set.

  • Since: 0.20
val of_int_exn : int ‑> t

Alias to Char.chr. -Return the character with the given ASCII code.

  • Raises Invalid_argument: if the int is not within 0,...,255.
  • Since: 1.0
val of_int : int ‑> t option

Safe version of of_int_exn.

  • Since: 1.0
val to_int : t ‑> int

Alias to Char.code. -Return the ASCII code of the argument.

  • Since: 1.0
val pp_buf : Buffer.t ‑> t ‑> unit

Renamed from pp since 2.0.

val pp : Format.formatter ‑> t ‑> unit

Renamed from print since 2.0.

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

Module CCChar

Utils around char

since
0.14
include module type of sig ... end
val code : char -> int
val chr : int -> char
val escaped : char -> string
val lowercase : char -> char
val uppercase : char -> char
val lowercase_ascii : char -> char
val uppercase_ascii : char -> char
type t = char
val compare : t -> t -> int
val equal : t -> t -> bool
val unsafe_chr : int -> char
val equal : t -> t -> bool

The equal function for chars.

val compare : t -> t -> int

The comparison function for characters, with the same specification as Pervasives.compare. Along with the type t, this function compare allows the module Char to be passed as argument to the functors Set.Make and Map.Make.

val lowercase_ascii : t -> t

Convert the given character to its equivalent lowercase character, using the US-ASCII character set.

since
0.20
val uppercase_ascii : t -> t

Convert the given character to its equivalent uppercase character, using the US-ASCII character set.

since
0.20
val of_int_exn : int -> t

Alias to Char.chr. Return the character with the given ASCII code.

raises Invalid_argument

if the int is not within 0,...,255.

since
1.0
val of_int : int -> t option

Safe version of of_int_exn.

since
1.0
val to_int : t -> int

Alias to Char.code. Return the ASCII code of the argument.

since
1.0
val pp_buf : Buffer.t -> t -> unit

Renamed from pp since 2.0.

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

Renamed from print since 2.0.

\ No newline at end of file diff --git a/dev/containers/CCEqual/Infix/index.html b/dev/containers/CCEqual/Infix/index.html index a69ba8ed..e27f133e 100644 --- a/dev/containers/CCEqual/Infix/index.html +++ b/dev/containers/CCEqual/Infix/index.html @@ -1,2 +1,2 @@ -Infix (containers.CCEqual.Infix)

Module CCEqual.Infix

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

Infix equivalent of map.

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

Module CCEqual.Infix

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

Infix equivalent of map.

\ No newline at end of file diff --git a/dev/containers/CCEqual/index.html b/dev/containers/CCEqual/index.html index 77d10d54..2f48a084 100644 --- a/dev/containers/CCEqual/index.html +++ b/dev/containers/CCEqual/index.html @@ -1,7 +1,2 @@ -CCEqual (containers.CCEqual)

Module CCEqual

Equality Combinators

type 'a t = 'a ‑> 'a ‑> bool

Equality function. Must be transitive, symmetric, and reflexive.

val poly : 'a t

Standard polymorphic equality.

val physical : 'a t

Standard physical equality.

  • Since: 2.0
val int : int t
val string : string t
val bool : bool t
val float : float t
val unit : unit t
val list : 'a t ‑> 'a list t
val array : 'a t ‑> 'a array t
val option : 'a t ‑> 'a option t
val pair : 'a t ‑> 'b t ‑> ('a * 'b) t
val triple : 'a t ‑> 'b t ‑> 'c t ‑> ('a * 'b * 'c) t
val map : ('a ‑> 'b) ‑> 'b t ‑> 'a t

map f eq is the equality function that, given objects x and y, -projects x and y using f (e.g. using a record field) and then -compares those projections with eq. -Example: -map fst int compares values of type (int * 'a) by their -first component.

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

Infix equivalent of map.

module Infix : sig ... end
\ No newline at end of file +CCEqual (containers.CCEqual)

Module CCEqual

Equality Combinators

type 'a t = 'a -> 'a -> bool

Equality function. Must be transitive, symmetric, and reflexive.

val poly : 'a t

Standard polymorphic equality.

val physical : 'a t

Standard physical equality.

since
2.0
val int : int t
val string : string t
val bool : bool t
val float : float t
val unit : unit t
val list : 'a t -> 'a list t
val array : 'a t -> 'a array t
val option : 'a t -> 'a option t
val pair : 'a t -> 'b t -> ('a * 'b) t
val triple : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t
val map : ('a -> 'b) -> 'b t -> 'a t

map f eq is the equality function that, given objects x and y, projects x and y using f (e.g. using a record field) and then compares those projections with eq. Example: map fst int compares values of type (int * 'a) by their first component.

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

Infix equivalent of map.

\ No newline at end of file diff --git a/dev/containers/CCFloat/Infix/index.html b/dev/containers/CCFloat/Infix/index.html index 6d8c0861..919c3ba1 100644 --- a/dev/containers/CCFloat/Infix/index.html +++ b/dev/containers/CCFloat/Infix/index.html @@ -1,2 +1,2 @@ -Infix (containers.CCFloat.Infix)

Module CCFloat.Infix

val (=) : t ‑> t ‑> bool
  • Since: 0.17
val (<>) : t ‑> t ‑> bool
  • Since: 0.17
val (<) : t ‑> t ‑> bool
  • Since: 0.17
val (>) : t ‑> t ‑> bool
  • Since: 0.17
val (<=) : t ‑> t ‑> bool
  • Since: 0.17
val (>=) : t ‑> t ‑> bool
  • Since: 0.17
val (+) : t ‑> t ‑> t

Addition.

  • Since: 2.1
val (-) : t ‑> t ‑> t

Subtraction.

  • Since: 2.1
val (~-) : t ‑> t

Unary negation.

  • Since: 2.1
val (*) : t ‑> t ‑> t

Multiplication.

  • Since: 2.1
val (/) : t ‑> t ‑> t

Division.

  • Since: 2.1
\ No newline at end of file +Infix (containers.CCFloat.Infix)

Module CCFloat.Infix

val (=) : t -> t -> bool
since
0.17
val (<>) : t -> t -> bool
since
0.17
val (<) : t -> t -> bool
since
0.17
val (>) : t -> t -> bool
since
0.17
val (<=) : t -> t -> bool
since
0.17
val (>=) : t -> t -> bool
since
0.17
val (+) : t -> t -> t

Addition.

since
2.1
val (-) : t -> t -> t

Subtraction.

since
2.1
val (~-) : t -> t

Unary negation.

since
2.1
val (*) : t -> t -> t

Multiplication.

since
2.1
val (/) : t -> t -> t

Division.

since
2.1
\ No newline at end of file diff --git a/dev/containers/CCFloat/index.html b/dev/containers/CCFloat/index.html index 8b74ab5b..b2883875 100644 --- a/dev/containers/CCFloat/index.html +++ b/dev/containers/CCFloat/index.html @@ -1,8 +1,2 @@ -CCFloat (containers.CCFloat)

Module CCFloat

Basic operations on floating-point numbers

type t = float
type fpclass = Pervasives.fpclass =
| FP_normal
| FP_subnormal
| FP_zero
| FP_infinite
| FP_nan
val nan : t

Equal to Pervasives.nan.

val max_value : t

Positive infinity. Equal to Pervasives.infinity.

val min_value : t

Negative infinity. Equal to Pervasives.neg_infinity.

val max_finite_value : t

Equal to Pervasives.max_float.

val epsilon : t

The smallest positive float x such that 1.0 +. x <> 1.0. -Equal to Pervasives.epsilon_float.

val is_nan : t ‑> bool

is_nan f returns true if f is NaN, false otherwise.

val add : t ‑> t ‑> t

Equal to (+.).

val sub : t ‑> t ‑> t

Equal to (-.).

val neg : t ‑> t

Equal to (~-.).

val abs : t ‑> t

The absolute value of a floating-point number. -Equal to Pervasives.abs_float.

val scale : t ‑> t ‑> t

Equal to ( *. ).

val min : t ‑> t ‑> t
val max : t ‑> t ‑> t
val equal : t ‑> t ‑> bool
val compare : t ‑> t ‑> int
type 'a printer = Format.formatter ‑> 'a ‑> unit
type 'a random_gen = Random.State.t ‑> 'a
val pp : t printer
val hash : t ‑> int
val random : t ‑> t random_gen
val random_small : t random_gen
val random_range : t ‑> t ‑> t random_gen
val fsign : t ‑> t

fsign x is one of -1., -0., +0., +1., or nan if x is NaN.

  • Since: 0.7
val round : t ‑> t

round f returns the closest integer value, either above or below.

  • Since: 0.20
exception TrapNaN of string
val sign_exn : t ‑> int

sign_exn x will return the sign of x as 1, 0 or -1, or raise an -exception TrapNaN if x is NaN. -Note that infinities have defined signs in OCaml.

  • Since: 0.7
val to_int : t ‑> int

Alias to int_of_float. -Unspecified if outside of the range of integers.

val of_int : int ‑> t

Alias to float_of_int.

val to_string : t ‑> string
val of_string_exn : string ‑> t

Alias to float_of_string.

  • Raises Failure: in case of failure.
  • Since: 1.2
val of_string : string ‑> t

Alias to float_of_string.

  • Deprecated since 1.2, use of_string_exn instead.
  • Raises Failure: in case of failure.
val equal_precision : epsilon:t ‑> t ‑> t ‑> bool

Equality with allowed error up to a non negative epsilon value.

val classify : t ‑> fpclass

Return the class of the given floating-point number: -normal, subnormal, zero, infinite or nan (not a number).

Infix Operators

module Infix : sig ... end
include module type of Infix
val (=) : t ‑> t ‑> bool
  • Since: 0.17
val (<>) : t ‑> t ‑> bool
  • Since: 0.17
val (<) : t ‑> t ‑> bool
  • Since: 0.17
val (>) : t ‑> t ‑> bool
  • Since: 0.17
val (<=) : t ‑> t ‑> bool
  • Since: 0.17
val (>=) : t ‑> t ‑> bool
  • Since: 0.17
val (+) : t ‑> t ‑> t

Addition.

  • Since: 2.1
val (-) : t ‑> t ‑> t

Subtraction.

  • Since: 2.1
val (~-) : t ‑> t

Unary negation.

  • Since: 2.1
val (*) : t ‑> t ‑> t

Multiplication.

  • Since: 2.1
val (/) : t ‑> t ‑> t

Division.

  • Since: 2.1
\ No newline at end of file +CCFloat (containers.CCFloat)

Module CCFloat

Basic operations on floating-point numbers

since
0.6.1
type t = float
type fpclass = Pervasives.fpclass =
| FP_normal
| FP_subnormal
| FP_zero
| FP_infinite
| FP_nan
val nan : t

Equal to Pervasives.nan.

val max_value : t

Positive infinity. Equal to Pervasives.infinity.

val min_value : t

Negative infinity. Equal to Pervasives.neg_infinity.

val max_finite_value : t

Equal to Pervasives.max_float.

val epsilon : t

The smallest positive float x such that 1.0 +. x <> 1.0. Equal to Pervasives.epsilon_float.

val is_nan : t -> bool

is_nan f returns true if f is NaN, false otherwise.

val add : t -> t -> t

Equal to (+.).

val sub : t -> t -> t

Equal to (-.).

val neg : t -> t

Equal to (~-.).

val abs : t -> t

The absolute value of a floating-point number. Equal to Pervasives.abs_float.

val scale : t -> t -> t

Equal to ( *. ).

val min : t -> t -> t
val max : t -> t -> t
val equal : t -> t -> bool
val compare : t -> t -> int
type 'a printer = Format.formatter -> 'a -> unit
type 'a random_gen = Random.State.t -> 'a
val pp : t printer
val hash : t -> int
val random : t -> t random_gen
val random_small : t random_gen
val random_range : t -> t -> t random_gen
val fsign : t -> t

fsign x is one of -1., -0., +0., +1., or nan if x is NaN.

since
0.7
val round : t -> t

round f returns the closest integer value, either above or below.

since
0.20
exception TrapNaN of string
val sign_exn : t -> int

sign_exn x will return the sign of x as 1, 0 or -1, or raise an exception TrapNaN if x is NaN. Note that infinities have defined signs in OCaml.

since
0.7
val to_int : t -> int

Alias to int_of_float. Unspecified if outside of the range of integers.

val of_int : int -> t

Alias to float_of_int.

val to_string : t -> string
val of_string_exn : string -> t

Alias to float_of_string.

raises Failure

in case of failure.

since
1.2
val of_string : string -> t

Alias to float_of_string.

deprecated

since 1.2, use of_string_exn instead.

raises Failure

in case of failure.

val equal_precision : epsilon:t -> t -> t -> bool

Equality with allowed error up to a non negative epsilon value.

val classify : t -> fpclass

Return the class of the given floating-point number: normal, subnormal, zero, infinite or nan (not a number).

Infix Operators

since
0.17
module Infix : sig ... end
include module type of Infix
val (=) : t -> t -> bool
since
0.17
val (<>) : t -> t -> bool
since
0.17
val (<) : t -> t -> bool
since
0.17
val (>) : t -> t -> bool
since
0.17
val (<=) : t -> t -> bool
since
0.17
val (>=) : t -> t -> bool
since
0.17
val (+) : t -> t -> t

Addition.

since
2.1
val (-) : t -> t -> t

Subtraction.

since
2.1
val (~-) : t -> t

Unary negation.

since
2.1
val (*) : t -> t -> t

Multiplication.

since
2.1
val (/) : t -> t -> t

Division.

since
2.1
\ No newline at end of file diff --git a/dev/containers/CCFormat/Dump/index.html b/dev/containers/CCFormat/Dump/index.html index b488489f..5c52cb74 100644 --- a/dev/containers/CCFormat/Dump/index.html +++ b/dev/containers/CCFormat/Dump/index.html @@ -1,2 +1,2 @@ -Dump (containers.CCFormat.Dump)

Module CCFormat.Dump

type 'a t = 'a printer
val unit : unit t
val int : int t
val string : string t
val bool : bool t
val float : float t
val char : char t
val int32 : int32 t
val int64 : int64 t
val nativeint : nativeint t
val list : 'a t ‑> 'a list t
val array : 'a t ‑> 'a array t
val option : 'a t ‑> 'a option t
val pair : 'a t ‑> 'b t ‑> ('a * 'b) t
val triple : 'a t ‑> 'b t ‑> 'c t ‑> ('a * 'b * 'c) t
val quad : 'a t ‑> 'b t ‑> 'c t ‑> 'd t ‑> ('a * 'b * 'c * 'd) t
val result : 'a t ‑> ('a, string) Result.result t
val result' : 'a t ‑> 'e t ‑> ('a'e) Result.result t
val to_string : 'a t ‑> 'a ‑> string
\ No newline at end of file +Dump (containers.CCFormat.Dump)

Module CCFormat.Dump

type 'a t = 'a printer
val unit : unit t
val int : int t
val string : string t
val bool : bool t
val float : float t
val char : char t
val int32 : int32 t
val int64 : int64 t
val nativeint : nativeint t
val list : 'a t -> 'a list t
val array : 'a t -> 'a array t
val option : 'a t -> 'a option t
val pair : 'a t -> 'b t -> ('a * 'b) t
val triple : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t
val quad : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) t
val result : 'a t -> ('a, string) Result.result t
val result' : 'a t -> 'e t -> ('a'e) Result.result t
val to_string : 'a t -> 'a -> string

Alias to CCFormat.to_string.

\ No newline at end of file diff --git a/dev/containers/CCFormat/index.html b/dev/containers/CCFormat/index.html index cdb21fb0..6c41e004 100644 --- a/dev/containers/CCFormat/index.html +++ b/dev/containers/CCFormat/index.html @@ -1,44 +1,14 @@ -CCFormat (containers.CCFormat)

Module CCFormat

Helpers for Format

type 'a sequence = ('a ‑> unit) ‑> unit
include module type of sig ... end
type formatter = 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_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
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 tag = string
val pp_open_tag : formatter ‑> string ‑> unit
val open_tag : tag ‑> unit
val pp_close_tag : formatter ‑> unit ‑> unit
val close_tag : 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 ‑> Pervasives.out_channel ‑> unit
val set_formatter_out_channel : Pervasives.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 = 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_tag_functions = 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
val formatter_of_out_channel : Pervasives.out_channel ‑> formatter
val std_formatter : formatter
val err_formatter : formatter
val formatter_of_buffer : Buffer.t ‑> formatter
val stdbuf : 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 = Format.symbolic_output_item =
| Output_flush
| Output_newline
| Output_string of string
| Output_spaces of int
| Output_indent of int
type symbolic_output_buffer = 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_text : formatter ‑> string ‑> unit
val fprintf : formatter ‑> ('aformatter, unit) Pervasives.format ‑> 'a
val printf : ('aformatter, unit) Pervasives.format ‑> 'a
val eprintf : ('aformatter, unit) Pervasives.format ‑> 'a
val sprintf : ('a, unit, string) Pervasives.format ‑> 'a
val asprintf : ('aformatter, unit, string) Pervasives.format4 ‑> 'a
val ifprintf : formatter ‑> ('aformatter, unit) Pervasives.format ‑> 'a
val kfprintf : (formatter ‑> 'a) ‑> formatter ‑> ('bformatter, unit, 'a) Pervasives.format4 ‑> 'b
val ikfprintf : (formatter ‑> 'a) ‑> formatter ‑> ('bformatter, unit, 'a) Pervasives.format4 ‑> 'b
val ksprintf : (string ‑> 'a) ‑> ('b, unit, string, 'a) Pervasives.format4 ‑> 'b
val kasprintf : (string ‑> 'a) ‑> ('bformatter, unit, 'a) Pervasives.format4 ‑> 'b
val bprintf : Buffer.t ‑> ('aformatter, unit) Pervasives.format ‑> 'a
val kprintf : (string ‑> 'a) ‑> ('b, unit, string, 'a) Pervasives.format4 ‑> 'b
  • Deprecated Use Format.ksprintf instead.
val set_all_formatter_output_functions : out:(string ‑> int ‑> int ‑> unit) ‑> flush:(unit ‑> unit) ‑> newline:(unit ‑> unit) ‑> spaces:(int ‑> unit) ‑> unit
  • Deprecated Use Format.set_formatter_out_functions instead.
val get_all_formatter_output_functions : unit ‑> (string ‑> int ‑> int ‑> unit) * (unit ‑> unit) * (unit ‑> unit) * (int ‑> unit)
  • Deprecated Use Format.get_formatter_out_functions instead.
val pp_set_all_formatter_output_functions : formatter ‑> out:(string ‑> int ‑> int ‑> unit) ‑> flush:(unit ‑> unit) ‑> newline:(unit ‑> unit) ‑> spaces:(int ‑> unit) ‑> unit
  • Deprecated Use Format.pp_set_formatter_out_functions instead.
val pp_get_all_formatter_output_functions : formatter ‑> unit ‑> (string ‑> int ‑> int ‑> unit) * (unit ‑> unit) * (unit ‑> unit) * (int ‑> unit)
  • Deprecated Use Format.pp_get_formatter_out_functions instead.
type t = 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 newline : unit printer

Force newline (see Format.pp_force_newline).

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

Print 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 char : char printer
  • Since: 0.14
val int32 : int32 printer
  • Since: 0.14
  • Since: 0.14
val int64 : int64 printer
  • Since: 0.14
  • Since: 0.14
val nativeint : nativeint printer
  • Since: 0.14
  • 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 sequence 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.

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 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) Pervasives.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 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:

Example:

      set_color_default true;;
+CCFormat (containers.CCFormat)

Module CCFormat

Helpers for Format

since
0.8
type 'a sequence = ('a -> unit) -> unit
include module type of sig ... end
type formatter = 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_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
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 tag = string
val pp_open_tag : formatter -> string -> unit
val open_tag : tag -> unit
val pp_close_tag : formatter -> unit -> unit
val close_tag : 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 -> Pervasives.out_channel -> unit
val set_formatter_out_channel : Pervasives.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 = 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_tag_functions = 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
val formatter_of_out_channel : Pervasives.out_channel -> formatter
val std_formatter : formatter
val err_formatter : formatter
val formatter_of_buffer : Buffer.t -> formatter
val stdbuf : 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 = Format.symbolic_output_item =
| Output_flush
| Output_newline
| Output_string of string
| Output_spaces of int
| Output_indent of int
type symbolic_output_buffer = 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_text : formatter -> string -> unit
val fprintf : formatter -> ('aformatter, unit) Pervasives.format -> 'a
val printf : ('aformatter, unit) Pervasives.format -> 'a
val eprintf : ('aformatter, unit) Pervasives.format -> 'a
val sprintf : ('a, unit, string) Pervasives.format -> 'a
val asprintf : ('aformatter, unit, string) Pervasives.format4 -> 'a
val ifprintf : formatter -> ('aformatter, unit) Pervasives.format -> 'a
val kfprintf : (formatter -> 'a) -> formatter -> ('bformatter, unit, 'a) Pervasives.format4 -> 'b
val ikfprintf : (formatter -> 'a) -> formatter -> ('bformatter, unit, 'a) Pervasives.format4 -> 'b
val ksprintf : (string -> 'a) -> ('b, unit, string, 'a) Pervasives.format4 -> 'b
val kasprintf : (string -> 'a) -> ('bformatter, unit, 'a) Pervasives.format4 -> 'b
val bprintf : Buffer.t -> ('aformatter, unit) Pervasives.format -> 'a
val kprintf : (string -> 'a) -> ('b, unit, string, 'a) Pervasives.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)
type t = 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 newline : unit printer

Force newline (see Format.pp_force_newline).

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

Print 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 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 sequence 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".
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 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) Pervasives.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 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) Pervasives.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) Pervasives.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) Pervasives.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

IO

val output : t ‑> 'a printer ‑> 'a ‑> unit
val to_string : 'a printer ‑> 'a ‑> string
val of_chan : Pervasives.out_channel ‑> t

Alias to Format.formatter_of_out_channel.

  • Since: 1.2
val with_out_chan : Pervasives.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) Pervasives.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) Pervasives.format4 ‑> 'a

Like sprintf but never prints colors.

  • Since: 0.16
val sprintf_dyn_color : colors:bool ‑> ('at, unit, string) Pervasives.format4 ‑> 'a

Like sprintf but enable/disable colors depending on colors.

Example: -

      (* with colors *)
-      CCFormat.sprintf_dyn_color ~colors:true "@{<Red>%a@}"
-        CCFormat.Dump.(list int) [1;2;3] |> print_endline;;
+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) Pervasives.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) Pervasives.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) Pervasives.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

IO

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

Alias to Format.formatter_of_out_channel.

since
1.2
val with_out_chan : Pervasives.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) Pervasives.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) Pervasives.format4 -> 'a

Like sprintf but never prints colors.

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

Like sprintf but enable/disable colors depending on colors.

Example:

(* with colors *)
+CCFormat.sprintf_dyn_color ~colors:true "@{<Red>%a@}"
+  CCFormat.Dump.(list int) [1;2;3] |> print_endline;;
 
-      (* without colors *)
-      CCFormat.sprintf_dyn_color ~colors:false "@{<Red>%a@}"
-        CCFormat.Dump.(list int) [1;2;3] |> print_endline;;
  • Since: 0.21
val fprintf : t ‑> ('at, unit) Pervasives.format ‑> 'a

Alias to Format.fprintf.

  • Since: 0.14
val fprintf_dyn_color : colors:bool ‑> t ‑> ('at, unit) Pervasives.format ‑> 'a

Like fprintf but enable/disable colors depending on colors.

  • Since: 0.21
val ksprintf : ?⁠margin:int ‑> f:(string ‑> 'b) ‑> ('a, Format.formatter, unit, 'b) Pervasives.format4 ‑> 'a

ksprintf fmt ~f formats using fmt, in a way similar to sprintf, -and then calls f on the resulting string.

  • Parameter margin: set margin (since 2.1)
  • Since: 0.14
val to_file : string ‑> ('at, unit, unit) Pervasives.format4 ‑> 'a

Print to the given file.

Dump

Print structures as OCaml values, so that they can be parsed back -by OCaml (typically, in the toplevel, for debugging).

Example: -

      Format.printf "%a@." CCFormat.Dump.(list int) CCList.(1 -- 200);;
+(* without colors *)
+CCFormat.sprintf_dyn_color ~colors:false "@{<Red>%a@}"
+  CCFormat.Dump.(list int) [1;2;3] |> print_endline;;
since
0.21
val fprintf : t -> ('at, unit) Pervasives.format -> 'a

Alias to Format.fprintf.

since
0.14
val fprintf_dyn_color : colors:bool -> t -> ('at, unit) Pervasives.format -> 'a

Like fprintf but enable/disable colors depending on colors.

since
0.21
val ksprintf : ?⁠margin:int -> f:(string -> 'b) -> ('a, Format.formatter, unit, 'b) Pervasives.format4 -> 'a

ksprintf fmt ~f formats using fmt, in a way similar to sprintf, and then calls f on the resulting string.

parameter margin

set margin (since 2.1)

since
0.14
val to_file : string -> ('at, unit, unit) Pervasives.format4 -> 'a

Print to the given file.

Dump

Print structures as OCaml values, so that they can be parsed back by OCaml (typically, in the toplevel, for debugging).

Example:

Format.printf "%a@." CCFormat.Dump.(list int) CCList.(1 -- 200);;
 
-      Format.printf "%a@." CCFormat.Dump.(array (list (pair int bool)))
-        [| [1, true; 2, false]; []; [42, false] |];;
  • Since: 0.21
module Dump : sig ... end
\ No newline at end of file +Format.printf "%a@." CCFormat.Dump.(array (list (pair int bool))) + [| [1, true; 2, false]; []; [42, false] |];;
since
0.21
module Dump : sig ... end
\ No newline at end of file diff --git a/dev/containers/CCFun/Monad/argument-1-X/index.html b/dev/containers/CCFun/Monad/argument-1-X/index.html index 2aecaebc..815b1ee1 100644 --- a/dev/containers/CCFun/Monad/argument-1-X/index.html +++ b/dev/containers/CCFun/Monad/argument-1-X/index.html @@ -1,2 +1,2 @@ -1-X (containers.CCFun.Monad.1-X)

Parameter CCFun.Monad.1-X

type t
\ No newline at end of file +1-X (containers.CCFun.Monad.1-X)

Parameter Monad.1-X

type t
\ No newline at end of file diff --git a/dev/containers/CCFun/Monad/index.html b/dev/containers/CCFun/Monad/index.html index 67350d69..adfaf985 100644 --- a/dev/containers/CCFun/Monad/index.html +++ b/dev/containers/CCFun/Monad/index.html @@ -1,2 +1,2 @@ -Monad (containers.CCFun.Monad)

Module CCFun.Monad

Parameters

X : sig ... end

Signature

type 'a t = X.t ‑> 'a
val return : 'a ‑> 'a t

Monadic return.

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

Monadic bind.

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

Module CCFun.Monad

Parameters

Signature

type 'a t = X.t -> 'a
val return : 'a -> 'a t

Monadic return.

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

Monadic bind.

\ No newline at end of file diff --git a/dev/containers/CCFun/index.html b/dev/containers/CCFun/index.html index 744a839b..02cbea9c 100644 --- a/dev/containers/CCFun/index.html +++ b/dev/containers/CCFun/index.html @@ -1,18 +1,4 @@ -CCFun (containers.CCFun)

Module CCFun

Basic Functions

val (|>) : 'a ‑> ('a ‑> 'b) ‑> 'b

A 'pipe' operator. x |> f is the same as f x.

val compose : ('a ‑> 'b) ‑> ('b ‑> 'c) ‑> 'a ‑> 'c

Composition. compose f g x is g (f x).

val compose_binop : ('a ‑> 'b) ‑> ('b ‑> 'b ‑> 'c) ‑> 'a ‑> 'a ‑> 'c

compose_binop f g is fun x y -> g (f x) (f y). -Example (partial order): -List.sort (compose_binop fst CCInt.compare) [1, true; 2, false; 1, false].

  • Since: 0.6
val (%>) : ('a ‑> 'b) ‑> ('b ‑> 'c) ‑> 'a ‑> 'c

Alias to compose.

val (@@) : ('a ‑> 'b) ‑> 'a ‑> 'b

f @@ x is the same as f x, but right-associative.

  • Since: 0.5
val id : 'a ‑> 'a

Identity function.

val const : 'a ‑> 'b ‑> 'a

Produce a function that just returns its first argument. -const x y = x for any y.

val flip : ('a ‑> 'b ‑> 'c) ‑> 'b ‑> 'a ‑> 'c

Reverse the order of arguments for a binary function.

val curry : (('a * 'b) ‑> 'c) ‑> 'a ‑> 'b ‑> 'c

Convert a function which accepts a pair of arguments into a function which accepts two arguments. -curry f x y is f (x,y).

val uncurry : ('a ‑> 'b ‑> 'c) ‑> ('a * 'b) ‑> 'c

Convert a function which accepts a two arguments into a function which accepts a pair of arguments. -uncurry f (x,y) is f x y.

val tap : ('a ‑> _) ‑> 'a ‑> 'a

tap f x evaluates f x, discards it, then returns x. Useful -in a pipeline, for instance: -

CCArray.(1 -- 10)
+CCFun (containers.CCFun)

Module CCFun

Basic Functions

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

A 'pipe' operator. x |> f is the same as f x.

val compose : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c

Composition. compose f g x is g (f x).

val compose_binop : ('a -> 'b) -> ('b -> 'b -> 'c) -> 'a -> 'a -> 'c

compose_binop f g is fun x y -> g (f x) (f y). Example (partial order): List.sort (compose_binop fst CCInt.compare) [1, true; 2, false; 1, false].

since
0.6
val (%>) : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c

Alias to compose.

val (@@) : ('a -> 'b) -> 'a -> 'b

f @@ x is the same as f x, but right-associative.

since
0.5
val id : 'a -> 'a

Identity function.

val const : 'a -> 'b -> 'a

Produce a function that just returns its first argument. const x y = x for any y.

val flip : ('a -> 'b -> 'c) -> 'b -> 'a -> 'c

Reverse the order of arguments for a binary function.

val curry : (('a * 'b) -> 'c) -> 'a -> 'b -> 'c

Convert a function which accepts a pair of arguments into a function which accepts two arguments. curry f x y is f (x,y).

val uncurry : ('a -> 'b -> 'c) -> ('a * 'b) -> 'c

Convert a function which accepts a two arguments into a function which accepts a pair of arguments. uncurry f (x,y) is f x y.

val tap : ('a -> _) -> 'a -> 'a

tap f x evaluates f x, discards it, then returns x. Useful in a pipeline, for instance:

CCArray.(1 -- 10)
       |> tap CCArray.shuffle
-      |> tap @@ CCArray.sort Pervasives.compare
val (%) : ('b ‑> 'c) ‑> ('a ‑> 'b) ‑> 'a ‑> 'c

Mathematical composition. (%) f g x is f (g x).

val lexicographic : ('a ‑> 'a ‑> int) ‑> ('a ‑> 'a ‑> int) ‑> 'a ‑> 'a ‑> int

Lexicographic combination of comparison functions.

val finally : h:(unit ‑> _) ‑> f:(unit ‑> 'a) ‑> 'a

finally h f calls f () and returns its result. If it raises, the -same exception is raised; in any case, h () is called after -f () terminates.

val finally1 : h:(unit ‑> _) ‑> ('a ‑> 'b) ‑> 'a ‑> 'b

finally1 ~h f x is the same as f x, but after the computation, -h () is called whether f x rose an exception or not.

  • Since: 0.16
val finally2 : h:(unit ‑> _) ‑> ('a ‑> 'b ‑> 'c) ‑> 'a ‑> 'b ‑> 'c

finally2 ~h f x y is the same as f x y, but after the computation, -h () is called whether f x y rose an exception or not.

  • Since: 0.16
val opaque_identity : 'a ‑> 'a

opaque_identity x is like x, but prevents Flambda from using x's -definition for optimizing it. (flambda is an optimization/inlining pass -in OCaml >= 4.03).

  • Since: 0.18
val iterate : int ‑> ('a ‑> 'a) ‑> 'a ‑> 'a

iterate n f is f iterated n times. That is to say, iterate 0 f x is -x, iterate 1 f x is f x, iterate 2 f x is f (f x), etc.

  • Since: 2.1

Monad

Functions with a fixed domain are monads in their codomain.

module Monad : functor (X : sig ... end) -> sig ... end
\ No newline at end of file + |> tap @@ CCArray.sort Pervasives.compare
val (%) : ('b -> 'c) -> ('a -> 'b) -> 'a -> 'c

Mathematical composition. (%) f g x is f (g x).

val lexicographic : ('a -> 'a -> int) -> ('a -> 'a -> int) -> 'a -> 'a -> int

Lexicographic combination of comparison functions.

val finally : h:(unit -> _) -> f:(unit -> 'a) -> 'a

finally h f calls f () and returns its result. If it raises, the same exception is raised; in any case, h () is called after f () terminates.

val finally1 : h:(unit -> _) -> ('a -> 'b) -> 'a -> 'b

finally1 ~h f x is the same as f x, but after the computation, h () is called whether f x rose an exception or not.

since
0.16
val finally2 : h:(unit -> _) -> ('a -> 'b -> 'c) -> 'a -> 'b -> 'c

finally2 ~h f x y is the same as f x y, but after the computation, h () is called whether f x y rose an exception or not.

since
0.16
val opaque_identity : 'a -> 'a

opaque_identity x is like x, but prevents Flambda from using x's definition for optimizing it. (flambda is an optimization/inlining pass in OCaml >= 4.03).

since
0.18
val iterate : int -> ('a -> 'a) -> 'a -> 'a

iterate n f is f iterated n times. That is to say, iterate 0 f x is x, iterate 1 f x is f x, iterate 2 f x is f (f x), etc.

since
2.1

Monad

Functions with a fixed domain are monads in their codomain.

module Monad : functor (X : sig ... end) -> sig ... end
\ No newline at end of file diff --git a/dev/containers/CCHash/index.html b/dev/containers/CCHash/index.html index 149af87c..ad4090c2 100644 --- a/dev/containers/CCHash/index.html +++ b/dev/containers/CCHash/index.html @@ -1,8 +1,2 @@ -CCHash (containers.CCHash)

Module CCHash

Hash combinators

Definitions

type hash = int

A hash value is a positive integer.

type 'a t = 'a ‑> hash

A hash function for values of type 'a.

val const : hash ‑> _ t

const h hashes any value into h. Use with caution!.

val const0 : _ t

Always return 0. Useful for ignoring elements. -Example: Hash.(pair string const0) will map pairs ("a", 1) -and ("a", 2) to the same hash, but not the same as ("b", 1).

  • Since: 1.5
val int : int t
val bool : bool t
val char : char t
val int32 : int32 t
val int64 : int64 t
val nativeint : nativeint t
val slice : string ‑> int ‑> int t

slice s i len state hashes the slice i, ... i+len-1 of s -into state.

val string : string t
val list : 'a t ‑> 'a list t
val array : 'a t ‑> 'a array t
val opt : 'a t ‑> 'a option t
val pair : 'a t ‑> 'b t ‑> ('a * 'b) t
val triple : 'a t ‑> 'b t ‑> 'c t ‑> ('a * 'b * 'c) t
val quad : 'a t ‑> 'b t ‑> 'c t ‑> 'd t ‑> ('a * 'b * 'c * 'd) t
val if_ : bool ‑> 'a t ‑> 'a t ‑> 'a t

Decide which hash function to use depending on the boolean.

val poly : 'a t

The regular polymorphic hash function. -poly x is Hashtbl.hash x.

val list_comm : 'a t ‑> 'a list t

Commutative version of list. Lists that are equal up to permutation -will have the same hash.

  • Since: 1.0
val array_comm : 'a t ‑> 'a array t

Commutative version of array. Arrays that are equal up to permutation -will have the same hash.

  • Since: 1.0

Base hash combinators

val combine : 'a t ‑> hash ‑> 'a ‑> hash
val combine2 : hash ‑> hash ‑> hash
val combine3 : hash ‑> hash ‑> hash ‑> hash
val combine4 : hash ‑> hash ‑> hash ‑> hash ‑> hash
val combine5 : hash ‑> hash ‑> hash ‑> hash ‑> hash ‑> hash
  • Since: 2.1
val combine6 : hash ‑> hash ‑> hash ‑> hash ‑> hash ‑> hash ‑> hash
  • Since: 2.1

Iterators

type 'a sequence = ('a ‑> unit) ‑> unit
type 'a gen = unit ‑> 'a option
type 'a klist = unit ‑> [ `Nil | `Cons of 'a * 'a klist ]
val seq : 'a t ‑> 'a sequence t
val gen : 'a t ‑> 'a gen t
val klist : 'a t ‑> 'a klist t
\ No newline at end of file +CCHash (containers.CCHash)

Module CCHash

Hash combinators

Definitions

type hash = int

A hash value is a positive integer.

type 'a t = 'a -> hash

A hash function for values of type 'a.

val const : hash -> _ t

const h hashes any value into h. Use with caution!.

val const0 : _ t

Always return 0. Useful for ignoring elements. Example: Hash.(pair string const0) will map pairs ("a", 1) and ("a", 2) to the same hash, but not the same as ("b", 1).

since
1.5
val int : int t
val bool : bool t
val char : char t
val int32 : int32 t
val int64 : int64 t
val nativeint : nativeint t
val slice : string -> int -> int t

slice s i len state hashes the slice i, ... i+len-1 of s into state.

val string : string t
val list : 'a t -> 'a list t
val array : 'a t -> 'a array t
val opt : 'a t -> 'a option t
val pair : 'a t -> 'b t -> ('a * 'b) t
val triple : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t
val quad : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) t
val if_ : bool -> 'a t -> 'a t -> 'a t

Decide which hash function to use depending on the boolean.

val poly : 'a t

The regular polymorphic hash function. poly x is Hashtbl.hash x.

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

Commutative version of list. Lists that are equal up to permutation will have the same hash.

since
1.0
val array_comm : 'a t -> 'a array t

Commutative version of array. Arrays that are equal up to permutation will have the same hash.

since
1.0

Base hash combinators

val combine : 'a t -> hash -> 'a -> hash
val combine2 : hash -> hash -> hash
val combine3 : hash -> hash -> hash -> hash
val combine4 : hash -> hash -> hash -> hash -> hash
val combine5 : hash -> hash -> hash -> hash -> hash -> hash
since
2.1
val combine6 : hash -> hash -> hash -> hash -> hash -> hash -> hash
since
2.1

Iterators

type 'a sequence = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
type 'a klist = unit -> [ `Nil | `Cons of 'a * 'a klist ]
val seq : 'a t -> 'a sequence t
val gen : 'a t -> 'a gen t
val klist : 'a t -> 'a klist t
\ No newline at end of file diff --git a/dev/containers/CCHashtbl/Poly/index.html b/dev/containers/CCHashtbl/Poly/index.html index a3321b61..b18ec5f1 100644 --- a/dev/containers/CCHashtbl/Poly/index.html +++ b/dev/containers/CCHashtbl/Poly/index.html @@ -1,21 +1,2 @@ -Poly (containers.CCHashtbl.Poly)

Module CCHashtbl.Poly

val get : ('a'b) Hashtbl.t ‑> 'a ‑> 'b option

Safe version of Hashtbl.find.

val get_or : ('a'b) 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) Hashtbl.t ‑> 'a sequence

Iterate on keys (similar order as Hashtbl.iter).

val values : ('a'b) Hashtbl.t ‑> 'b sequence

Iterate on values in the table.

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

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

  • Since: 0.8
val values_list : ('a'b) Hashtbl.t ‑> 'b list

values_list t is the list of values in t.

  • Since: 0.8
val map_list : ('a ‑> 'b ‑> 'c) ‑> ('a'b) Hashtbl.t ‑> 'c list

Map on a hashtable's items, collect into a list.

val incr : ?⁠by:int ‑> ('a, int) 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) Hashtbl.t ‑> 'a ‑> unit

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_seq : ('a'b) Hashtbl.t ‑> ('a * 'b) sequence

Iterate on bindings in the table.

val add_list : ('a'b list) 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_seq : ('a'b) Hashtbl.t ‑> ('a * 'b) sequence ‑> unit

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

  • Since: 0.16
val of_seq : ('a * 'b) sequence ‑> ('a'b) Hashtbl.t

From the given bindings, added in order.

val add_seq_count : ('a, int) Hashtbl.t ‑> 'a sequence ‑> 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.

  • Since: 0.16
val of_seq_count : 'a sequence ‑> ('a, int) Hashtbl.t

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

  • Since: 0.16
val to_list : ('a'b) Hashtbl.t ‑> ('a * 'b) list

List of bindings (order unspecified).

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

Build a table from the given list 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 update : ('a'b) 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) 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 : 'a printer ‑> 'b printer ‑> ('a'b) Hashtbl.t printer
\ No newline at end of file +Poly (containers.CCHashtbl.Poly)

Module CCHashtbl.Poly

val get : ('a'b) Hashtbl.t -> 'a -> 'b option

Safe version of Hashtbl.find.

val get_or : ('a'b) 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) Hashtbl.t -> 'a sequence

Iterate on keys (similar order as Hashtbl.iter).

val values : ('a'b) Hashtbl.t -> 'b sequence

Iterate on values in the table.

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

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

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

values_list t is the list of values in t.

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

Map on a hashtable's items, collect into a list.

val incr : ?⁠by:int -> ('a, int) 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) Hashtbl.t -> 'a -> unit

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_seq : ('a'b) Hashtbl.t -> ('a * 'b) sequence

Iterate on bindings in the table.

val add_list : ('a'b list) 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_seq : ('a'b) Hashtbl.t -> ('a * 'b) sequence -> unit

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

since
0.16
val of_seq : ('a * 'b) sequence -> ('a'b) Hashtbl.t

From the given bindings, added in order.

val add_seq_count : ('a, int) Hashtbl.t -> 'a sequence -> 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.

since
0.16
val of_seq_count : 'a sequence -> ('a, int) Hashtbl.t

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

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

List of bindings (order unspecified).

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

Build a table from the given list 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 update : ('a'b) 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) 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 : 'a printer -> 'b printer -> ('a'b) Hashtbl.t printer

Printer for table. Renamed from print since 2.0.

since
0.13
\ No newline at end of file diff --git a/dev/containers/CCHashtbl/index.html b/dev/containers/CCHashtbl/index.html index 8ebc49c4..ec2c9576 100644 --- a/dev/containers/CCHashtbl/index.html +++ b/dev/containers/CCHashtbl/index.html @@ -1,21 +1,2 @@ -CCHashtbl (containers.CCHashtbl)

Module CCHashtbl

Extension to the standard Hashtbl

type 'a sequence = ('a ‑> unit) ‑> unit
type 'a eq = 'a ‑> 'a ‑> bool
type 'a hash = 'a ‑> int
type 'a printer = Format.formatter ‑> 'a ‑> unit

Polymorphic tables

This sub-module contains the extension of the standard polymorphic Hashtbl.

module Poly : sig ... end
include module type of Poly
val get : ('a'b) Hashtbl.t ‑> 'a ‑> 'b option

Safe version of Hashtbl.find.

val get_or : ('a'b) 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) Hashtbl.t ‑> 'a sequence

Iterate on keys (similar order as Hashtbl.iter).

val values : ('a'b) Hashtbl.t ‑> 'b sequence

Iterate on values in the table.

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

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

  • Since: 0.8
val values_list : ('a'b) Hashtbl.t ‑> 'b list

values_list t is the list of values in t.

  • Since: 0.8
val map_list : ('a ‑> 'b ‑> 'c) ‑> ('a'b) Hashtbl.t ‑> 'c list

Map on a hashtable's items, collect into a list.

val incr : ?⁠by:int ‑> ('a, int) 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) Hashtbl.t ‑> 'a ‑> unit

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_seq : ('a'b) Hashtbl.t ‑> ('a * 'b) sequence

Iterate on bindings in the table.

val add_list : ('a'b list) 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_seq : ('a'b) Hashtbl.t ‑> ('a * 'b) sequence ‑> unit

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

  • Since: 0.16
val of_seq : ('a * 'b) sequence ‑> ('a'b) Hashtbl.t

From the given bindings, added in order.

val add_seq_count : ('a, int) Hashtbl.t ‑> 'a sequence ‑> 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.

  • Since: 0.16
val of_seq_count : 'a sequence ‑> ('a, int) Hashtbl.t

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

  • Since: 0.16
val to_list : ('a'b) Hashtbl.t ‑> ('a * 'b) list

List of bindings (order unspecified).

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

Build a table from the given list 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 update : ('a'b) 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) 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 : 'a printer ‑> 'b printer ‑> ('a'b) Hashtbl.t printer

Functor

module type S : sig ... end
module Make : functor (X : Hashtbl.HashedType) -> S with type Make.key = X.t and type 'a Make.t = 'a Hashtbl.Make(X).t
\ No newline at end of file +CCHashtbl (containers.CCHashtbl)

Module CCHashtbl

Extension to the standard Hashtbl

since
0.4
type 'a sequence = ('a -> unit) -> unit
type 'a eq = 'a -> 'a -> bool
type 'a hash = 'a -> int
type 'a printer = Format.formatter -> 'a -> unit

Polymorphic tables

module Poly : sig ... end
include module type of Poly
val get : ('a'b) Hashtbl.t -> 'a -> 'b option

Safe version of Hashtbl.find.

val get_or : ('a'b) 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) Hashtbl.t -> 'a sequence

Iterate on keys (similar order as Hashtbl.iter).

val values : ('a'b) Hashtbl.t -> 'b sequence

Iterate on values in the table.

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

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

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

values_list t is the list of values in t.

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

Map on a hashtable's items, collect into a list.

val incr : ?⁠by:int -> ('a, int) 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) Hashtbl.t -> 'a -> unit

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_seq : ('a'b) Hashtbl.t -> ('a * 'b) sequence

Iterate on bindings in the table.

val add_list : ('a'b list) 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_seq : ('a'b) Hashtbl.t -> ('a * 'b) sequence -> unit

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

since
0.16
val of_seq : ('a * 'b) sequence -> ('a'b) Hashtbl.t

From the given bindings, added in order.

val add_seq_count : ('a, int) Hashtbl.t -> 'a sequence -> 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.

since
0.16
val of_seq_count : 'a sequence -> ('a, int) Hashtbl.t

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

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

List of bindings (order unspecified).

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

Build a table from the given list 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 update : ('a'b) 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) 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 : 'a printer -> 'b printer -> ('a'b) Hashtbl.t printer

Printer for table. Renamed from print since 2.0.

since
0.13

Functor

module type S = sig ... end
module Make : functor (X : Hashtbl.HashedType) -> S with type Make.key = X.t and type 'a Make.t = 'a Hashtbl.Make(X).t
\ No newline at end of file diff --git a/dev/containers/CCHashtbl/module-type-S/index.html b/dev/containers/CCHashtbl/module-type-S/index.html index 54d7a5df..f078d6dd 100644 --- a/dev/containers/CCHashtbl/module-type-S/index.html +++ b/dev/containers/CCHashtbl/module-type-S/index.html @@ -1,21 +1,2 @@ -S (containers.CCHashtbl.S)

Module type CCHashtbl.S

include Hashtbl.S
type key
type 'a 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 ‑> Hashtbl.statistics
val get : 'a t ‑> key ‑> 'a option

Safe version of Hashtbl.find.

val get_or : 'a t ‑> key ‑> default:'a ‑> 'a

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 add_list : 'a list t ‑> key ‑> 'a ‑> 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 incr : ?⁠by:int ‑> int t ‑> key ‑> 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 ‑> int t ‑> key ‑> unit

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 keys : 'a t ‑> key sequence

Iterate on keys (similar order as Hashtbl.iter).

val values : 'a t ‑> 'a sequence

Iterate on values in the table.

val keys_list : _ t ‑> key list

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

  • Since: 0.8
val values_list : 'a t ‑> 'a list

values_list t is the list of values in t.

  • Since: 0.8
val map_list : (key ‑> 'a ‑> 'b) ‑> 'a t ‑> 'b list

Map on a hashtable's items, collect into a list.

val to_seq : 'a t ‑> (key * 'a) sequence

Iterate on values in the table.

val of_seq : (key * 'a) sequence ‑> 'a t

From the given bindings, added in order.

val add_seq : 'a t ‑> (key * 'a) sequence ‑> unit

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

  • Since: 0.16
val add_seq_count : int t ‑> key sequence ‑> 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.

  • Since: 0.16
val of_seq_count : key sequence ‑> int t

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

  • Since: 0.16
val to_list : 'a t ‑> (key * 'a) list

List of bindings (order unspecified).

val of_list : (key * 'a) list ‑> 'a t

Build a table from the given list 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 update : 'a t ‑> f:(key ‑> 'a option ‑> 'a option) ‑> k:key ‑> 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 t ‑> f:(key ‑> 'a) ‑> k:key ‑> 'a

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 : key printer ‑> 'a printer ‑> 'a t printer
\ No newline at end of file +S (containers.CCHashtbl.S)

Module type CCHashtbl.S

include Hashtbl.S
type key
type 'a 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 -> Hashtbl.statistics
val get : 'a t -> key -> 'a option

Safe version of Hashtbl.find.

val get_or : 'a t -> key -> default:'a -> 'a

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 add_list : 'a list t -> key -> 'a -> 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 incr : ?⁠by:int -> int t -> key -> 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 -> int t -> key -> unit

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 keys : 'a t -> key sequence

Iterate on keys (similar order as Hashtbl.iter).

val values : 'a t -> 'a sequence

Iterate on values in the table.

val keys_list : _ t -> key list

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

since
0.8
val values_list : 'a t -> 'a list

values_list t is the list of values in t.

since
0.8
val map_list : (key -> 'a -> 'b) -> 'a t -> 'b list

Map on a hashtable's items, collect into a list.

val to_seq : 'a t -> (key * 'a) sequence

Iterate on values in the table.

val of_seq : (key * 'a) sequence -> 'a t

From the given bindings, added in order.

val add_seq : 'a t -> (key * 'a) sequence -> unit

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

since
0.16
val add_seq_count : int t -> key sequence -> 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.

since
0.16
val of_seq_count : key sequence -> int t

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

since
0.16
val to_list : 'a t -> (key * 'a) list

List of bindings (order unspecified).

val of_list : (key * 'a) list -> 'a t

Build a table from the given list 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 update : 'a t -> f:(key -> 'a option -> 'a option) -> k:key -> 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 t -> f:(key -> 'a) -> k:key -> 'a

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 : key printer -> 'a printer -> 'a t printer

Printer for tables. Renamed from print since 2.0.

since
0.13
\ No newline at end of file diff --git a/dev/containers/CCHeap/Make/argument-1-E/index.html b/dev/containers/CCHeap/Make/argument-1-E/index.html index 6173385d..b0e09a7b 100644 --- a/dev/containers/CCHeap/Make/argument-1-E/index.html +++ b/dev/containers/CCHeap/Make/argument-1-E/index.html @@ -1,2 +1,2 @@ -1-E (containers.CCHeap.Make.1-E)

Parameter CCHeap.Make.1-E

type t
val leq : t ‑> t ‑> bool

leq x y shall return true iff x is lower or equal to y.

\ No newline at end of file +1-E (containers.CCHeap.Make.1-E)

Parameter Make.1-E

type t
val leq : t -> t -> bool

leq x y shall return true iff x is lower or equal to y.

\ No newline at end of file diff --git a/dev/containers/CCHeap/Make/index.html b/dev/containers/CCHeap/Make/index.html index 31a9e3c1..31a8e2ec 100644 --- a/dev/containers/CCHeap/Make/index.html +++ b/dev/containers/CCHeap/Make/index.html @@ -1,13 +1,2 @@ -Make (containers.CCHeap.Make)

Module CCHeap.Make

Parameters

Signature

type elt = E.t
type t
val empty : t

Empty heap.

val is_empty : t ‑> bool

Is the heap empty?

exception Empty
val merge : t ‑> t ‑> t

Merge two heaps.

val insert : elt ‑> t ‑> t

Insert a value in the heap.

val add : t ‑> elt ‑> t

Synonym to insert.

val filter : (elt ‑> bool) ‑> t ‑> t

Filter values, only retaining the ones that satisfy the predicate. -Linear time at least.

val find_min : t ‑> elt option

Find minimal element.

val find_min_exn : t ‑> elt

Like find_min but can fail.

  • Raises Empty: if the heap is empty.
val take : t ‑> (t * elt) option

Extract and return the minimum element, and the new heap (without -this element), or None if the heap is empty.

val take_exn : t ‑> t * elt

Like take, but can fail.

  • Raises Empty: if the heap is empty.
val delete_one : (elt ‑> elt ‑> bool) ‑> elt ‑> t ‑> t

Delete one occurrence of a value if it exist in the heap. -delete_one eq x h, use eq to find one x in h and delete it. -If h do not contain x then it return h.

  • Since: 2.0
val delete_all : (elt ‑> elt ‑> bool) ‑> elt ‑> t ‑> t

Delete all occurrences of a value in the heap. -delete_all eq x h, use eq to find all x in h and delete them. -If h do not contain x then it return h. -The difference with filter is that delete_all stops as soon as -it enters a subtree whose root is bigger than the element.

  • Since: 2.0
val iter : (elt ‑> unit) ‑> t ‑> unit

Iterate on elements.

val fold : ('a ‑> elt ‑> 'a) ‑> 'a ‑> t ‑> 'a

Fold on all values.

val size : t ‑> int

Number of elements (linear complexity).

Conversions

The interface of of_gen, of_seq, of_klist -has changed since 0.16 (the old signatures -are now add_seq, add_gen, add_klist).

val to_list : t ‑> elt list

Return the elements of the heap, in no particular order.

val to_list_sorted : t ‑> elt list

Return the elements in increasing order.

  • Since: 1.1
val add_list : t ‑> elt list ‑> t

Add the elements of the list to the heap. An element occurring several -times will be added that many times to the heap.

  • Since: 0.16
val of_list : elt list ‑> t

of_list l is add_list empty l. Complexity: O(n log n).

val add_seq : t ‑> elt sequence ‑> t
  • Since: 0.16
val of_seq : elt sequence ‑> t

Build a heap from a given sequence. Complexity: O(n log n).

val to_seq : t ‑> elt sequence

Return a sequence of the elements of the heap.

val to_seq_sorted : t ‑> elt sequence

Iterate on the elements, in increasing order.

  • Since: 1.1
val add_klist : t ‑> elt klist ‑> t
  • Since: 0.16
val of_klist : elt klist ‑> t

Build a heap from a given klist. Complexity: O(n log n).

val to_klist : t ‑> elt klist

Return a klist of the elements of the heap.

val add_gen : t ‑> elt gen ‑> t
  • Since: 0.16
val of_gen : elt gen ‑> t

Build a heap from a given gen. Complexity: O(n log n).

val to_gen : t ‑> elt gen

Return a gen of the elements of the heap.

val to_tree : t ‑> elt ktree

Return a ktree of the elements of the heap.

val pp : ?⁠sep:string ‑> elt printer ‑> t printer
\ No newline at end of file +Make (containers.CCHeap.Make)

Module CCHeap.Make

Parameters

Signature

type elt = E.t
type t
val empty : t

Empty heap.

val is_empty : t -> bool

Is the heap empty?

exception Empty
val merge : t -> t -> t

Merge two heaps.

val insert : elt -> t -> t

Insert a value in the heap.

val add : t -> elt -> t

Synonym to insert.

val filter : (elt -> bool) -> t -> t

Filter values, only retaining the ones that satisfy the predicate. Linear time at least.

val find_min : t -> elt option

Find minimal element.

val find_min_exn : t -> elt

Like find_min but can fail.

raises Empty

if the heap is empty.

val take : t -> (t * elt) option

Extract and return the minimum element, and the new heap (without this element), or None if the heap is empty.

val take_exn : t -> t * elt

Like take, but can fail.

raises Empty

if the heap is empty.

val delete_one : (elt -> elt -> bool) -> elt -> t -> t

Delete one occurrence of a value if it exist in the heap. delete_one eq x h, use eq to find one x in h and delete it. If h do not contain x then it return h.

since
2.0
val delete_all : (elt -> elt -> bool) -> elt -> t -> t

Delete all occurrences of a value in the heap. delete_all eq x h, use eq to find all x in h and delete them. If h do not contain x then it return h. The difference with filter is that delete_all stops as soon as it enters a subtree whose root is bigger than the element.

since
2.0
val iter : (elt -> unit) -> t -> unit

Iterate on elements.

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

Fold on all values.

val size : t -> int

Number of elements (linear complexity).

Conversions

The interface of of_gen, of_seq, of_klist has changed since 0.16 (the old signatures are now add_seq, add_gen, add_klist).

val to_list : t -> elt list

Return the elements of the heap, in no particular order.

val to_list_sorted : t -> elt list

Return the elements in increasing order.

since
1.1
val add_list : t -> elt list -> t

Add the elements of the list to the heap. An element occurring several times will be added that many times to the heap.

since
0.16
val of_list : elt list -> t

of_list l is add_list empty l. Complexity: O(n log n).

val add_seq : t -> elt sequence -> t
since
0.16
val of_seq : elt sequence -> t

Build a heap from a given sequence. Complexity: O(n log n).

val to_seq : t -> elt sequence

Return a sequence of the elements of the heap.

val to_seq_sorted : t -> elt sequence

Iterate on the elements, in increasing order.

since
1.1
val add_klist : t -> elt klist -> t
since
0.16
val of_klist : elt klist -> t

Build a heap from a given klist. Complexity: O(n log n).

val to_klist : t -> elt klist

Return a klist of the elements of the heap.

val add_gen : t -> elt gen -> t
since
0.16
val of_gen : elt gen -> t

Build a heap from a given gen. Complexity: O(n log n).

val to_gen : t -> elt gen

Return a gen of the elements of the heap.

val to_tree : t -> elt ktree

Return a ktree of the elements of the heap.

val pp : ?⁠sep:string -> elt printer -> t printer

Printer. Renamed from print since 2.0

since
0.16
\ No newline at end of file diff --git a/dev/containers/CCHeap/index.html b/dev/containers/CCHeap/index.html index 1d0591ff..5df93cb0 100644 --- a/dev/containers/CCHeap/index.html +++ b/dev/containers/CCHeap/index.html @@ -1,2 +1,2 @@ -CCHeap (containers.CCHeap)

Module CCHeap

Leftist Heaps

following Okasaki

type 'a sequence = ('a ‑> unit) ‑> unit
type 'a gen = unit ‑> 'a option
type 'a klist = unit ‑> [ `Nil | `Cons of 'a * 'a klist ]
type 'a ktree = unit ‑> [ `Nil | `Node of 'a * 'a ktree list ]
type 'a printer = Format.formatter ‑> 'a ‑> unit
module type PARTIAL_ORD : sig ... end
module type S : sig ... end
module Make : functor (E : PARTIAL_ORD) -> S with type elt = E.t
\ No newline at end of file +CCHeap (containers.CCHeap)

Module CCHeap

Leftist Heaps

Implementation following Okasaki's book.

type 'a sequence = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
type 'a klist = unit -> [ `Nil | `Cons of 'a * 'a klist ]
type 'a ktree = unit -> [ `Nil | `Node of 'a * 'a ktree list ]
type 'a printer = Format.formatter -> 'a -> unit
module type PARTIAL_ORD = sig ... end
module type TOTAL_ORD = sig ... end
module type S = sig ... end
module Make : functor (E : PARTIAL_ORD) -> S with type elt = E.t
module Make_from_compare : functor (E : TOTAL_ORD) -> S with type elt = E.t

A convenient version of Make that take a TOTAL_ORD instead of a partially ordered module. It allow to directly pass modules that implement compare without implementing leq explicitly

\ No newline at end of file diff --git a/dev/containers/CCHeap/module-type-PARTIAL_ORD/index.html b/dev/containers/CCHeap/module-type-PARTIAL_ORD/index.html index b5e693f3..681f2275 100644 --- a/dev/containers/CCHeap/module-type-PARTIAL_ORD/index.html +++ b/dev/containers/CCHeap/module-type-PARTIAL_ORD/index.html @@ -1,2 +1,2 @@ -PARTIAL_ORD (containers.CCHeap.PARTIAL_ORD)

Module type CCHeap.PARTIAL_ORD

type t
val leq : t ‑> t ‑> bool

leq x y shall return true iff x is lower or equal to y.

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

Module type CCHeap.PARTIAL_ORD

type t
val leq : t -> t -> bool

leq x y shall return true iff x is lower or equal to y.

\ No newline at end of file diff --git a/dev/containers/CCHeap/module-type-S/index.html b/dev/containers/CCHeap/module-type-S/index.html index 43577598..274c0867 100644 --- a/dev/containers/CCHeap/module-type-S/index.html +++ b/dev/containers/CCHeap/module-type-S/index.html @@ -1,13 +1,2 @@ -S (containers.CCHeap.S)

Module type CCHeap.S

type elt
type t
val empty : t

Empty heap.

val is_empty : t ‑> bool

Is the heap empty?

exception Empty
val merge : t ‑> t ‑> t

Merge two heaps.

val insert : elt ‑> t ‑> t

Insert a value in the heap.

val add : t ‑> elt ‑> t

Synonym to insert.

val filter : (elt ‑> bool) ‑> t ‑> t

Filter values, only retaining the ones that satisfy the predicate. -Linear time at least.

val find_min : t ‑> elt option

Find minimal element.

val find_min_exn : t ‑> elt

Like find_min but can fail.

  • Raises Empty: if the heap is empty.
val take : t ‑> (t * elt) option

Extract and return the minimum element, and the new heap (without -this element), or None if the heap is empty.

val take_exn : t ‑> t * elt

Like take, but can fail.

  • Raises Empty: if the heap is empty.
val delete_one : (elt ‑> elt ‑> bool) ‑> elt ‑> t ‑> t

Delete one occurrence of a value if it exist in the heap. -delete_one eq x h, use eq to find one x in h and delete it. -If h do not contain x then it return h.

  • Since: 2.0
val delete_all : (elt ‑> elt ‑> bool) ‑> elt ‑> t ‑> t

Delete all occurrences of a value in the heap. -delete_all eq x h, use eq to find all x in h and delete them. -If h do not contain x then it return h. -The difference with filter is that delete_all stops as soon as -it enters a subtree whose root is bigger than the element.

  • Since: 2.0
val iter : (elt ‑> unit) ‑> t ‑> unit

Iterate on elements.

val fold : ('a ‑> elt ‑> 'a) ‑> 'a ‑> t ‑> 'a

Fold on all values.

val size : t ‑> int

Number of elements (linear complexity).

Conversions

The interface of of_gen, of_seq, of_klist -has changed since 0.16 (the old signatures -are now add_seq, add_gen, add_klist).

val to_list : t ‑> elt list

Return the elements of the heap, in no particular order.

val to_list_sorted : t ‑> elt list

Return the elements in increasing order.

  • Since: 1.1
val add_list : t ‑> elt list ‑> t

Add the elements of the list to the heap. An element occurring several -times will be added that many times to the heap.

  • Since: 0.16
val of_list : elt list ‑> t

of_list l is add_list empty l. Complexity: O(n log n).

val add_seq : t ‑> elt sequence ‑> t
  • Since: 0.16
val of_seq : elt sequence ‑> t

Build a heap from a given sequence. Complexity: O(n log n).

val to_seq : t ‑> elt sequence

Return a sequence of the elements of the heap.

val to_seq_sorted : t ‑> elt sequence

Iterate on the elements, in increasing order.

  • Since: 1.1
val add_klist : t ‑> elt klist ‑> t
  • Since: 0.16
val of_klist : elt klist ‑> t

Build a heap from a given klist. Complexity: O(n log n).

val to_klist : t ‑> elt klist

Return a klist of the elements of the heap.

val add_gen : t ‑> elt gen ‑> t
  • Since: 0.16
val of_gen : elt gen ‑> t

Build a heap from a given gen. Complexity: O(n log n).

val to_gen : t ‑> elt gen

Return a gen of the elements of the heap.

val to_tree : t ‑> elt ktree

Return a ktree of the elements of the heap.

val pp : ?⁠sep:string ‑> elt printer ‑> t printer
\ No newline at end of file +S (containers.CCHeap.S)

Module type CCHeap.S

type elt
type t
val empty : t

Empty heap.

val is_empty : t -> bool

Is the heap empty?

exception Empty
val merge : t -> t -> t

Merge two heaps.

val insert : elt -> t -> t

Insert a value in the heap.

val add : t -> elt -> t

Synonym to insert.

val filter : (elt -> bool) -> t -> t

Filter values, only retaining the ones that satisfy the predicate. Linear time at least.

val find_min : t -> elt option

Find minimal element.

val find_min_exn : t -> elt

Like find_min but can fail.

raises Empty

if the heap is empty.

val take : t -> (t * elt) option

Extract and return the minimum element, and the new heap (without this element), or None if the heap is empty.

val take_exn : t -> t * elt

Like take, but can fail.

raises Empty

if the heap is empty.

val delete_one : (elt -> elt -> bool) -> elt -> t -> t

Delete one occurrence of a value if it exist in the heap. delete_one eq x h, use eq to find one x in h and delete it. If h do not contain x then it return h.

since
2.0
val delete_all : (elt -> elt -> bool) -> elt -> t -> t

Delete all occurrences of a value in the heap. delete_all eq x h, use eq to find all x in h and delete them. If h do not contain x then it return h. The difference with filter is that delete_all stops as soon as it enters a subtree whose root is bigger than the element.

since
2.0
val iter : (elt -> unit) -> t -> unit

Iterate on elements.

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

Fold on all values.

val size : t -> int

Number of elements (linear complexity).

Conversions

The interface of of_gen, of_seq, of_klist has changed since 0.16 (the old signatures are now add_seq, add_gen, add_klist).

val to_list : t -> elt list

Return the elements of the heap, in no particular order.

val to_list_sorted : t -> elt list

Return the elements in increasing order.

since
1.1
val add_list : t -> elt list -> t

Add the elements of the list to the heap. An element occurring several times will be added that many times to the heap.

since
0.16
val of_list : elt list -> t

of_list l is add_list empty l. Complexity: O(n log n).

val add_seq : t -> elt sequence -> t
since
0.16
val of_seq : elt sequence -> t

Build a heap from a given sequence. Complexity: O(n log n).

val to_seq : t -> elt sequence

Return a sequence of the elements of the heap.

val to_seq_sorted : t -> elt sequence

Iterate on the elements, in increasing order.

since
1.1
val add_klist : t -> elt klist -> t
since
0.16
val of_klist : elt klist -> t

Build a heap from a given klist. Complexity: O(n log n).

val to_klist : t -> elt klist

Return a klist of the elements of the heap.

val add_gen : t -> elt gen -> t
since
0.16
val of_gen : elt gen -> t

Build a heap from a given gen. Complexity: O(n log n).

val to_gen : t -> elt gen

Return a gen of the elements of the heap.

val to_tree : t -> elt ktree

Return a ktree of the elements of the heap.

val pp : ?⁠sep:string -> elt printer -> t printer

Printer. Renamed from print since 2.0

since
0.16
\ No newline at end of file diff --git a/dev/containers/CCIO/File/index.html b/dev/containers/CCIO/File/index.html index 510e259d..f6875fa7 100644 --- a/dev/containers/CCIO/File/index.html +++ b/dev/containers/CCIO/File/index.html @@ -1,14 +1,2 @@ -File (containers.CCIO.File)

Module CCIO.File

type t = string

A file should be represented by its absolute path, but currently -this is not enforced.

val to_string : t ‑> string
val make : string ‑> t

Build a file representation from a path (absolute or relative).

val exists : t ‑> bool
val is_directory : t ‑> bool
val remove_exn : t ‑> unit

remove_exn path tries to remove the file at path from the -file system.

  • Raises Sys_error: if there is no file at path or access rights are wrong.
  • Since: 0.8
val remove : t ‑> unit or_error

Like remove_exn but with an error monad.

  • Since: 0.8
val remove_noerr : t ‑> unit

Like remove_exn but do not raise any exception on failure.

  • Since: 0.8
val read_dir : ?⁠recurse:bool ‑> t ‑> t gen

read_dir d returns a sequence of files and directory contained -in the directory d (or an empty stream if d is not a directory).

  • Raises Sys_error: in case of error (e.g. permission denied).
  • Parameter recurse: if true (default false), sub-directories are also -explored.
val read_exn : t ‑> string

Read the content of the given file, or raises some exception.

  • Raises Sys_error: in case of error.
  • Since: 0.16
val read : t ‑> string or_error

Read the content of the given file.

  • Since: 0.16
val append_exn : t ‑> string ‑> unit

Append the given string into the given file, possibly raising.

  • Raises Sys_error: in case of error.
  • Since: 0.16
val append : t ‑> string ‑> unit or_error

Append the given string into the given file.

  • Since: 0.16
val write_exn : t ‑> string ‑> unit

Write the given string into the given file, possibly raising.

  • Raises Sys_error: in case of error.
  • Since: 0.16
val write : t ‑> string ‑> unit or_error

Write the given string into the given file.

  • Since: 0.16
type walk_item = [ `File | `Dir ] * t
val walk : t ‑> walk_item gen

Like read_dir (with recurse=true), this function walks -a directory recursively and yields either files or directories. -Is a file anything that doesn't satisfy is_directory (including -symlinks, etc.)

  • Raises Sys_error: in case of error (e.g. permission denied) during iteration.
val walk_l : t ‑> walk_item list

Like walk but returns a list (therefore it's eager and might -take some time on large directories).

  • Since: 1.1
val show_walk_item : walk_item ‑> string
val with_temp : ?⁠temp_dir:string ‑> prefix:string ‑> suffix:string ‑> (string ‑> 'a) ‑> 'a

with_temp ~prefix ~suffix f will call f with the name of a new -temporary file (located in temp_dir). -After f returns, the file is deleted. Best to be used in -combination with with_out. -See Filename.temp_file.

  • Since: 0.17
\ No newline at end of file +File (containers.CCIO.File)

Module CCIO.File

type t = string

A file should be represented by its absolute path, but currently this is not enforced.

val to_string : t -> string
val make : string -> t

Build a file representation from a path (absolute or relative).

val exists : t -> bool
val is_directory : t -> bool
val remove_exn : t -> unit

remove_exn path tries to remove the file at path from the file system.

raises Sys_error

if there is no file at path or access rights are wrong.

since
0.8
val remove : t -> unit or_error

Like remove_exn but with an error monad.

since
0.8
val remove_noerr : t -> unit

Like remove_exn but do not raise any exception on failure.

since
0.8
val read_dir : ?⁠recurse:bool -> t -> t gen

read_dir d returns a sequence of files and directory contained in the directory d (or an empty stream if d is not a directory).

raises Sys_error

in case of error (e.g. permission denied).

parameter recurse

if true (default false), sub-directories are also explored.

val read_exn : t -> string

Read the content of the given file, or raises some exception.

raises Sys_error

in case of error.

since
0.16
val read : t -> string or_error

Read the content of the given file.

since
0.16
val append_exn : t -> string -> unit

Append the given string into the given file, possibly raising.

raises Sys_error

in case of error.

since
0.16
val append : t -> string -> unit or_error

Append the given string into the given file.

since
0.16
val write_exn : t -> string -> unit

Write the given string into the given file, possibly raising.

raises Sys_error

in case of error.

since
0.16
val write : t -> string -> unit or_error

Write the given string into the given file.

since
0.16
type walk_item = [ `File | `Dir ] * t
val walk : t -> walk_item gen

Like read_dir (with recurse=true), this function walks a directory recursively and yields either files or directories. Is a file anything that doesn't satisfy is_directory (including symlinks, etc.)

raises Sys_error

in case of error (e.g. permission denied) during iteration.

val walk_l : t -> walk_item list

Like walk but returns a list (therefore it's eager and might take some time on large directories).

since
1.1
val show_walk_item : walk_item -> string
val with_temp : ?⁠temp_dir:string -> prefix:string -> suffix:string -> (string -> 'a) -> 'a

with_temp ~prefix ~suffix f will call f with the name of a new temporary file (located in temp_dir). After f returns, the file is deleted. Best to be used in combination with with_out. See Filename.temp_file.

since
0.17
\ No newline at end of file diff --git a/dev/containers/CCIO/index.html b/dev/containers/CCIO/index.html index d71a58b9..618d2b00 100644 --- a/dev/containers/CCIO/index.html +++ b/dev/containers/CCIO/index.html @@ -1,23 +1,13 @@ -CCIO (containers.CCIO)

Module CCIO

IO Utils

Simple utilities to deal with basic Input/Output tasks in a resource-safe -way. For advanced IO tasks, the user is advised to use something -like Lwt or Async, that are far more comprehensive.

Examples:

      # let l = CCIO.(with_in "/tmp/some_file" read_lines);;
      # CCIO.(
-          with_in "/tmp/input"
-            (fun ic ->
-               let chunks = read_chunks ic in
-               with_out ~flags:[Open_binary] ~mode:0o644 "/tmp/output"
-                 (fun oc ->
-                    write_gen oc chunks
-                 )
-            )
-        ) ;;
type 'a or_error = ('a, string) Result.result
type 'a gen = unit ‑> 'a option

See Gen in the gen library.

Input

val with_in : ?⁠mode:int ‑> ?⁠flags:Pervasives.open_flag list ‑> string ‑> (Pervasives.in_channel ‑> 'a) ‑> 'a

Open an input file with the given optional flag list, calls the function -on the input channel. When the function raises or returns, the -channel is closed.

  • Raises Sys_error: in case of error (same as open_in and close_in).
  • Parameter flags: opening flags (default [Open_text]). Open_rdonly is used in any cases.
val read_chunks : ?⁠size:int ‑> Pervasives.in_channel ‑> string gen

Read the channel's content into chunks of size size.

val read_line : Pervasives.in_channel ‑> string option

Read a line from the channel. Returns None if the input is terminated. -The "\n" is removed from the line.

val read_lines : Pervasives.in_channel ‑> string gen

Read all lines. The generator should be traversed only once.

val read_lines_l : Pervasives.in_channel ‑> string list

Read all lines into a list.

val read_all : ?⁠size:int ‑> Pervasives.in_channel ‑> string

Read the whole channel into a buffer, then converted into a string.

  • Parameter size: the internal buffer size.
  • Since: 0.7
val read_all_bytes : ?⁠size:int ‑> Pervasives.in_channel ‑> Bytes.t

Read the whole channel into a mutable byte array.

  • Parameter size: the internal buffer size.
  • Since: 0.12

Output

val with_out : ?⁠mode:int ‑> ?⁠flags:Pervasives.open_flag list ‑> string ‑> (Pervasives.out_channel ‑> 'a) ‑> 'a

Like with_in but for an output channel.

  • Parameter flags: opening flags (default [Open_creat; Open_trunc; Open_text]).
  • Raises Sys_error: in case of error (same as open_out and close_out). -Open_wronly is used in any cases.
val with_out_a : ?⁠mode:int ‑> ?⁠flags:Pervasives.open_flag list ‑> string ‑> (Pervasives.out_channel ‑> 'a) ‑> 'a

Like with_out but with the [Open_append; Open_creat; Open_wronly] -flags activated, to append to the file.

  • Raises Sys_error: in case of error (same as open_out and close_out).
val write_line : Pervasives.out_channel ‑> string ‑> unit

Write the given string on the channel, followed by "\n".

val write_gen : ?⁠sep:string ‑> Pervasives.out_channel ‑> string gen ‑> unit

Write the given strings on the output. If provided, add sep between -every two strings (but not at the end).

val write_lines : Pervasives.out_channel ‑> string gen ‑> unit

Write every string on the output, followed by "\n".

val write_lines_l : Pervasives.out_channel ‑> string list ‑> unit

Both

val with_in_out : ?⁠mode:int ‑> ?⁠flags:Pervasives.open_flag list ‑> string ‑> (Pervasives.in_channel ‑> Pervasives.out_channel ‑> 'a) ‑> 'a

Combines with_in and with_out.

  • Parameter flags: opening flags (default [Open_creat]).
  • Raises Sys_error: in case of error.
  • Since: 0.12

Misc for Generators

val tee : ('a ‑> unit) list ‑> 'a gen ‑> 'a gen

tee funs gen behaves like gen, but each element is given to -every function f in funs at the time the element is produced.

File and file names

How to list recursively files in a directory: -

      # let files = CCIO.File.read_dir ~recurse:true (CCIO.File.make "/tmp");;
-      # CCIO.write_lines stdout files;;

See File.walk if you also need to list directories:

      # let content = CCIO.File.walk (CCIO.File.make "/tmp");;
-      # Gen.map CCIO.File.show_walk_item content |> CCIO.write_lines stdout;;
module File : sig ... end
\ No newline at end of file +CCIO (containers.CCIO)

Module CCIO

IO Utils

Simple utilities to deal with basic Input/Output tasks in a resource-safe way. For advanced IO tasks, the user is advised to use something like Lwt or Async, that are far more comprehensive.

Examples:

  • obtain the list of lines of a file:
# let l = CCIO.(with_in "/tmp/some_file" read_lines_l);;
  • transfer one file into another:
# CCIO.(
+    with_in "/tmp/input"
+      (fun ic ->
+         let chunks = read_chunks ic in
+         with_out ~flags:[Open_binary] ~mode:0o644 "/tmp/output"
+           (fun oc ->
+              write_gen oc chunks
+           )
+      )
+  ) ;;
since
0.6
before 0.12

was in 'containers.io', now moved into 'containers'

type 'a or_error = ('a, string) Result.result
type 'a gen = unit -> 'a option

See Gen in the gen library.

Input

val with_in : ?⁠mode:int -> ?⁠flags:Pervasives.open_flag list -> string -> (Pervasives.in_channel -> 'a) -> 'a

Open an input file with the given optional flag list, calls the function on the input channel. When the function raises or returns, the channel is closed.

raises Sys_error

in case of error (same as open_in and close_in).

parameter flags

opening flags (default [Open_text]). Open_rdonly is used in any cases.

val read_chunks : ?⁠size:int -> Pervasives.in_channel -> string gen

Read the channel's content into chunks of size size.

val read_line : Pervasives.in_channel -> string option

Read a line from the channel. Returns None if the input is terminated. The "\n" is removed from the line.

val read_lines : Pervasives.in_channel -> string gen

Read all lines. The generator should be traversed only once.

val read_lines_l : Pervasives.in_channel -> string list

Read all lines into a list.

val read_all : ?⁠size:int -> Pervasives.in_channel -> string

Read the whole channel into a buffer, then converted into a string.

parameter size

the internal buffer size.

since
0.7
val read_all_bytes : ?⁠size:int -> Pervasives.in_channel -> Bytes.t

Read the whole channel into a mutable byte array.

parameter size

the internal buffer size.

since
0.12

Output

val with_out : ?⁠mode:int -> ?⁠flags:Pervasives.open_flag list -> string -> (Pervasives.out_channel -> 'a) -> 'a

Like with_in but for an output channel.

parameter flags

opening flags (default [Open_creat; Open_trunc; Open_text]).

raises Sys_error

in case of error (same as open_out and close_out). Open_wronly is used in any cases.

val with_out_a : ?⁠mode:int -> ?⁠flags:Pervasives.open_flag list -> string -> (Pervasives.out_channel -> 'a) -> 'a

Like with_out but with the [Open_append; Open_creat; Open_wronly] flags activated, to append to the file.

raises Sys_error

in case of error (same as open_out and close_out).

val write_line : Pervasives.out_channel -> string -> unit

Write the given string on the channel, followed by "\n".

val write_gen : ?⁠sep:string -> Pervasives.out_channel -> string gen -> unit

Write the given strings on the output. If provided, add sep between every two strings (but not at the end).

val write_lines : Pervasives.out_channel -> string gen -> unit

Write every string on the output, followed by "\n".

val write_lines_l : Pervasives.out_channel -> string list -> unit

Both

val with_in_out : ?⁠mode:int -> ?⁠flags:Pervasives.open_flag list -> string -> (Pervasives.in_channel -> Pervasives.out_channel -> 'a) -> 'a

Combines with_in and with_out.

parameter flags

opening flags (default [Open_creat]).

raises Sys_error

in case of error.

since
0.12

Misc for Generators

val tee : ('a -> unit) list -> 'a gen -> 'a gen

tee funs gen behaves like gen, but each element is given to every function f in funs at the time the element is produced.

File and file names

How to list recursively files in a directory:

# let files = CCIO.File.read_dir ~recurse:true (CCIO.File.make "/tmp");;
+# CCIO.write_lines stdout files;;

See File.walk if you also need to list directories:

# let content = CCIO.File.walk (CCIO.File.make "/tmp");;
+# Gen.map CCIO.File.show_walk_item content |> CCIO.write_lines stdout;;
module File : sig ... end
\ No newline at end of file diff --git a/dev/containers/CCInt/Infix/index.html b/dev/containers/CCInt/Infix/index.html index b359cedf..99f1246a 100644 --- a/dev/containers/CCInt/Infix/index.html +++ b/dev/containers/CCInt/Infix/index.html @@ -1,2 +1,2 @@ -Infix (containers.CCInt.Infix)

Module CCInt.Infix

val (=) : t ‑> t ‑> bool
  • Since: 0.17
val (<>) : t ‑> t ‑> bool
  • Since: 0.17
val (<) : t ‑> t ‑> bool
  • Since: 0.17
val (>) : t ‑> t ‑> bool
  • Since: 0.17
val (<=) : t ‑> t ‑> bool
  • Since: 0.17
val (>=) : t ‑> t ‑> bool
  • Since: 0.17
val (--) : t ‑> t ‑> t sequence

Alias to range.

  • Since: 1.2
val (--^) : t ‑> t ‑> t sequence

Alias to range'.

  • Since: 1.2
val (+) : t ‑> t ‑> t
  • Since: 2.1
val (-) : t ‑> t ‑> t
  • Since: 2.1
  • Since: 2.1
val (~-) : t ‑> t
  • Since: 2.1
  • Since: 2.1
val (*) : t ‑> t ‑> t
  • Since: 2.1
  • Since: 2.1
val (/) : t ‑> t ‑> t
  • Since: 2.1
  • Since: 2.1
val (mod) : t ‑> t ‑> t
  • Since: 2.1
  • Since: 2.1
val (land) : t ‑> t ‑> t
  • Since: 2.1
  • Since: 2.1
val (lor) : t ‑> t ‑> t
  • Since: 2.1
  • Since: 2.1
val (lxor) : t ‑> t ‑> t
  • Since: 2.1
  • Since: 2.1
val (lnot) : t ‑> t
  • Since: 2.1
  • Since: 2.1
val (lsl) : t ‑> int ‑> t
  • Since: 2.1
  • Since: 2.1
val (lsr) : t ‑> int ‑> t
  • Since: 2.1
  • Since: 2.1
val (asr) : t ‑> int ‑> t
  • Since: 2.1
  • Since: 2.1
\ No newline at end of file +Infix (containers.CCInt.Infix)

Module CCInt.Infix

val (=) : t -> t -> bool
since
0.17
val (<>) : t -> t -> bool
since
0.17
val (<) : t -> t -> bool
since
0.17
val (>) : t -> t -> bool
since
0.17
val (<=) : t -> t -> bool
since
0.17
val (>=) : t -> t -> bool
since
0.17
val (--) : t -> t -> t sequence

Alias to range.

since
1.2
val (--^) : t -> t -> t sequence

Alias to range'.

since
1.2
val (+) : t -> t -> t
since
2.1
val (-) : t -> t -> t
since
2.1
val (~-) : t -> t
since
2.1
val (*) : t -> t -> t
since
2.1
val (/) : t -> t -> t
since
2.1
val (**) : t -> t -> t
since
2.4
val (mod) : t -> t -> t
since
2.1
val (land) : t -> t -> t
since
2.1
val (lor) : t -> t -> t
since
2.1
val (lxor) : t -> t -> t
since
2.1
val (lnot) : t -> t
since
2.1
val (lsl) : t -> int -> t
since
2.1
val (lsr) : t -> int -> t
since
2.1
val (asr) : t -> int -> t
since
2.1
\ No newline at end of file diff --git a/dev/containers/CCInt/index.html b/dev/containers/CCInt/index.html index a36547a3..f312fa06 100644 --- a/dev/containers/CCInt/index.html +++ b/dev/containers/CCInt/index.html @@ -1,10 +1,2 @@ -CCInt (containers.CCInt)

Module CCInt

Basic Int functions

type t = int
val compare : t ‑> t ‑> int

The comparison function for integers with the same specification as Pervasives.compare.

val equal : t ‑> t ‑> bool

Equality function for integers.

val hash : t ‑> int
val sign : t ‑> int

sign i is one of -1, 0, 1.

val neg : t ‑> t

Unary negation. neg i = - i.

  • Since: 0.5
val pow : t ‑> t ‑> t

pow base exponent returns base raised to the power of exponent. -pow a b = a^b for positive integers a and b. -Raises Invalid_argument if a = b = 0 or b < 0.

  • Since: 0.11
val floor_div : t ‑> t ‑> t

floor_div a n is integer division rounding towards negative infinity. -It satisfies a = m * floor_div a n + rem a n.

  • Since: 1.2
val rem : t ‑> t ‑> t

rem a n is the remainder of dividing a by n, with the same -sign as n.

  • Since: 1.2
type 'a printer = Format.formatter ‑> 'a ‑> unit
type 'a random_gen = Random.State.t ‑> 'a
type 'a sequence = ('a ‑> unit) ‑> unit
val random : int ‑> t random_gen
val random_small : t random_gen
val random_range : int ‑> int ‑> t random_gen
val pp : t printer
val to_string : t ‑> string

Return the string representation of its argument, in signed decimal.

  • Since: 0.13
val of_string : string ‑> t option
  • Since: 0.13
val pp_binary : t printer

Print as "0b00101010".

  • Since: 0.20
val to_string_binary : t ‑> string
  • Since: 0.20
val min : t ‑> t ‑> t

The minimum of two integers.

  • Since: 0.17
val max : t ‑> t ‑> t

The maximum of two integers.

  • Since: 0.17
val range_by : step:t ‑> t ‑> t ‑> t sequence

range_by ~step i j iterates on integers from i to j included, -where the difference between successive elements is step. -Use a negative step for a decreasing list.

  • Raises Invalid_argument: if step=0.
  • Since: 1.2
val range : t ‑> t ‑> t sequence

range i j iterates on integers from i to j included . It works -both for decreasing and increasing ranges.

  • Since: 1.2
val range' : t ‑> t ‑> t sequence

Like range but the second bound is excluded. -For instance range' 0 5 = Sequence.of_list [0;1;2;3;4].

  • Since: 1.2

Infix Operators

module Infix : sig ... end
include module type of Infix
val (=) : t ‑> t ‑> bool
  • Since: 0.17
val (<>) : t ‑> t ‑> bool
  • Since: 0.17
val (<) : t ‑> t ‑> bool
  • Since: 0.17
val (>) : t ‑> t ‑> bool
  • Since: 0.17
val (<=) : t ‑> t ‑> bool
  • Since: 0.17
val (>=) : t ‑> t ‑> bool
  • Since: 0.17
val (--) : t ‑> t ‑> t sequence

Alias to range.

  • Since: 1.2
val (--^) : t ‑> t ‑> t sequence

Alias to range'.

  • Since: 1.2
val (+) : t ‑> t ‑> t
  • Since: 2.1
val (-) : t ‑> t ‑> t
  • Since: 2.1
  • Since: 2.1
val (~-) : t ‑> t
  • Since: 2.1
  • Since: 2.1
val (*) : t ‑> t ‑> t
  • Since: 2.1
  • Since: 2.1
val (/) : t ‑> t ‑> t
  • Since: 2.1
  • Since: 2.1
val (mod) : t ‑> t ‑> t
  • Since: 2.1
  • Since: 2.1
val (land) : t ‑> t ‑> t
  • Since: 2.1
  • Since: 2.1
val (lor) : t ‑> t ‑> t
  • Since: 2.1
  • Since: 2.1
val (lxor) : t ‑> t ‑> t
  • Since: 2.1
  • Since: 2.1
val (lnot) : t ‑> t
  • Since: 2.1
  • Since: 2.1
val (lsl) : t ‑> int ‑> t
  • Since: 2.1
  • Since: 2.1
val (lsr) : t ‑> int ‑> t
  • Since: 2.1
  • Since: 2.1
val (asr) : t ‑> int ‑> t
  • Since: 2.1
  • Since: 2.1
\ No newline at end of file +CCInt (containers.CCInt)

Module CCInt

Basic Int functions

type t = int
val compare : t -> t -> int

The comparison function for integers with the same specification as Pervasives.compare.

val equal : t -> t -> bool

Equality function for integers.

val hash : t -> int
val sign : t -> int

sign i is one of -1, 0, 1.

val neg : t -> t

Unary negation. neg i = - i.

since
0.5
val pow : t -> t -> t

pow base exponent returns base raised to the power of exponent. pow a b = a^b for positive integers a and b. Raises Invalid_argument if a = b = 0 or b < 0.

since
0.11
val floor_div : t -> t -> t

floor_div a n is integer division rounding towards negative infinity. It satisfies a = m * floor_div a n + rem a n.

since
1.2
val rem : t -> t -> t

rem a n is the remainder of dividing a by n, with the same sign as n.

since
1.2
type 'a printer = Format.formatter -> 'a -> unit
type 'a random_gen = Random.State.t -> 'a
type 'a sequence = ('a -> unit) -> unit
val random : int -> t random_gen
val random_small : t random_gen
val random_range : int -> int -> t random_gen
val pp : t printer
val to_string : t -> string

Return the string representation of its argument, in signed decimal.

since
0.13
val of_string : string -> t option
since
0.13
val pp_binary : t printer

Print as "0b00101010".

since
0.20
val to_string_binary : t -> string
since
0.20
val min : t -> t -> t

The minimum of two integers.

since
0.17
val max : t -> t -> t

The maximum of two integers.

since
0.17
val range_by : step:t -> t -> t -> t sequence

range_by ~step i j iterates on integers from i to j included, where the difference between successive elements is step. Use a negative step for a decreasing list.

raises Invalid_argument

if step=0.

since
1.2
val range : t -> t -> t sequence

range i j iterates on integers from i to j included . It works both for decreasing and increasing ranges.

since
1.2
val range' : t -> t -> t sequence

Like range but the second bound is excluded. For instance range' 0 5 = Iter.of_list [0;1;2;3;4].

since
1.2

Infix Operators

since
0.17
module Infix : sig ... end
include module type of Infix
val (=) : t -> t -> bool
since
0.17
val (<>) : t -> t -> bool
since
0.17
val (<) : t -> t -> bool
since
0.17
val (>) : t -> t -> bool
since
0.17
val (<=) : t -> t -> bool
since
0.17
val (>=) : t -> t -> bool
since
0.17
val (--) : t -> t -> t sequence

Alias to range.

since
1.2
val (--^) : t -> t -> t sequence

Alias to range'.

since
1.2
val (+) : t -> t -> t
since
2.1
val (-) : t -> t -> t
since
2.1
val (~-) : t -> t
since
2.1
val (*) : t -> t -> t
since
2.1
val (/) : t -> t -> t
since
2.1
val (**) : t -> t -> t
since
2.4
val (mod) : t -> t -> t
since
2.1
val (land) : t -> t -> t
since
2.1
val (lor) : t -> t -> t
since
2.1
val (lxor) : t -> t -> t
since
2.1
val (lnot) : t -> t
since
2.1
val (lsl) : t -> int -> t
since
2.1
val (lsr) : t -> int -> t
since
2.1
val (asr) : t -> int -> t
since
2.1
\ No newline at end of file diff --git a/dev/containers/CCInt32/Infix/index.html b/dev/containers/CCInt32/Infix/index.html index df1e809f..e74e00c4 100644 --- a/dev/containers/CCInt32/Infix/index.html +++ b/dev/containers/CCInt32/Infix/index.html @@ -1,2 +1,2 @@ -Infix (containers.CCInt32.Infix)

Module CCInt32.Infix

val (+) : t ‑> t ‑> t
val (-) : t ‑> t ‑> t
val (~-) : t ‑> t
val (*) : t ‑> t ‑> t
val (/) : t ‑> t ‑> t
val (mod) : t ‑> t ‑> t
val (land) : t ‑> t ‑> t
val (lor) : t ‑> t ‑> t
val (lxor) : t ‑> t ‑> t
val (lnot) : t ‑> t
val (lsl) : t ‑> int ‑> t
val (lsr) : t ‑> int ‑> t
val (asr) : t ‑> int ‑> t
val (=) : t ‑> t ‑> bool
val (<>) : t ‑> t ‑> bool
val (>) : t ‑> t ‑> bool
val (>=) : t ‑> t ‑> bool
val (<=) : t ‑> t ‑> bool
val (<) : t ‑> t ‑> bool
\ No newline at end of file +Infix (containers.CCInt32.Infix)

Module CCInt32.Infix

val (+) : t -> t -> t
val (-) : t -> t -> t
val (~-) : t -> t
val (*) : t -> t -> t
val (/) : t -> t -> t
val (mod) : t -> t -> t
val (land) : t -> t -> t
val (lor) : t -> t -> t
val (lxor) : t -> t -> t
val (lnot) : t -> t
val (lsl) : t -> int -> t
val (lsr) : t -> int -> t
val (asr) : t -> int -> t
val (=) : t -> t -> bool
val (<>) : t -> t -> bool
val (>) : t -> t -> bool
val (>=) : t -> t -> bool
val (<=) : t -> t -> bool
val (<) : t -> t -> bool
\ No newline at end of file diff --git a/dev/containers/CCInt32/index.html b/dev/containers/CCInt32/index.html index 3bf31545..4efb90e1 100644 --- a/dev/containers/CCInt32/index.html +++ b/dev/containers/CCInt32/index.html @@ -1,39 +1,2 @@ -CCInt32 (containers.CCInt32)

Module CCInt32

Int32

Helpers for 32-bit integers.

This module provides operations on the type int32 of signed 32-bit integers. -Unlike the built-in int type, the type int32 is guaranteed to be exactly -32-bit wide on all platforms. All arithmetic operations over int32 are taken -modulo 232.

Performance notice: values of type int32 occupy more memory space than values -of type int, and arithmetic operations on int32 are generally slower than -those on int. Use int32 only when the application requires exact 32-bit arithmetic.

include module type of sig ... end
val zero : int32
val one : int32
val minus_one : int32
external neg : int32 ‑> int32 = "%int32_neg"
external add : int32 ‑> int32 ‑> int32 = "%int32_add"
external sub : int32 ‑> int32 ‑> int32 = "%int32_sub"
external mul : int32 ‑> int32 ‑> int32 = "%int32_mul"
external div : int32 ‑> int32 ‑> int32 = "%int32_div"
external rem : int32 ‑> int32 ‑> int32 = "%int32_mod"
val succ : int32 ‑> int32
val pred : int32 ‑> int32
val abs : int32 ‑> int32
val max_int : int32
val min_int : int32
external logand : int32 ‑> int32 ‑> int32 = "%int32_and"
external logor : int32 ‑> int32 ‑> int32 = "%int32_or"
external logxor : int32 ‑> int32 ‑> int32 = "%int32_xor"
val lognot : int32 ‑> int32
external shift_left : int32 ‑> int ‑> int32 = "%int32_lsl"
external shift_right : int32 ‑> int ‑> int32 = "%int32_asr"
external shift_right_logical : int32 ‑> int ‑> int32 = "%int32_lsr"
external of_int : int ‑> int32 = "%int32_of_int"
external to_int : int32 ‑> int = "%int32_to_int"
external of_float : float ‑> int32 = "caml_int32_of_float" "caml_int32_of_float_unboxed"
external to_float : int32 ‑> float = "caml_int32_to_float" "caml_int32_to_float_unboxed"
external of_string : string ‑> int32 = "caml_int32_of_string"
val of_string_opt : string ‑> int32 option
val to_string : int32 ‑> string
external bits_of_float : float ‑> int32 = "caml_int32_bits_of_float" "caml_int32_bits_of_float_unboxed"
external float_of_bits : int32 ‑> float = "caml_int32_float_of_bits" "caml_int32_float_of_bits_unboxed"
type t = int32
val compare : t ‑> t ‑> int
val equal : t ‑> t ‑> bool
external format : string ‑> int32 ‑> string = "caml_int32_format"
val (+) : t ‑> t ‑> t

Addition.

val (-) : t ‑> t ‑> t

Subtraction.

val (~-) : t ‑> t

Unary negation.

val (*) : t ‑> t ‑> t

Multiplication.

val (/) : t ‑> t ‑> t

Integer division. Raise Division_by_zero if the second -argument is zero. This division rounds the real quotient of -its arguments towards zero, as specified for Pervasives.(/).

val (mod) : t ‑> t ‑> t

x mod y is the integer remainder. -If y <> zero, the result of x mod y satisfies the following property: -x = ((x / y) * y) + (x mod y). -If y = 0, x mod y raises Division_by_zero.

val (land) : t ‑> t ‑> t

Bitwise logical and.

val (lor) : t ‑> t ‑> t

Bitwise logical or.

val (lxor) : t ‑> t ‑> t

Bitwise logical exclusive or.

val (lnot) : t ‑> t

Bitwise logical negation.

val (lsl) : t ‑> int ‑> t

x lsl y shifts x to the left by y bits, filling in with zeroes. -The result is unspecified if y < 0 or y >= 32.

val (lsr) : t ‑> int ‑> t

x lsr y shifts x to the right by y bits. -This is a logical shift: zeroes are inserted in the vacated bits -regardless of the sign of x. -The result is unspecified if y < 0 or y >= 32.

val (asr) : t ‑> int ‑> t

x asr y shifts x to the right by y bits. -This is an arithmetic shift: the sign bit of x is replicated -and inserted in the vacated bits. -The result is unspecified if y < 0 or y >= 32.

module Infix : sig ... end
val equal : t ‑> t ‑> bool

The equal function for 32-bit integers. -Like Pervasives.(=) x y).

val hash : t ‑> int

Like Pervasives.abs (to_int x).

Conversion

val to_int : t ‑> int

Convert the given 32-bit integer (type int32) to an -integer (type int). On 32-bit platforms, the 32-bit integer -is taken modulo 231, i.e. the high-order bit is lost -during the conversion. On 64-bit platforms, the conversion is exact.

val of_int : int ‑> t

Alias to Int32.of_int.

val to_float : t ‑> float

Convert the given 32-bit integer to a floating-point number.

val of_float : float ‑> t

Alias to Int32.of_float. -Convert the given floating-point number to a 32-bit integer, -discarding the fractional part (truncate towards 0). -The result of the conversion is undefined if, after truncation, the number -is outside the range [CCInt32.min_int, CCInt32.max_int].

val to_string : t ‑> string

Return the string representation of its argument, in signed decimal.

val of_string_exn : string ‑> t

Alias to Int32.of_string. -Convert the given string to a 32-bit integer. -The string is read in decimal (by default, or if the string -begins with 0u) or in hexadecimal, octal or binary if the -string begins with 0x, 0o or 0b respectively.

The 0u prefix reads the input as an unsigned integer in the range -[0, 2*CCInt32.max_int+1]. If the input exceeds CCInt32.max_int -it is converted to the signed integer -CCInt32.min_int + input - CCInt32.max_int - 1.

The _ (underscore) character can appear anywhere in the string -and is ignored. -Raise Failure "Int32.of_string" if the given string is not -a valid representation of an integer, or if the integer represented -exceeds the range of integers representable in type int32.

val of_string : string ‑> t option

Safe version of of_string_exn. -Like of_string_exn, but return None instead of raising.

val of_string_opt : string ‑> t option

Alias to of_string.

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

Module CCInt32

Int32

Helpers for 32-bit integers.

This module provides operations on the type int32 of signed 32-bit integers. Unlike the built-in int type, the type int32 is guaranteed to be exactly 32-bit wide on all platforms. All arithmetic operations over int32 are taken modulo 232.

Performance notice: values of type int32 occupy more memory space than values of type int, and arithmetic operations on int32 are generally slower than those on int. Use int32 only when the application requires exact 32-bit arithmetic.

since
2.1
include module type of sig ... end
val zero : int32
val one : int32
val minus_one : int32
val neg : int32 -> int32
val add : int32 -> int32 -> int32
val sub : int32 -> int32 -> int32
val mul : int32 -> int32 -> int32
val div : int32 -> int32 -> int32
val rem : int32 -> int32 -> int32
val succ : int32 -> int32
val pred : int32 -> int32
val abs : int32 -> int32
val max_int : int32
val min_int : int32
val logand : int32 -> int32 -> int32
val logor : int32 -> int32 -> int32
val logxor : int32 -> int32 -> int32
val lognot : int32 -> int32
val shift_left : int32 -> int -> int32
val shift_right : int32 -> int -> int32
val shift_right_logical : int32 -> int -> int32
val of_int : int -> int32
val to_int : int32 -> int
val of_float : float -> int32
val to_float : int32 -> float
val of_string : string -> int32
val of_string_opt : string -> int32 option
val to_string : int32 -> string
val bits_of_float : float -> int32
val float_of_bits : int32 -> float
type t = int32
val compare : t -> t -> int
val equal : t -> t -> bool
val format : string -> int32 -> string
val (+) : t -> t -> t

Addition.

val (-) : t -> t -> t

Subtraction.

val (~-) : t -> t

Unary negation.

val (*) : t -> t -> t

Multiplication.

val (/) : t -> t -> t

Integer division. Raise Division_by_zero if the second argument is zero. This division rounds the real quotient of its arguments towards zero, as specified for Pervasives.(/).

val (mod) : t -> t -> t

x mod y is the integer remainder. If y <> zero, the result of x mod y satisfies the following property: x = ((x / y) * y) + (x mod y). If y = 0, x mod y raises Division_by_zero.

val (land) : t -> t -> t

Bitwise logical and.

val (lor) : t -> t -> t

Bitwise logical or.

val (lxor) : t -> t -> t

Bitwise logical exclusive or.

val (lnot) : t -> t

Bitwise logical negation.

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

x lsl y shifts x to the left by y bits, filling in with zeroes. The result is unspecified if y < 0 or y >= 32.

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

x lsr y shifts x to the right by y bits. This is a logical shift: zeroes are inserted in the vacated bits regardless of the sign of x. The result is unspecified if y < 0 or y >= 32.

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

x asr y shifts x to the right by y bits. This is an arithmetic shift: the sign bit of x is replicated and inserted in the vacated bits. The result is unspecified if y < 0 or y >= 32.

module Infix : sig ... end
include module type of Infix
val (+) : t -> t -> t
val (-) : t -> t -> t
val (~-) : t -> t
val (*) : t -> t -> t
val (/) : t -> t -> t
val (mod) : t -> t -> t
val (land) : t -> t -> t
val (lor) : t -> t -> t
val (lxor) : t -> t -> t
val (lnot) : t -> t
val (lsl) : t -> int -> t
val (lsr) : t -> int -> t
val (asr) : t -> int -> t
val (=) : t -> t -> bool
val (<>) : t -> t -> bool
val (>) : t -> t -> bool
val (>=) : t -> t -> bool
val (<=) : t -> t -> bool
val (<) : t -> t -> bool
val equal : t -> t -> bool

The equal function for 32-bit integers. Like Pervasives.(=) x y).

val hash : t -> int

Like Pervasives.abs (to_int x).

Conversion

val to_int : t -> int

Convert the given 32-bit integer (type int32) to an integer (type int). On 32-bit platforms, the 32-bit integer is taken modulo 231, i.e. the high-order bit is lost during the conversion. On 64-bit platforms, the conversion is exact.

val of_int : int -> t

Alias to Int32.of_int.

val to_float : t -> float

Convert the given 32-bit integer to a floating-point number.

val of_float : float -> t

Alias to Int32.of_float. Convert the given floating-point number to a 32-bit integer, discarding the fractional part (truncate towards 0). The result of the conversion is undefined if, after truncation, the number is outside the range [CCInt32.min_int, CCInt32.max_int].

val to_string : t -> string

Return the string representation of its argument, in signed decimal.

val of_string_exn : string -> t

Alias to Int32.of_string. Convert the given string to a 32-bit integer. The string is read in decimal (by default, or if the string begins with 0u) or in hexadecimal, octal or binary if the string begins with 0x, 0o or 0b respectively.

The 0u prefix reads the input as an unsigned integer in the range [0, 2*CCInt32.max_int+1]. If the input exceeds CCInt32.max_int it is converted to the signed integer CCInt32.min_int + input - CCInt32.max_int - 1.

The _ (underscore) character can appear anywhere in the string and is ignored. Raise Failure "Int32.of_string" if the given string is not a valid representation of an integer, or if the integer represented exceeds the range of integers representable in type int32.

val of_string : string -> t option

Safe version of of_string_exn. Like of_string_exn, but return None instead of raising.

val of_string_opt : string -> t option

Alias to of_string.

\ No newline at end of file diff --git a/dev/containers/CCInt64/Infix/index.html b/dev/containers/CCInt64/Infix/index.html index f50f1a50..340f3719 100644 --- a/dev/containers/CCInt64/Infix/index.html +++ b/dev/containers/CCInt64/Infix/index.html @@ -1,2 +1,2 @@ -Infix (containers.CCInt64.Infix)

Module CCInt64.Infix

Infix operators

val (+) : t ‑> t ‑> t
val (-) : t ‑> t ‑> t
val (~-) : t ‑> t
val (*) : t ‑> t ‑> t
val (/) : t ‑> t ‑> t
val (mod) : t ‑> t ‑> t
val (land) : t ‑> t ‑> t
val (lor) : t ‑> t ‑> t
val (lxor) : t ‑> t ‑> t
val (lnot) : t ‑> t
val (lsl) : t ‑> int ‑> t
val (lsr) : t ‑> int ‑> t
val (asr) : t ‑> int ‑> t
val (=) : t ‑> t ‑> bool
val (<>) : t ‑> t ‑> bool
val (>) : t ‑> t ‑> bool
val (>=) : t ‑> t ‑> bool
val (<=) : t ‑> t ‑> bool
val (<) : t ‑> t ‑> bool
\ No newline at end of file +Infix (containers.CCInt64.Infix)

Module CCInt64.Infix

Infix operators

since
2.1
val (+) : t -> t -> t
val (-) : t -> t -> t
val (~-) : t -> t
val (*) : t -> t -> t
val (/) : t -> t -> t
val (mod) : t -> t -> t
val (land) : t -> t -> t
val (lor) : t -> t -> t
val (lxor) : t -> t -> t
val (lnot) : t -> t
val (lsl) : t -> int -> t
val (lsr) : t -> int -> t
val (asr) : t -> int -> t
val (=) : t -> t -> bool
val (<>) : t -> t -> bool
val (>) : t -> t -> bool
val (>=) : t -> t -> bool
val (<=) : t -> t -> bool
val (<) : t -> t -> bool
\ No newline at end of file diff --git a/dev/containers/CCInt64/index.html b/dev/containers/CCInt64/index.html index ba969ec3..43106ad6 100644 --- a/dev/containers/CCInt64/index.html +++ b/dev/containers/CCInt64/index.html @@ -1,46 +1,2 @@ -CCInt64 (containers.CCInt64)

Module CCInt64

Int64

Helpers for 64-bit integers

include module type of sig ... end
val zero : int64
val one : int64
val minus_one : int64
external neg : int64 ‑> int64 = "%int64_neg"
external add : int64 ‑> int64 ‑> int64 = "%int64_add"
external sub : int64 ‑> int64 ‑> int64 = "%int64_sub"
external mul : int64 ‑> int64 ‑> int64 = "%int64_mul"
external div : int64 ‑> int64 ‑> int64 = "%int64_div"
external rem : int64 ‑> int64 ‑> int64 = "%int64_mod"
val succ : int64 ‑> int64
val pred : int64 ‑> int64
val abs : int64 ‑> int64
val max_int : int64
val min_int : int64
external logand : int64 ‑> int64 ‑> int64 = "%int64_and"
external logor : int64 ‑> int64 ‑> int64 = "%int64_or"
external logxor : int64 ‑> int64 ‑> int64 = "%int64_xor"
val lognot : int64 ‑> int64
external shift_left : int64 ‑> int ‑> int64 = "%int64_lsl"
external shift_right : int64 ‑> int ‑> int64 = "%int64_asr"
external shift_right_logical : int64 ‑> int ‑> int64 = "%int64_lsr"
external of_int : int ‑> int64 = "%int64_of_int"
external to_int : int64 ‑> int = "%int64_to_int"
external of_float : float ‑> int64 = "caml_int64_of_float" "caml_int64_of_float_unboxed"
external to_float : int64 ‑> float = "caml_int64_to_float" "caml_int64_to_float_unboxed"
external of_int32 : int32 ‑> int64 = "%int64_of_int32"
external to_int32 : int64 ‑> int32 = "%int64_to_int32"
external of_nativeint : nativeint ‑> int64 = "%int64_of_nativeint"
external to_nativeint : int64 ‑> nativeint = "%int64_to_nativeint"
external of_string : string ‑> int64 = "caml_int64_of_string"
val of_string_opt : string ‑> int64 option
val to_string : int64 ‑> string
external bits_of_float : float ‑> int64 = "caml_int64_bits_of_float" "caml_int64_bits_of_float_unboxed"
external float_of_bits : int64 ‑> float = "caml_int64_float_of_bits" "caml_int64_float_of_bits_unboxed"
type t = int64
val compare : t ‑> t ‑> int
val equal : t ‑> t ‑> bool
external format : string ‑> int64 ‑> string = "caml_int64_format"
val (+) : t ‑> t ‑> t

Addition.

val (-) : t ‑> t ‑> t

Subtraction.

val (~-) : t ‑> t

Unary negation.

val (*) : t ‑> t ‑> t

Multiplication.

val (/) : t ‑> t ‑> t

Integer division. Raise Division_by_zero if the second -argument is zero. This division rounds the real quotient of -its arguments towards zero, as specified for Pervasives.(/).

val (mod) : t ‑> t ‑> t

Integer remainder. -If y = 0, x mod y raises Division_by_zero.

val abs : t ‑> t

Return the absolute value of its argument.

val max_int : t

The greatest representable 64-bit integer, 263 - 1 = 9_223_372_036_854_775_807.

val min_int : t

The smallest representable 64-bit integer, -263 = -9_223_372_036_854_775_808.

val (land) : t ‑> t ‑> t

Bitwise logical and.

val (lor) : t ‑> t ‑> t

Bitwise logical or.

val (lxor) : t ‑> t ‑> t

Bitwise logical exclusive or.

val (lnot) : t ‑> t

Bitwise logical negation.

val (lsl) : t ‑> int ‑> t

x lsl y shifts x to the left by y bits, filling in with zeroes. -The result is unspecified if y < 0 or y >= 64.

val (lsr) : t ‑> int ‑> t

x lsr y shifts x to the right by y bits. -This is a logical shift: zeroes are inserted in the vacated bits -regardless of the sign of x. -The result is unspecified if y < 0 or y >= 64.

val (asr) : t ‑> int ‑> t

x asr y shifts x to the right by y bits. -This is an arithmetic shift: the sign bit of x is replicated -and inserted in the vacated bits. -The result is unspecified if y < 0 or y >= 64.

module Infix : sig ... end

Infix operators

val equal : t ‑> t ‑> bool

The equal function for 64-bit integers. -Like Pervasives.(=) x y).

val compare : t ‑> t ‑> int

The comparison function for 64-bit integers, with the same specification as -Pervasives.compare. Along with the type t, this function compare -allows the module CCInt64 to be passed as argument to the functors -Set.Make and Map.Make.

val hash : t ‑> int

Like Pervasives.abs (to_int x).

Conversion

val to_int : t ‑> int

Convert the given 64-bit integer (type int64) to an -integer (type int). On 64-bit platforms, the 64-bit integer -is taken modulo 263, i.e. the high-order bit is lost -during the conversion. On 32-bit platforms, the 64-bit integer -is taken modulo 231, i.e. the top 33 bits are lost -during the conversion.

val of_int : int ‑> t

Alias to Int64.of_int. -NOTE: used to return an option, but the function actually never fails.

val of_int_exn : int ‑> t

Alias to Int64.of_int.

  • Deprecated since 2.1
val to_int32 : t ‑> int32

Convert the given 64-bit integer (type int64) to a -32-bit integer (type int32). The 64-bit integer -is taken modulo 232, i.e. the top 32 bits are lost -during the conversion.

val of_int32 : int32 ‑> t

Alias to Int64.of_int32. -NOTE: use to return an option, but the function actually never fails.

val of_int32_exn : int32 ‑> t

Alias to Int64.of_int32.

  • Deprecated since 2.1
val to_nativeint : t ‑> nativeint

Convert the given 64-bit integer (type int64) to a -native integer. On 32-bit platforms, the 64-bit integer -is taken modulo 232. On 64-bit platforms, -the conversion is exact.

val of_nativeint : nativeint ‑> t

Alias to Int64.of_nativeint. -NOTE: use to return an option, but the function actually never fails.

val of_nativeint_exn : nativeint ‑> t

Alias to Int64.of_nativeint.

  • Deprecated since 2.1
val to_float : t ‑> float

Convert the given 64-bit integer to a floating-point number.

val of_float : float ‑> t

Alias to Int64.of_float. -Convert the given floating-point number to a 64-bit integer, -discarding the fractional part (truncate towards 0). -The result of the conversion is undefined if, after truncation, -the number is outside the range [CCInt64.min_int, CCInt64.max_int]. -NOTE: used to return an option, but the function never fails.

val of_float_exn : float ‑> t

Alias to Int64.of_float.

  • Deprecated since 2.1
val to_string : t ‑> string

Return the string representation of its argument, in decimal.

val of_string : string ‑> t option

Safe version of of_string_exn.

val of_string_opt : string ‑> t option

Alias to of_string.

  • Since: 2.1
val of_string_exn : string ‑> t

Alias to Int64.of_string. -Convert the given string to a 64-bit integer. -The string is read in decimal (by default, or if the string -begins with 0u) or in hexadecimal, octal or binary if the -string begins with 0x, 0o or 0b respectively.

The 0u prefix reads the input as an unsigned integer in the range -[0, 2*CCInt64.max_int+1]. If the input exceeds CCInt64.max_int -it is converted to the signed integer -CCInt64.min_int + input - CCInt64.max_int - 1.

The _ (underscore) character can appear anywhere in the string -and is ignored. -Raise Failure "Int64.of_string" if the given string is not -a valid representation of an integer, or if the integer represented -exceeds the range of integers representable in type int64.

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

Module CCInt64

Int64

Helpers for 64-bit integers

since
0.13
include module type of sig ... end
val zero : int64
val one : int64
val minus_one : int64
val neg : int64 -> int64
val add : int64 -> int64 -> int64
val sub : int64 -> int64 -> int64
val mul : int64 -> int64 -> int64
val div : int64 -> int64 -> int64
val rem : int64 -> int64 -> int64
val succ : int64 -> int64
val pred : int64 -> int64
val abs : int64 -> int64
val max_int : int64
val min_int : int64
val logand : int64 -> int64 -> int64
val logor : int64 -> int64 -> int64
val logxor : int64 -> int64 -> int64
val lognot : int64 -> int64
val shift_left : int64 -> int -> int64
val shift_right : int64 -> int -> int64
val shift_right_logical : int64 -> int -> int64
val of_int : int -> int64
val to_int : int64 -> int
val of_float : float -> int64
val to_float : int64 -> float
val of_int32 : int32 -> int64
val to_int32 : int64 -> int32
val of_nativeint : nativeint -> int64
val to_nativeint : int64 -> nativeint
val of_string : string -> int64
val of_string_opt : string -> int64 option
val to_string : int64 -> string
val bits_of_float : float -> int64
val float_of_bits : int64 -> float
type t = int64
val compare : t -> t -> int
val equal : t -> t -> bool
val format : string -> int64 -> string
val (+) : t -> t -> t

Addition.

val (-) : t -> t -> t

Subtraction.

val (~-) : t -> t

Unary negation.

val (*) : t -> t -> t

Multiplication.

val (/) : t -> t -> t

Integer division. Raise Division_by_zero if the second argument is zero. This division rounds the real quotient of its arguments towards zero, as specified for Pervasives.(/).

val (mod) : t -> t -> t

Integer remainder. If y = 0, x mod y raises Division_by_zero.

val abs : t -> t

Return the absolute value of its argument.

val max_int : t

The greatest representable 64-bit integer, 263 - 1 = 9_223_372_036_854_775_807.

val min_int : t

The smallest representable 64-bit integer, -263 = -9_223_372_036_854_775_808.

val (land) : t -> t -> t

Bitwise logical and.

val (lor) : t -> t -> t

Bitwise logical or.

val (lxor) : t -> t -> t

Bitwise logical exclusive or.

val (lnot) : t -> t

Bitwise logical negation.

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

x lsl y shifts x to the left by y bits, filling in with zeroes. The result is unspecified if y < 0 or y >= 64.

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

x lsr y shifts x to the right by y bits. This is a logical shift: zeroes are inserted in the vacated bits regardless of the sign of x. The result is unspecified if y < 0 or y >= 64.

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

x asr y shifts x to the right by y bits. This is an arithmetic shift: the sign bit of x is replicated and inserted in the vacated bits. The result is unspecified if y < 0 or y >= 64.

module Infix : sig ... end

Infix operators

include module type of Infix
val (+) : t -> t -> t
val (-) : t -> t -> t
val (~-) : t -> t
val (*) : t -> t -> t
val (/) : t -> t -> t
val (mod) : t -> t -> t
val (land) : t -> t -> t
val (lor) : t -> t -> t
val (lxor) : t -> t -> t
val (lnot) : t -> t
val (lsl) : t -> int -> t
val (lsr) : t -> int -> t
val (asr) : t -> int -> t
val (=) : t -> t -> bool
val (<>) : t -> t -> bool
val (>) : t -> t -> bool
val (>=) : t -> t -> bool
val (<=) : t -> t -> bool
val (<) : t -> t -> bool
val equal : t -> t -> bool

The equal function for 64-bit integers. Like Pervasives.(=) x y).

val compare : t -> t -> int

The comparison function for 64-bit integers, with the same specification as Pervasives.compare. Along with the type t, this function compare allows the module CCInt64 to be passed as argument to the functors Set.Make and Map.Make.

val hash : t -> int

Like Pervasives.abs (to_int x).

Conversion

val to_int : t -> int

Convert the given 64-bit integer (type int64) to an integer (type int). On 64-bit platforms, the 64-bit integer is taken modulo 263, i.e. the high-order bit is lost during the conversion. On 32-bit platforms, the 64-bit integer is taken modulo 231, i.e. the top 33 bits are lost during the conversion.

val of_int : int -> t

Alias to Int64.of_int. NOTE: used to return an option, but the function actually never fails.

val of_int_exn : int -> t

Alias to Int64.of_int.

deprecated

since 2.1, use Int64.of_int instead.

val to_int32 : t -> int32

Convert the given 64-bit integer (type int64) to a 32-bit integer (type int32). The 64-bit integer is taken modulo 232, i.e. the top 32 bits are lost during the conversion.

val of_int32 : int32 -> t

Alias to Int64.of_int32. NOTE: use to return an option, but the function actually never fails.

val of_int32_exn : int32 -> t

Alias to Int64.of_int32.

deprecated

since 2.1, use Int64.of_int32 instead.

val to_nativeint : t -> nativeint

Convert the given 64-bit integer (type int64) to a native integer. On 32-bit platforms, the 64-bit integer is taken modulo 232. On 64-bit platforms, the conversion is exact.

val of_nativeint : nativeint -> t

Alias to Int64.of_nativeint. NOTE: use to return an option, but the function actually never fails.

val of_nativeint_exn : nativeint -> t

Alias to Int64.of_nativeint.

deprecated

since 2.1, use Int64.of_nativeint instead.

val to_float : t -> float

Convert the given 64-bit integer to a floating-point number.

val of_float : float -> t

Alias to Int64.of_float. Convert the given floating-point number to a 64-bit integer, discarding the fractional part (truncate towards 0). The result of the conversion is undefined if, after truncation, the number is outside the range [CCInt64.min_int, CCInt64.max_int]. NOTE: used to return an option, but the function never fails.

val of_float_exn : float -> t

Alias to Int64.of_float.

deprecated

since 2.1, use Int64.of_float instead.

val to_string : t -> string

Return the string representation of its argument, in decimal.

val of_string : string -> t option

Safe version of of_string_exn.

val of_string_opt : string -> t option

Alias to of_string.

since
2.1
val of_string_exn : string -> t

Alias to Int64.of_string. Convert the given string to a 64-bit integer. The string is read in decimal (by default, or if the string begins with 0u) or in hexadecimal, octal or binary if the string begins with 0x, 0o or 0b respectively.

The 0u prefix reads the input as an unsigned integer in the range [0, 2*CCInt64.max_int+1]. If the input exceeds CCInt64.max_int it is converted to the signed integer CCInt64.min_int + input - CCInt64.max_int - 1.

The _ (underscore) character can appear anywhere in the string and is ignored. Raise Failure "Int64.of_string" if the given string is not a valid representation of an integer, or if the integer represented exceeds the range of integers representable in type int64.

\ No newline at end of file diff --git a/dev/containers/CCList/Assoc/index.html b/dev/containers/CCList/Assoc/index.html index 7c33af60..d463a51a 100644 --- a/dev/containers/CCList/Assoc/index.html +++ b/dev/containers/CCList/Assoc/index.html @@ -1,4 +1,2 @@ -Assoc (containers.CCList.Assoc)

Module CCList.Assoc

type ('a, 'b) t = ('a * 'b) list
val get : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> ('a'bt ‑> 'b option

Find the element.

val get_exn : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> ('a'bt ‑> 'b

Like get, but unsafe.

  • Raises Not_found: if the element is not present.
val set : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> 'b ‑> ('a'bt ‑> ('a'bt

Add the binding into the list (erase it if already present).

val mem : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> ('a_t ‑> bool

mem x l returns true iff x is a key in l.

  • Since: 0.16
val update : eq:('a ‑> 'a ‑> bool) ‑> f:('b option ‑> 'b option) ‑> 'a ‑> ('a'bt ‑> ('a'bt

update k ~f l updates l on the key k, by calling f (get l k) -and removing k if it returns None, mapping k to v' if it -returns Some v'.

  • Since: 0.16
val remove : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> ('a'bt ‑> ('a'bt

remove x l removes the first occurrence of k from l.

  • Since: 0.17
\ No newline at end of file +Assoc (containers.CCList.Assoc)

Module CCList.Assoc

type ('a, 'b) t = ('a * 'b) list
val get : eq:('a -> 'a -> bool) -> 'a -> ('a'b) t -> 'b option

Find the element.

val get_exn : eq:('a -> 'a -> bool) -> 'a -> ('a'b) t -> 'b

Like get, but unsafe.

raises Not_found

if the element is not present.

val set : eq:('a -> 'a -> bool) -> 'a -> 'b -> ('a'b) t -> ('a'b) t

Add the binding into the list (erase it if already present).

val mem : eq:('a -> 'a -> bool) -> 'a -> ('a_) t -> bool

mem x l returns true iff x is a key in l.

since
0.16
val update : eq:('a -> 'a -> bool) -> f:('b option -> 'b option) -> 'a -> ('a'b) t -> ('a'b) t

update k ~f l updates l on the key k, by calling f (get l k) and removing k if it returns None, mapping k to v' if it returns Some v'.

since
0.16
val remove : eq:('a -> 'a -> bool) -> 'a -> ('a'b) t -> ('a'b) t

remove x l removes the first occurrence of k from l.

since
0.17
\ No newline at end of file diff --git a/dev/containers/CCList/Infix/index.html b/dev/containers/CCList/Infix/index.html index 4ede567e..d9bc337f 100644 --- a/dev/containers/CCList/Infix/index.html +++ b/dev/containers/CCList/Infix/index.html @@ -1,2 +1,2 @@ -Infix (containers.CCList.Infix)

Module CCList.Infix

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

Infix version of map with reversed arguments.

val (@) : 'a t ‑> 'a t ‑> 'a t

As append. Concatenate two lists.

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

fun <*> l is product (fun f x -> f x) funs l.

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

As map.

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

l >>= f is flat_map f l.

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

Infix alias for range. Bounds included.

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

Infix alias for range'. Second bound excluded.

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

Module CCList.Infix

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

Infix version of map with reversed arguments.

val (@) : 'a t -> 'a t -> 'a t

As append. Concatenate two lists.

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

funs <*> l is product (fun f x -> f x) funs l.

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

As map.

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

l >>= f is flat_map f l.

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

Infix alias for range. Bounds included.

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

Infix alias for range'. Second bound excluded.

\ No newline at end of file diff --git a/dev/containers/CCList/Ref/index.html b/dev/containers/CCList/Ref/index.html index 56413548..39dadcdb 100644 --- a/dev/containers/CCList/Ref/index.html +++ b/dev/containers/CCList/Ref/index.html @@ -1,3 +1,2 @@ -Ref (containers.CCList.Ref)

Module CCList.Ref

type 'a t = 'a list Pervasives.ref
val push : 'a t ‑> 'a ‑> unit
val pop : 'a t ‑> 'a option
val pop_exn : 'a t ‑> 'a

Unsafe version of pop.

  • Raises Failure: if the list is empty.
val create : unit ‑> 'a t

Create a new list reference.

val clear : _ t ‑> unit

Remove all elements.

val lift : ('a list ‑> 'b) ‑> 'a t ‑> 'b

Apply a list function to the content.

val push_list : 'a t ‑> 'a list ‑> unit

Add elements of the list at the beginning of the list ref. Elements -at the end of the list will be at the beginning of the list ref.

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

Module CCList.Ref

type 'a t = 'a list Pervasives.ref
val push : 'a t -> 'a -> unit
val pop : 'a t -> 'a option
val pop_exn : 'a t -> 'a

Unsafe version of pop.

raises Failure

if the list is empty.

val create : unit -> 'a t

Create a new list reference.

val clear : _ t -> unit

Remove all elements.

val lift : ('a list -> 'b) -> 'a t -> 'b

Apply a list function to the content.

val push_list : 'a t -> 'a list -> unit

Add elements of the list at the beginning of the list ref. Elements at the end of the list will be at the beginning of the list ref.

\ No newline at end of file diff --git a/dev/containers/CCList/Traverse/argument-1-M/index.html b/dev/containers/CCList/Traverse/argument-1-M/index.html index 07caa0b7..465ec6fb 100644 --- a/dev/containers/CCList/Traverse/argument-1-M/index.html +++ b/dev/containers/CCList/Traverse/argument-1-M/index.html @@ -1,2 +1,2 @@ -1-M (containers.CCList.Traverse.1-M)

Parameter CCList.Traverse.1-M

type 'a t
val return : 'a ‑> 'a t

Monadic return.

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

Monadic bind.

\ No newline at end of file +1-M (containers.CCList.Traverse.1-M)

Parameter Traverse.1-M

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

Monadic return.

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

Monadic bind.

\ No newline at end of file diff --git a/dev/containers/CCList/Traverse/index.html b/dev/containers/CCList/Traverse/index.html index 5b32801a..1099d6e7 100644 --- a/dev/containers/CCList/Traverse/index.html +++ b/dev/containers/CCList/Traverse/index.html @@ -1,4 +1,2 @@ -Traverse (containers.CCList.Traverse)

Module CCList.Traverse

Parameters

Signature

val sequence_m : 'a M.t t ‑> 'a t M.t
val fold_m : ('b ‑> 'a ‑> 'b M.t) ‑> 'b ‑> 'a t ‑> 'b M.t
val map_m : ('a ‑> 'b M.t) ‑> 'a t ‑> 'b t M.t
val map_m_par : ('a ‑> 'b M.t) ‑> 'a t ‑> 'b t M.t

Like map_m but map_m_par f (x::l) evaluates f x and -f l "in parallel" before combining their result (for instance -in Lwt).

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

Module CCList.Traverse

Parameters

Signature

val sequence_m : 'a M.t t -> 'a t M.t
val fold_m : ('b -> 'a -> 'b M.t) -> 'b -> 'a t -> 'b M.t
val map_m : ('a -> 'b M.t) -> 'a t -> 'b t M.t
val map_m_par : ('a -> 'b M.t) -> 'a t -> 'b t M.t

Like map_m but map_m_par f (x::l) evaluates f x and f l "in parallel" before combining their result (for instance in Lwt).

\ No newline at end of file diff --git a/dev/containers/CCList/index.html b/dev/containers/CCList/index.html index 92938bf2..d5c82905 100644 --- a/dev/containers/CCList/index.html +++ b/dev/containers/CCList/index.html @@ -1,96 +1,6 @@ -CCList (containers.CCList)

Module CCList

Complements to list

type 'a sequence = ('a ‑> unit) ‑> unit
type 'a gen = unit ‑> 'a option
type 'a klist = unit ‑> [ `Nil | `Cons of 'a * 'a klist ]
type 'a printer = Format.formatter ‑> 'a ‑> unit
type 'a random_gen = Random.State.t ‑> 'a
include module type of List
val length : 'a list ‑> int
val compare_lengths : 'a list ‑> 'b list ‑> int
val compare_length_with : 'a list ‑> int ‑> int
val cons : 'a ‑> 'a list ‑> 'a list
val hd : 'a list ‑> 'a
val tl : 'a list ‑> 'a list
val nth : 'a list ‑> int ‑> 'a
val nth_opt : 'a list ‑> int ‑> 'a option
val rev : 'a list ‑> 'a list
val init : int ‑> (int ‑> 'a) ‑> 'a list
val append : 'a list ‑> 'a list ‑> 'a list
val rev_append : 'a list ‑> 'a list ‑> 'a list
val concat : 'a list list ‑> 'a list
val flatten : 'a list list ‑> 'a list
val iter : ('a ‑> unit) ‑> 'a list ‑> unit
val iteri : (int ‑> 'a ‑> unit) ‑> 'a list ‑> unit
val map : ('a ‑> 'b) ‑> 'a list ‑> 'b list
val mapi : (int ‑> 'a ‑> 'b) ‑> 'a list ‑> 'b list
val rev_map : ('a ‑> 'b) ‑> 'a list ‑> 'b list
val fold_left : ('a ‑> 'b ‑> 'a) ‑> 'a ‑> 'b list ‑> 'a
val fold_right : ('a ‑> 'b ‑> 'b) ‑> 'a list ‑> 'b ‑> 'b
val iter2 : ('a ‑> 'b ‑> unit) ‑> 'a list ‑> 'b list ‑> unit
val map2 : ('a ‑> 'b ‑> 'c) ‑> 'a list ‑> 'b list ‑> 'c list
val rev_map2 : ('a ‑> 'b ‑> 'c) ‑> 'a list ‑> 'b list ‑> 'c list
val fold_left2 : ('a ‑> 'b ‑> 'c ‑> 'a) ‑> 'a ‑> 'b list ‑> 'c list ‑> 'a
val fold_right2 : ('a ‑> 'b ‑> 'c ‑> 'c) ‑> 'a list ‑> 'b list ‑> 'c ‑> 'c
val for_all : ('a ‑> bool) ‑> 'a list ‑> bool
val exists : ('a ‑> bool) ‑> 'a list ‑> bool
val for_all2 : ('a ‑> 'b ‑> bool) ‑> 'a list ‑> 'b list ‑> bool
val exists2 : ('a ‑> 'b ‑> bool) ‑> 'a list ‑> 'b list ‑> bool
val mem : 'a ‑> 'a list ‑> bool
val memq : 'a ‑> 'a list ‑> bool
val find : ('a ‑> bool) ‑> 'a list ‑> 'a
val find_opt : ('a ‑> bool) ‑> 'a list ‑> 'a option
val filter : ('a ‑> bool) ‑> 'a list ‑> 'a list
val find_all : ('a ‑> bool) ‑> 'a list ‑> 'a list
val partition : ('a ‑> bool) ‑> 'a list ‑> 'a list * 'a list
val assoc : 'a ‑> ('a * 'b) list ‑> 'b
val assoc_opt : 'a ‑> ('a * 'b) list ‑> 'b option
val assq : 'a ‑> ('a * 'b) list ‑> 'b
val assq_opt : 'a ‑> ('a * 'b) list ‑> 'b option
val mem_assoc : 'a ‑> ('a * 'b) list ‑> bool
val mem_assq : 'a ‑> ('a * 'b) list ‑> bool
val remove_assoc : 'a ‑> ('a * 'b) list ‑> ('a * 'b) list
val remove_assq : 'a ‑> ('a * 'b) list ‑> ('a * 'b) list
val split : ('a * 'b) list ‑> 'a list * 'b list
val combine : 'a list ‑> 'b list ‑> ('a * 'b) list
val sort : ('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a list
val stable_sort : ('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a list
val fast_sort : ('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a list
val sort_uniq : ('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a list
val merge : ('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a list ‑> 'a list
type 'a t = 'a list
val empty : 'a t

empty is .

val is_empty : _ t ‑> bool

is_empty l returns true iff l = [].

  • Since: 0.11
val map : ('a ‑> 'b) ‑> 'a t ‑> 'b t

Safe version of List.map.

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

Infix version of map with reversed arguments.

  • Since: 0.5
val cons : 'a ‑> 'a t ‑> 'a t

cons x l is x::l.

  • Since: 0.12
val append : 'a t ‑> 'a t ‑> 'a t

Safe version of List.append. -Concatenate two lists.

val cons_maybe : 'a option ‑> 'a t ‑> 'a t

cons_maybe (Some x) l is x :: l. -cons_maybe None l is l.

  • Since: 0.13
val (@) : 'a t ‑> 'a t ‑> 'a t

Like append. -Concatenate two lists.

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

Safe version of List.filter. -filter p l returns all the elements of the list l -that satisfy the predicate p. The order of the elements -in the input list is preserved.

val fold_right : ('a ‑> 'b ‑> 'b) ‑> 'a t ‑> 'b ‑> 'b

Safe version of fold_right. -fold_right f [a1; ...; an] b is -f a1 (f a2 (... (f an b) ...)). Not tail-recursive.

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

Fold until a stop condition via ('a, `Stop) is -indicated by the accumulator.

  • Since: 0.8
val fold_map : ('acc ‑> 'a ‑> 'acc * 'b) ‑> 'acc ‑> 'a list ‑> 'acc * 'b list

fold_map f acc l is a fold_left-like function, but it also maps the -list to another list.

  • Since: 0.14
val scan_left : ('acc ‑> 'a ‑> 'acc) ‑> 'acc ‑> 'a list ‑> 'acc list

scan_left f acc l returns the list [acc; f acc x0; f (f acc x0) x1; ...] -where x0, x1, etc. are the elements of l.

  • Since: 1.2
val fold_map2 : ('acc ‑> 'a ‑> 'b ‑> 'acc * 'c) ‑> 'acc ‑> 'a list ‑> 'b list ‑> 'acc * 'c list

fold_map2 is to fold_map what List.map2 is to List.map.

  • Raises Invalid_argument: if the lists do not have the same length.
  • Since: 0.16
val fold_filter_map : ('acc ‑> 'a ‑> 'acc * 'b option) ‑> 'acc ‑> 'a list ‑> 'acc * 'b list

fold_filter_map f acc l is a fold_left-like function, but also -generates a list of output in a way similar to filter_map.

  • Since: 0.17
val fold_flat_map : ('acc ‑> 'a ‑> 'acc * 'b list) ‑> 'acc ‑> 'a list ‑> 'acc * 'b list

fold_flat_map f acc l is a fold_left-like function, but it also maps the -list to a list of lists that is then flatten'd.

  • Since: 0.14
val count : ('a ‑> bool) ‑> 'a list ‑> int

count f l counts how much elements of l comply with the function f.

  • Since: 1.5
val init : int ‑> (int ‑> 'a) ‑> 'a t

init len f is f 0; f 1; ...; f (len-1).

  • Raises Invalid_argument: if len < 0.
  • Since: 0.6
val combine : 'a list ‑> 'b list ‑> ('a * 'b) list

Like List.combine but tail-recursive. -Transform a pair of lists into a list of pairs: -combine [a1; ...; an] [b1; ...; bn] is -[(a1,b1); ...; (an,bn)].

  • Raises Invalid_argument: if the lists have distinct lengths.
  • Since: 1.2
val combine_gen : 'a list ‑> 'b list ‑> ('a * 'b) gen

Lazy version of combine. -Unlike combine, it does not fail if the lists have different -lengths; -instead, the output has as many pairs as the smallest input list.

  • Since: 1.2
val split : ('a * 'b) t ‑> 'a t * 'b t

A tail-recursive version of List.split. -Transform a list of pairs into a pair of lists: -split [(a1,b1); ...; (an,bn)] is ([a1; ...; an], [b1; ...; bn]).

val compare : ('a ‑> 'a ‑> int) ‑> 'a t ‑> 'a t ‑> int
val compare_lengths : 'a t ‑> 'b t ‑> int

Equivalent to compare (length l1) (length l2) but more efficient. -Compare the lengths of two lists.

  • Since: 1.5
val compare_length_with : 'a t ‑> int ‑> int

Equivalent to compare (length l) x but more efficient. -Compare the length of a list to an integer.

  • Since: 1.5
val equal : ('a ‑> 'a ‑> bool) ‑> 'a t ‑> 'a t ‑> bool
val flat_map : ('a ‑> 'b t) ‑> 'a t ‑> 'b t

Map and flatten at the same time (safe). Evaluation order is not guaranteed.

val flatten : 'a t t ‑> 'a t

Safe flatten. Concatenate a list of lists.

val product : ('a ‑> 'b ‑> 'c) ‑> 'a t ‑> 'b t ‑> 'c t

Cartesian product of the two lists, with the given combinator.

val fold_product : ('c ‑> 'a ‑> 'b ‑> 'c) ‑> 'c ‑> 'a t ‑> 'b t ‑> 'c

Fold on the cartesian product.

val cartesian_product : 'a t t ‑> 'a t t

Produce the cartesian product of this list of lists, -by returning all the ways of picking one element per sublist. -NOTE the order of the returned list is unspecified. -For example: -

      # cartesian_product [[1;2];[3];[4;5;6]] |> sort =
-      [[1;3;4];[1;3;5];[1;3;6];[2;3;4];[2;3;5];[2;3;6]];;
-      # cartesian_product [[1;2];[];[4;5;6]] = [];;
-      # cartesian_product [[1;2];[3];[4];[5];[6]] |> sort =
-      [[1;3;4;5;6];[2;3;4;5;6]];;

-invariant: cartesian_product l = map_product id l.

  • Since: 1.2
val map_product_l : ('a ‑> 'b list) ‑> 'a list ‑> 'b list list

map_product_l f l maps each element of l to a list of -objects of type 'b using f. -We obtain [l1;l2;...;ln] where length l=n and li : 'b list. -Then, it returns all the ways of picking exactly one element per li.

  • Since: 1.2
val diagonal : 'a t ‑> ('a * 'a) t

All pairs of distinct positions of the list. list_diagonal l will -return the list of List.nth i l, List.nth j l if i < j.

val partition_map : ('a ‑> [< `Left of 'b | `Right of 'c | `Drop ]) ‑> 'a list ‑> 'b list * 'c list

partition_map f l maps f on l and gather results in lists: -

  • if f x = `Left y, adds y to the first list.
  • if f x = `Right z, adds z to the second list.
  • if f x = `Drop, ignores x.
  • Since: 0.11
val sublists_of_len : ?⁠last:('a list ‑> 'a list option) ‑> ?⁠offset:int ‑> int ‑> 'a list ‑> 'a list list

sublists_of_len n l returns sub-lists of l that have length n. -By default, these sub-lists are non overlapping: -sublists_of_len 2 [1;2;3;4;5;6] returns [1;2]; [3;4]; [5;6].

Examples:

  • sublists_of_len 2 [1;2;3;4;5;6] = [[1;2]; [3;4]; [5;6]].
  • sublists_of_len 2 ~offset:3 [1;2;3;4;5;6] = [1;2];[4;5].
  • sublists_of_len 3 ~last:CCOpt.return [1;2;3;4] = [1;2;3];[4].
  • sublists_of_len 2 [1;2;3;4;5] = [[1;2]; [3;4]].
  • Parameter offset: the number of elements skipped between two consecutive -sub-lists. By default it is n. If offset < n, the sub-lists -will overlap; if offset > n, some elements will not appear at all.
  • Parameter last: if provided and the last group of elements g is such -that length g < n, last g is called. If last g = Some g', -g' is appended; otherwise g is dropped. -If last = CCOpt.return, it will simply keep the last group. -By default, last = fun _ -> None, i.e. the last group is dropped if shorter than n.
  • Raises Invalid_argument: if offset <= 0 or n <= 0.
  • Since: 1.0
val intersperse : 'a ‑> 'a list ‑> 'a list

Insert the first argument between every element of the list

  • Since: 2.1
val interleave : 'a list ‑> 'a list ‑> 'a list

interleave [x1…xn] [y1…ym] is x1,y1,x2,y2,… and finishes with -the suffix of the longest list

  • Since: 2.1
val pure : 'a ‑> 'a t

pure is return.

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

funs <*> l is product (fun f x -> f x) funs l.

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

(<$>) = map.

val return : 'a ‑> 'a t

return x is x.

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

l >>= f is flat_map f l.

val take : int ‑> 'a t ‑> 'a t

Take the n first elements, drop the rest.

val drop : int ‑> 'a t ‑> 'a t

Drop the n first elements, keep the rest.

val hd_tl : 'a t ‑> 'a * 'a t

hd_tl (x :: l) returns hd, l.

  • Raises Failure: if the list is empty.
  • Since: 0.16
val take_drop : int ‑> 'a t ‑> 'a t * 'a t

take_drop n l returns l1, l2 such that l1 @ l2 = l and -length l1 = min (length l) n.

val take_while : ('a ‑> bool) ‑> 'a t ‑> 'a t

take_while f l returns the longest prefix of l for which f is true.

  • Since: 0.13
val drop_while : ('a ‑> bool) ‑> 'a t ‑> 'a t

drop_while f l drops the longest prefix of l for which f is true.

  • Since: 0.13
val take_drop_while : ('a ‑> bool) ‑> 'a t ‑> 'a t * 'a t

take_drop_while p l = take_while p l, drop_while p l.

  • Since: 1.2
val last : int ‑> 'a t ‑> 'a t

last n l takes the last n elements of l (or less if -l doesn't have that many elements.

val head_opt : 'a t ‑> 'a option

First element.

  • Since: 0.20
val tail_opt : 'a t ‑> 'a t option

Return the given list without its first element.

  • Since: 2.0
val last_opt : 'a t ‑> 'a option

Last element.

  • Since: 0.20
val find_pred : ('a ‑> bool) ‑> 'a t ‑> 'a option

find_pred p l finds the first element of l that satisfies p, -or returns None if no element satisfies p.

  • Since: 0.11
val find_opt : ('a ‑> bool) ‑> 'a t ‑> 'a option

Safe version of find.

  • Since: 1.5
val find_pred_exn : ('a ‑> bool) ‑> 'a t ‑> 'a

Unsafe version of find_pred.

  • Raises Not_found: if no such element is found.
  • Since: 0.11
val find_map : ('a ‑> 'b option) ‑> 'a t ‑> 'b option

find_map f l traverses l, applying f to each element. If for -some element x, f x = Some y, then Some y is returned. Otherwise -the call returns None.

  • Since: 0.11
val find_mapi : (int ‑> 'a ‑> 'b option) ‑> 'a t ‑> 'b option

Like find_map, but also pass the index to the predicate function.

  • Since: 0.11
val find_idx : ('a ‑> bool) ‑> 'a t ‑> (int * 'a) option

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

val remove : eq:('a ‑> 'a ‑> bool) ‑> x:'a ‑> 'a t ‑> 'a t

remove ~x l removes every instance of x from l. Tail-recursive.

  • Parameter eq: equality function.
  • Since: 0.11
val filter_map : ('a ‑> 'b option) ‑> 'a t ‑> 'b t

filter_map f l is the sublist of l containing only elements for which -f returns Some e. -Map and remove elements at the same time.

val keep_some : 'a option t ‑> 'a t

keep_some l retains only elements of the form Some x. -Like filter_map CCFun.id.

  • Since: 1.3
val keep_ok : ('a_) Result.result t ‑> 'a t

keep_ok l retains only elements of the form Ok x.

  • Since: 1.3
val all_some : 'a option t ‑> 'a t option

all_some l returns Some l' if all elements of l are of the form Some x, -or None otherwise.

  • Since: 1.3
val all_ok : ('a'err) Result.result t ‑> ('a t'err) Result.result

all_ok l returns Ok l' if all elements of l are of the form Ok x, -or Error e otherwise (with the first error met).

  • Since: 1.3
val sorted_merge : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a list ‑> 'a list

Merge elements from both sorted list.

val sort_uniq : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a list

Sort the list and remove duplicate elements.

val sorted_merge_uniq : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a list ‑> 'a list

sorted_merge_uniq l1 l2 merges the sorted lists l1 and l2 and -removes duplicates.

  • Since: 0.10
val is_sorted : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> bool

is_sorted l returns true iff l is sorted (according to given order).

  • Parameter cmp: the comparison function (default Pervasives.compare).
  • Since: 0.17
val sorted_insert : cmp:('a ‑> 'a ‑> int) ‑> ?⁠uniq:bool ‑> 'a ‑> 'a list ‑> 'a list

sorted_insert x l inserts x into l such that, if l was sorted, -then sorted_insert x l is sorted too.

  • Parameter uniq: if true and x is already in sorted position in l, then -x is not duplicated. Default false (x will be inserted in any case).
  • Since: 0.17
val uniq_succ : eq:('a ‑> 'a ‑> bool) ‑> 'a list ‑> 'a list

uniq_succ l removes duplicate elements that occur one next to the other. -Examples: -uniq_succ [1;2;1] = [1;2;1]. -uniq_succ [1;1;2] = [1;2].

  • Since: 0.10
val group_succ : eq:('a ‑> 'a ‑> bool) ‑> 'a list ‑> 'a list list

group_succ ~eq l groups together consecutive elements that are equal -according to eq.

  • Since: 0.11

Indices

val mapi : (int ‑> 'a ‑> 'b) ‑> 'a t ‑> 'b t

Like map, but the function is applied to the index of -the element as first argument (counting from 0), and the element -itself as second argument.

val iteri : (int ‑> 'a ‑> unit) ‑> 'a t ‑> unit

Like iter, but the function is applied to the index of -the element as first argument (counting from 0), and the element -itself as second argument.

val iteri2 : (int ‑> 'a ‑> 'b ‑> unit) ‑> 'a t ‑> 'b t ‑> unit

Iter on two lists.

  • Raises Invalid_argument: when lists do not have the same length.
  • Since: 2.0
val foldi : ('b ‑> int ‑> 'a ‑> 'b) ‑> 'b ‑> 'a t ‑> 'b

Like fold but it also passes in the index of each element to the folded function. Tail-recursive.

val foldi2 : ('c ‑> int ‑> 'a ‑> 'b ‑> 'c) ‑> 'c ‑> 'a t ‑> 'b t ‑> 'c

Fold on two lists, with index.

  • Raises Invalid_argument: when lists do not have the same length.
  • Since: 2.0
val get_at_idx : int ‑> 'a t ‑> 'a option

Get by index in the list. -If the index is negative, it will get element starting from the end -of the list.

val nth_opt : 'a t ‑> int ‑> 'a option

Safe version of nth.

  • Raises Invalid_argument: if the int is negative.
  • Since: 1.5
val get_at_idx_exn : int ‑> 'a t ‑> 'a

Get the i-th element, or

  • Raises Not_found: if the index is invalid. -If the index is negative, it will get element starting from the end -of the list.
val set_at_idx : int ‑> 'a ‑> 'a t ‑> 'a t

Set i-th element (removes the old one), or does nothing if -index is too high. -If the index is negative, it will set element starting from the end -of the list.

val insert_at_idx : int ‑> 'a ‑> 'a t ‑> 'a t

Insert at i-th position, between the two existing elements. If the -index is too high, append at the end of the list. -If the index is negative, it will insert element starting from the end -of the list.

val remove_at_idx : int ‑> 'a t ‑> 'a t

Remove element at given index. Does nothing if the index is -too high. -If the index is negative, it will remove element starting from the end -of the list.

Set Operators

Those operations maintain the invariant that the list does not -contain duplicates (if it already satisfies it).

val add_nodup : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> 'a t ‑> 'a t

add_nodup x set adds x to set if it was not already present. Linear time.

  • Since: 0.11
val remove_one : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> 'a t ‑> 'a t

remove_one x set removes one occurrence of x from set. Linear time.

  • Since: 0.11
val mem : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> 'a t ‑> bool

Membership to the list. Linear time.

val subset : eq:('a ‑> 'a ‑> bool) ‑> 'a t ‑> 'a t ‑> bool

Test for inclusion.

val uniq : eq:('a ‑> 'a ‑> bool) ‑> 'a t ‑> 'a t

Remove duplicates w.r.t the equality predicate. -Complexity is quadratic in the length of the list, but the order -of elements is preserved. If you wish for a faster de-duplication -but do not care about the order, use sort_uniq.

val union : eq:('a ‑> 'a ‑> bool) ‑> 'a t ‑> 'a t ‑> 'a t

List union. Complexity is product of length of inputs.

val inter : eq:('a ‑> 'a ‑> bool) ‑> 'a t ‑> 'a t ‑> 'a t

List intersection. Complexity is product of length of inputs.

Other Constructors

val range_by : step:int ‑> int ‑> int ‑> int t

range_by ~step i j iterates on integers from i to j included, -where the difference between successive elements is step. -Use a negative step for a decreasing list.

  • Raises Invalid_argument: if step=0.
  • Since: 0.18
val range : int ‑> int ‑> int t

range i j iterates on integers from i to j included. It works -both for decreasing and increasing ranges.

val range' : int ‑> int ‑> int t

Like range but the second bound is excluded. -For instance range' 0 5 = [0;1;2;3;4].

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

Infix alias for range.

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

Infix alias for range'.

  • Since: 0.17
val replicate : int ‑> 'a ‑> 'a t

Replicate the given element n times.

val repeat : int ‑> 'a t ‑> 'a t

Concatenate the list with itself n times.

Association Lists

module Assoc : sig ... end
val assoc : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> ('a * 'b) t ‑> 'b

Like Assoc.get_exn.

  • Since: 2.0
val assoc_opt : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> ('a * 'b) t ‑> 'b option

Like Assoc.get.

  • Since: 1.5
val assq_opt : 'a ‑> ('a * 'b) t ‑> 'b option

Safe version of assq.

  • Since: 1.5
val mem_assoc : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> ('a * _) t ‑> bool

Like Assoc.mem.

  • Since: 2.0
val remove_assoc : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> ('a * 'b) t ‑> ('a * 'b) t

Like Assoc.remove.

  • Since: 2.0

References on Lists

module Ref : sig ... end
module type MONAD : sig ... end

Monadic Operations

module Traverse : functor (M : MONAD) -> sig ... end

Conversions

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
val random_choose : 'a t ‑> 'a random_gen

Randomly choose an element in the list.

  • Raises Not_found: if the list is empty.
val random_sequence : 'a random_gen t ‑> 'a t random_gen
val to_seq : 'a t ‑> 'a sequence

Return a sequence of the elements of the list.

val of_seq : 'a sequence ‑> 'a t

Build a list from a given sequence. -In the result, elements appear in the same order as they did in the source sequence.

val to_gen : 'a t ‑> 'a gen

Return a gen of the elements of the list.

val of_gen : 'a gen ‑> 'a t

Build a list from a given gen. -In the result, elements appear in the same order as they did in the source gen.

val to_klist : 'a t ‑> 'a klist

Return a klist of the elements of the list.

val of_klist : 'a klist ‑> 'a t

Build a list from a given klist. -In the result, elements appear in the same order as they did in the source klist.

Infix Operators

-It is convenient to open CCList.Infix to access the infix operators -without cluttering the scope too much.

module Infix : sig ... end

IO

val pp : ?⁠start:string ‑> ?⁠stop:string ‑> ?⁠sep:string ‑> 'a printer ‑> 'a t printer

Print the contents of a list.

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

Module CCList

Complements to list

type 'a sequence = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
type 'a klist = unit -> [ `Nil | `Cons of 'a * 'a klist ]
type 'a printer = Format.formatter -> 'a -> unit
type 'a random_gen = Random.State.t -> 'a
include module type of List
val length : 'a list -> int
val compare_lengths : 'a list -> 'b list -> int
val compare_length_with : 'a list -> int -> int
val cons : 'a -> 'a list -> 'a list
val hd : 'a list -> 'a
val tl : 'a list -> 'a list
val nth : 'a list -> int -> 'a
val nth_opt : 'a list -> int -> 'a option
val rev : 'a list -> 'a list
val init : int -> (int -> 'a) -> 'a list
val append : 'a list -> 'a list -> 'a list
val rev_append : 'a list -> 'a list -> 'a list
val concat : 'a list list -> 'a list
val flatten : 'a list list -> 'a list
val iter : ('a -> unit) -> 'a list -> unit
val iteri : (int -> 'a -> unit) -> 'a list -> unit
val map : ('a -> 'b) -> 'a list -> 'b list
val mapi : (int -> 'a -> 'b) -> 'a list -> 'b list
val rev_map : ('a -> 'b) -> 'a list -> 'b list
val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a
val fold_right : ('a -> 'b -> 'b) -> 'a list -> 'b -> 'b
val iter2 : ('a -> 'b -> unit) -> 'a list -> 'b list -> unit
val map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
val rev_map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
val fold_left2 : ('a -> 'b -> 'c -> 'a) -> 'a -> 'b list -> 'c list -> 'a
val fold_right2 : ('a -> 'b -> 'c -> 'c) -> 'a list -> 'b list -> 'c -> 'c
val for_all : ('a -> bool) -> 'a list -> bool
val exists : ('a -> bool) -> 'a list -> bool
val for_all2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
val exists2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
val mem : 'a -> 'a list -> bool
val memq : 'a -> 'a list -> bool
val find : ('a -> bool) -> 'a list -> 'a
val find_opt : ('a -> bool) -> 'a list -> 'a option
val filter : ('a -> bool) -> 'a list -> 'a list
val find_all : ('a -> bool) -> 'a list -> 'a list
val partition : ('a -> bool) -> 'a list -> 'a list * 'a list
val assoc : 'a -> ('a * 'b) list -> 'b
val assoc_opt : 'a -> ('a * 'b) list -> 'b option
val assq : 'a -> ('a * 'b) list -> 'b
val assq_opt : 'a -> ('a * 'b) list -> 'b option
val mem_assoc : 'a -> ('a * 'b) list -> bool
val mem_assq : 'a -> ('a * 'b) list -> bool
val remove_assoc : 'a -> ('a * 'b) list -> ('a * 'b) list
val remove_assq : 'a -> ('a * 'b) list -> ('a * 'b) list
val split : ('a * 'b) list -> 'a list * 'b list
val combine : 'a list -> 'b list -> ('a * 'b) list
val sort : ('a -> 'a -> int) -> 'a list -> 'a list
val stable_sort : ('a -> 'a -> int) -> 'a list -> 'a list
val fast_sort : ('a -> 'a -> int) -> 'a list -> 'a list
val sort_uniq : ('a -> 'a -> int) -> 'a list -> 'a list
val merge : ('a -> 'a -> int) -> 'a list -> 'a list -> 'a list
type 'a t = 'a list
val empty : 'a t

empty is [].

val is_empty : _ t -> bool

is_empty l returns true iff l = [].

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

Safe version of List.map.

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

Infix version of map with reversed arguments.

since
0.5
val cons : 'a -> 'a t -> 'a t

cons x l is x::l.

since
0.12
val append : 'a t -> 'a t -> 'a t

Safe version of List.append. Concatenate two lists.

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

cons_maybe (Some x) l is x :: l. cons_maybe None l is l.

since
0.13
val (@) : 'a t -> 'a t -> 'a t

Like append. Concatenate two lists.

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

Safe version of List.filter. filter p l returns all the elements of the list l that satisfy the predicate p. The order of the elements in the input list is preserved.

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

Safe version of fold_right. fold_right f [a1; ...; an] b is f a1 (f a2 (... (f an b) ...)).

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

Fold until a stop condition via ('a, `Stop) is indicated by the accumulator.

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

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

since
0.14
val scan_left : ('acc -> 'a -> 'acc) -> 'acc -> 'a list -> 'acc list

scan_left f init l returns the list [init; f init x0; f (f init x0) x1; ...] where x0, x1, etc. are the elements of l.

since
1.2, but only
since
2.2 with labels
val fold_map2 : ('acc -> 'a -> 'b -> 'acc * 'c) -> 'acc -> 'a list -> 'b list -> 'acc * 'c list

fold_map2 is to fold_map what List.map2 is to List.map.

raises Invalid_argument

if the lists do not have the same length.

since
0.16
val fold_filter_map : ('acc -> 'a -> 'acc * 'b option) -> 'acc -> 'a list -> 'acc * 'b list

fold_filter_map f init l is a fold_left-like function, but also generates a list of output in a way similar to filter_map.

since
0.17
val fold_flat_map : ('acc -> 'a -> 'acc * 'b list) -> 'acc -> 'a list -> 'acc * 'b list

fold_flat_map f acc l is a fold_left-like function, but it also maps the list to a list of lists that is then flatten'd.

since
0.14
val count : ('a -> bool) -> 'a list -> int

count p l counts how many elements of l satisfy predicate p.

since
1.5, but only
since
2.2 with labels
val count_true_false : ('a -> bool) -> 'a list -> int * int
since
2.4
val init : int -> (int -> 'a) -> 'a t

init len f is f 0; f 1; ...; f (len-1).

raises Invalid_argument

if len < 0.

since
0.6
val combine : 'a list -> 'b list -> ('a * 'b) list

Like List.combine but tail-recursive. Transform a pair of lists into a list of pairs: combine [a1; ...; an] [b1; ...; bn] is [(a1,b1); ...; (an,bn)].

raises Invalid_argument

if the lists have distinct lengths.

since
1.2, but only
since
2.2 with labels
val combine_gen : 'a list -> 'b list -> ('a * 'b) gen

Lazy version of combine. Unlike combine, it does not fail if the lists have different lengths; instead, the output has as many pairs as the smallest input list.

since
1.2, but only
since
2.2 with labels
val split : ('a * 'b) t -> 'a t * 'b t

A tail-recursive version of List.split. Transform a list of pairs into a pair of lists: split [(a1,b1); ...; (an,bn)] is ([a1; ...; an], [b1; ...; bn]).

since
1.2, but only
since
2.2 with labels
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
val compare_lengths : 'a t -> 'b t -> int

Equivalent to compare (length l1) (length l2) but more efficient. Compare the lengths of two lists.

since
1.5, but only
since
2.2 with labels
val compare_length_with : 'a t -> int -> int

Equivalent to compare (length l) x but more efficient. Compare the length of a list to an integer.

since
1.5, but only
since
2.2 with labels
val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
val flat_map : ('a -> 'b t) -> 'a t -> 'b t

Map and flatten at the same time (safe). Evaluation order is not guaranteed.

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

Safe flatten. Concatenate a list of lists.

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

Cartesian product of the two lists, with the given combinator.

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

Fold on the cartesian product.

val cartesian_product : 'a t t -> 'a t t

Produce the cartesian product of this list of lists, by returning all the ways of picking one element per sublist. NOTE the order of the returned list is unspecified. For example:

# cartesian_product [[1;2];[3];[4;5;6]] |> sort =
+[[1;3;4];[1;3;5];[1;3;6];[2;3;4];[2;3;5];[2;3;6]];;
+# cartesian_product [[1;2];[];[4;5;6]] = [];;
+# cartesian_product [[1;2];[3];[4];[5];[6]] |> sort =
+[[1;3;4;5;6];[2;3;4;5;6]];;

invariant: cartesian_product l = map_product id l.

since
1.2, but only
since
2.2 with labels
val map_product_l : ('a -> 'b list) -> 'a list -> 'b list list

map_product_l f l maps each element of l to a list of objects of type 'b using f. We obtain [l1;l2;...;ln] where length l=n and li : 'b list. Then, it returns all the ways of picking exactly one element per li.

since
1.2, but only
since
2.2 with labels
val diagonal : 'a t -> ('a * 'a) t

All pairs of distinct positions of the list. list_diagonal l will return the list of List.nth i l, List.nth j l if i < j.

val partition_map : ('a -> [< `Left of 'b | `Right of 'c | `Drop ]) -> 'a list -> 'b list * 'c list

partition_map f l maps f on l and gather results in lists:

  • if f x = `Left y, adds y to the first list.
  • if f x = `Right z, adds z to the second list.
  • if f x = `Drop, ignores x.
since
0.11
val group_by : ?⁠hash:('a -> int) -> ?⁠eq:('a -> 'a -> bool) -> 'a t -> 'a list t

Group equal elements, regardless of their order of appearance. precondition: for any x and y, if eq x y then hash x=hash y must hold.

since
2.3
val join : join_row:('a -> 'b -> 'c option) -> 'a t -> 'b t -> 'c t

join ~join_row a b combines every element of a with every element of b using join_row. If join_row returns None, then the two elements do not combine. Assume that b allows for multiple iterations.

since
2.3
val join_by : ?⁠eq:('key -> 'key -> bool) -> ?⁠hash:('key -> int) -> ('a -> 'key) -> ('b -> 'key) -> merge:('key -> 'a -> 'b -> 'c option) -> 'a t -> 'b t -> 'c t

join key1 key2 ~merge is a binary operation that takes two sequences a and b, projects their elements resp. with key1 and key2, and combine values (x,y) from (a,b) with the same key using merge. If merge returns None, the combination of values is discarded. precondition: for any x and y, if eq x y then hash x=hash y must hold.

since
2.3
val join_all_by : ?⁠eq:('key -> 'key -> bool) -> ?⁠hash:('key -> int) -> ('a -> 'key) -> ('b -> 'key) -> merge:('key -> 'a list -> 'b list -> 'c option) -> 'a t -> 'b t -> 'c t

join_all_by key1 key2 ~merge is a binary operation that takes two sequences a and b, projects their elements resp. with key1 and key2, and, for each key k occurring in at least one of them:

  • compute the list l1 of elements of a that map to k
  • compute the list l2 of elements of b that map to k
  • call merge k l1 l2. If merge returns None, the combination of values is discarded, otherwise it returns Some c and c is inserted in the result.
since
2.3
val group_join_by : ?⁠eq:('a -> 'a -> bool) -> ?⁠hash:('a -> int) -> ('b -> 'a) -> 'a t -> 'b t -> ('a * 'b list) t

group_join_by key2 associates to every element x of the first sequence, all the elements y of the second sequence such that eq x (key y). Elements of the first sequences without corresponding values in the second one are mapped to [] precondition: for any x and y, if eq x y then hash x=hash y must hold.

since
2.3
val sublists_of_len : ?⁠last:('a list -> 'a list option) -> ?⁠offset:int -> int -> 'a list -> 'a list list

sublists_of_len n l returns sub-lists of l that have length n. By default, these sub-lists are non overlapping: sublists_of_len 2 [1;2;3;4;5;6] returns [1;2]; [3;4]; [5;6].

Examples:

  • sublists_of_len 2 [1;2;3;4;5;6] = [[1;2]; [3;4]; [5;6]].
  • sublists_of_len 2 ~offset:3 [1;2;3;4;5;6] = [1;2];[4;5].
  • sublists_of_len 3 ~last:CCOpt.return [1;2;3;4] = [1;2;3];[4].
  • sublists_of_len 2 [1;2;3;4;5] = [[1;2]; [3;4]].
parameter offset

the number of elements skipped between two consecutive sub-lists. By default it is n. If offset < n, the sub-lists will overlap; if offset > n, some elements will not appear at all.

parameter last

if provided and the last group of elements g is such that length g < n, last g is called. If last g = Some g', g' is appended; otherwise g is dropped. If last = CCOpt.return, it will simply keep the last group. By default, last = fun _ -> None, i.e. the last group is dropped if shorter than n.

raises Invalid_argument

if offset <= 0 or n <= 0. See CCList.sublists_of_len for more details.

since
1.0, but only
since
1.5 with labels
val intersperse : 'a -> 'a list -> 'a list

Insert the first argument between every element of the list.

since
2.1, but only
since
2.2 with labels
val interleave : 'a list -> 'a list -> 'a list

interleave [x1…xn] [y1…ym] is x1,y1,x2,y2,… and finishes with the suffix of the longest list.

since
2.1, but only
since
2.2 with labels
val pure : 'a -> 'a t

pure is return.

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

funs <*> l is product (fun f x -> f x) funs l.

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

(<$>) is map.

val return : 'a -> 'a t

return x is x.

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

l >>= f is flat_map f l.

val take : int -> 'a t -> 'a t

Take the n first elements, drop the rest.

val drop : int -> 'a t -> 'a t

Drop the n first elements, keep the rest.

val hd_tl : 'a t -> 'a * 'a t

hd_tl (x :: l) returns hd, l.

raises Failure

if the list is empty.

since
0.16
val take_drop : int -> 'a t -> 'a t * 'a t

take_drop n l returns l1, l2 such that l1 @ l2 = l and length l1 = min (length l) n.

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

take_while f l returns the longest prefix of l for which f is true.

since
0.13
val drop_while : ('a -> bool) -> 'a t -> 'a t

drop_while f l drops the longest prefix of l for which f is true.

since
0.13
val take_drop_while : ('a -> bool) -> 'a t -> 'a t * 'a t

take_drop_while p l = take_while p l, drop_while p l.

since
1.2, but only
since
2.2 with labels
val last : int -> 'a t -> 'a t

last n l takes the last n elements of l (or less if l doesn't have that many elements).

val head_opt : 'a t -> 'a option

First element.

since
0.20
val tail_opt : 'a t -> 'a t option

Return the given list without its first element.

since
2.0
val last_opt : 'a t -> 'a option

Last element.

since
0.20
val find_pred : ('a -> bool) -> 'a t -> 'a option

find_pred p l finds the first element of l that satisfies p, or returns None if no element satisfies p.

since
0.11
val find_opt : ('a -> bool) -> 'a t -> 'a option

Safe version of find.

since
1.5, but only
since
2.2 with labels
val find_pred_exn : ('a -> bool) -> 'a t -> 'a

Unsafe version of find_pred.

raises Not_found

if no such element is found.

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

find_map f l traverses l, applying f to each element. If for some element x, f x = Some y, then Some y is returned. Otherwise the call returns None.

since
0.11
val find_mapi : (int -> 'a -> 'b option) -> 'a t -> 'b option

Like find_map, but also pass the index to the predicate function.

since
0.11
val find_idx : ('a -> bool) -> 'a t -> (int * 'a) option

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

val remove : eq:('a -> 'a -> bool) -> key:'a -> 'a t -> 'a t

remove ~key l removes every instance of key from l. Tail-recursive.

parameter eq

equality function.

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

filter_map f l is the sublist of l containing only elements for which f returns Some e. Map and remove elements at the same time.

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

keep_some l retains only elements of the form Some x. Like filter_map CCFun.id.

since
1.3, but only
since
2.2 with labels
val keep_ok : ('a_) Result.result t -> 'a t

keep_ok l retains only elements of the form Ok x.

since
1.3, but only
since
2.2 with labels
val all_some : 'a option t -> 'a t option

all_some l returns Some l' if all elements of l are of the form Some x, or None otherwise.

since
1.3, but only
since
2.2 with labels
val all_ok : ('a'err) Result.result t -> ('a t'err) Result.result

all_ok l returns Ok l' if all elements of l are of the form Ok x, or Error e otherwise (with the first error met).

since
1.3, but only
since
2.2 with labels
val sorted_merge : cmp:('a -> 'a -> int) -> 'a list -> 'a list -> 'a list

Merge elements from both sorted list.

val sort_uniq : cmp:('a -> 'a -> int) -> 'a list -> 'a list

Sort the list and remove duplicate elements.

val sorted_merge_uniq : cmp:('a -> 'a -> int) -> 'a list -> 'a list -> 'a list

sorted_merge_uniq l1 l2 merges the sorted lists l1 and l2 and removes duplicates.

since
0.10
val is_sorted : cmp:('a -> 'a -> int) -> 'a list -> bool

is_sorted l returns true iff l is sorted (according to given order).

parameter cmp

the comparison function (default Pervasives.compare).

since
0.17
val sorted_insert : cmp:('a -> 'a -> int) -> ?⁠uniq:bool -> 'a -> 'a list -> 'a list

sorted_insert x l inserts x into l such that, if l was sorted, then sorted_insert x l is sorted too.

parameter uniq

if true and x is already in sorted position in l, then x is not duplicated. Default false (x will be inserted in any case).

since
0.17
val uniq_succ : eq:('a -> 'a -> bool) -> 'a list -> 'a list

uniq_succ l removes duplicate elements that occur one next to the other. Examples: uniq_succ [1;2;1] = [1;2;1]. uniq_succ [1;1;2] = [1;2].

since
0.10
val group_succ : eq:('a -> 'a -> bool) -> 'a list -> 'a list list

group_succ ~eq l groups together consecutive elements that are equal according to eq.

since
0.11

Indices

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

Like map, but the function is applied to the index of the element as first argument (counting from 0), and the element itself as second argument.

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

Like iter, but the function is applied to the index of the element as first argument (counting from 0), and the element itself as second argument.

val iteri2 : (int -> 'a -> 'b -> unit) -> 'a t -> 'b t -> unit

Iter on two lists.

raises Invalid_argument

when lists do not have the same length.

since
2.0, but only
since
2.2 with labels
val foldi : ('b -> int -> 'a -> 'b) -> 'b -> 'a t -> 'b

Like fold but it also passes in the index of each element to the folded function. Tail-recursive.

val foldi2 : ('c -> int -> 'a -> 'b -> 'c) -> 'c -> 'a t -> 'b t -> 'c

Fold on two lists, with index.

raises Invalid_argument

when lists do not have the same length.

since
2.0, but only
since
2.2 with labels
val get_at_idx : int -> 'a t -> 'a option

Get by index in the list. If the index is negative, it will get element starting from the end of the list.

val nth_opt : 'a t -> int -> 'a option

Safe version of nth.

raises Invalid_argument

if the int is negative.

since
1.5, but only
since
2.2 with labels
val get_at_idx_exn : int -> 'a t -> 'a

Get the i-th element, or

raises Not_found

if the index is invalid. If the index is negative, it will get element starting from the end of the list.

val set_at_idx : int -> 'a -> 'a t -> 'a t

Set i-th element (removes the old one), or does nothing if index is too high. If the index is negative, it will set element starting from the end of the list.

val insert_at_idx : int -> 'a -> 'a t -> 'a t

Insert at i-th position, between the two existing elements. If the index is too high, append at the end of the list. If the index is negative, it will insert element starting from the end of the list.

val remove_at_idx : int -> 'a t -> 'a t

Remove element at given index. Does nothing if the index is too high. If the index is negative, it will remove element starting from the end of the list.

Set Operators

Those operations maintain the invariant that the list does not contain duplicates (if it already satisfies it).

val add_nodup : eq:('a -> 'a -> bool) -> 'a -> 'a t -> 'a t

add_nodup x set adds x to set if it was not already present. Linear time.

since
0.11
val remove_one : eq:('a -> 'a -> bool) -> 'a -> 'a t -> 'a t

remove_one x set removes one occurrence of x from set. Linear time.

since
0.11
val mem : eq:('a -> 'a -> bool) -> 'a -> 'a t -> bool

Membership to the list. Linear time.

val subset : eq:('a -> 'a -> bool) -> 'a t -> 'a t -> bool

Test for inclusion.

val uniq : eq:('a -> 'a -> bool) -> 'a t -> 'a t

Remove duplicates w.r.t the equality predicate. Complexity is quadratic in the length of the list, but the order of elements is preserved. If you wish for a faster de-duplication but do not care about the order, use sort_uniq.

val union : eq:('a -> 'a -> bool) -> 'a t -> 'a t -> 'a t

List union. Complexity is product of length of inputs.

val inter : eq:('a -> 'a -> bool) -> 'a t -> 'a t -> 'a t

List intersection. Complexity is product of length of inputs.

Other Constructors

val range_by : step:int -> int -> int -> int t

range_by ~step i j iterates on integers from i to j included, where the difference between successive elements is step. Use a negative step for a decreasing list.

raises Invalid_argument

if step=0.

since
0.18
val range : int -> int -> int t

range i j iterates on integers from i to j included. It works both for decreasing and increasing ranges.

val range' : int -> int -> int t

Like range but the second bound is excluded. For instance range' 0 5 = [0;1;2;3;4].

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

Infix alias for range.

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

Infix alias for range'.

since
0.17
val replicate : int -> 'a -> 'a t

Replicate the given element n times.

val repeat : int -> 'a t -> 'a t

Concatenate the list with itself n times.

Association Lists

module Assoc : sig ... end
val assoc : eq:('a -> 'a -> bool) -> 'a -> ('a * 'b) t -> 'b

Like Assoc.get_exn.

since
2.0
val assoc_opt : eq:('a -> 'a -> bool) -> 'a -> ('a * 'b) t -> 'b option

Like Assoc.get.

since
1.5, but only
since
2.0 with labels
val assq_opt : 'a -> ('a * 'b) t -> 'b option

Safe version of assq.

since
1.5, but only
since
2.0 with labels
val mem_assoc : eq:('a -> 'a -> bool) -> 'a -> ('a * _) t -> bool

Like Assoc.mem.

since
2.0
val remove_assoc : eq:('a -> 'a -> bool) -> 'a -> ('a * 'b) t -> ('a * 'b) t

Like Assoc.remove.

since
2.0

References on Lists

since
0.3.3
module Ref : sig ... end
module type MONAD = sig ... end
module Traverse : functor (M : MONAD) -> sig ... end

Conversions

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
val random_choose : 'a t -> 'a random_gen

Randomly choose an element in the list.

raises Not_found

if the list is empty.

val random_sequence : 'a random_gen t -> 'a t random_gen
val to_seq : 'a t -> 'a sequence

Return a sequence of the elements of the list.

val of_seq : 'a sequence -> 'a t

Build a list from a given sequence. In the result, elements appear in the same order as they did in the source sequence.

val to_gen : 'a t -> 'a gen

Return a gen of the elements of the list.

val of_gen : 'a gen -> 'a t

Build a list from a given gen. In the result, elements appear in the same order as they did in the source gen.

val to_klist : 'a t -> 'a klist

Return a klist of the elements of the list.

val of_klist : 'a klist -> 'a t

Build a list from a given klist. In the result, elements appear in the same order as they did in the source klist.

Infix Operators

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

since
0.16
module Infix : sig ... end

IO

val pp : ?⁠start:string -> ?⁠stop:string -> ?⁠sep:string -> 'a printer -> 'a t printer

Print the contents of a list.

\ No newline at end of file diff --git a/dev/containers/CCList/module-type-MONAD/index.html b/dev/containers/CCList/module-type-MONAD/index.html index 732eec61..0f47f52b 100644 --- a/dev/containers/CCList/module-type-MONAD/index.html +++ b/dev/containers/CCList/module-type-MONAD/index.html @@ -1,2 +1,2 @@ -MONAD (containers.CCList.MONAD)

Module type CCList.MONAD

Monadic Operations

type 'a t
val return : 'a ‑> 'a t

Monadic return.

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

Monadic bind.

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

Module type CCList.MONAD

Monadic Operations

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

Monadic return.

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

Monadic bind.

\ No newline at end of file diff --git a/dev/containers/CCListLabels/Assoc/index.html b/dev/containers/CCListLabels/Assoc/index.html index 03850fd6..b863148e 100644 --- a/dev/containers/CCListLabels/Assoc/index.html +++ b/dev/containers/CCListLabels/Assoc/index.html @@ -1,4 +1,2 @@ -Assoc (containers.CCListLabels.Assoc)

Module CCListLabels.Assoc

type ('a, 'b) t = ('a * 'b) list
val get : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> ('a'bt ‑> 'b option

Find the element.

val get_exn : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> ('a'bt ‑> 'b

Like get, but unsafe.

  • Raises Not_found: if the element is not present.
val set : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> 'b ‑> ('a'bt ‑> ('a'bt

Add the binding into the list (erase it if already present).

val mem : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> ('a_t ‑> bool

mem x l returns true iff x is a key in l.

  • Since: 0.16
val update : eq:('a ‑> 'a ‑> bool) ‑> f:('b option ‑> 'b option) ‑> 'a ‑> ('a'bt ‑> ('a'bt

update k ~f l updates l on the key k, by calling f (get l k) -and removing k if it returns None, mapping k to v' if it -returns Some v'.

  • Since: 0.16
val remove : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> ('a'bt ‑> ('a'bt

remove x l removes the first occurrence of k from l.

  • Since: 0.17
\ No newline at end of file +Assoc (containers.CCListLabels.Assoc)

Module CCListLabels.Assoc

type ('a, 'b) t = ('a * 'b) list
val get : eq:('a -> 'a -> bool) -> 'a -> ('a'b) t -> 'b option

Find the element.

val get_exn : eq:('a -> 'a -> bool) -> 'a -> ('a'b) t -> 'b

Like get, but unsafe.

raises Not_found

if the element is not present.

val set : eq:('a -> 'a -> bool) -> 'a -> 'b -> ('a'b) t -> ('a'b) t

Add the binding into the list (erase it if already present).

val mem : eq:('a -> 'a -> bool) -> 'a -> ('a_) t -> bool

mem x l returns true iff x is a key in l.

since
0.16
val update : eq:('a -> 'a -> bool) -> f:('b option -> 'b option) -> 'a -> ('a'b) t -> ('a'b) t

update k ~f l updates l on the key k, by calling f (get l k) and removing k if it returns None, mapping k to v' if it returns Some v'.

since
0.16
val remove : eq:('a -> 'a -> bool) -> 'a -> ('a'b) t -> ('a'b) t

remove x l removes the first occurrence of k from l.

since
0.17
\ No newline at end of file diff --git a/dev/containers/CCListLabels/Infix/index.html b/dev/containers/CCListLabels/Infix/index.html index db928795..a476e811 100644 --- a/dev/containers/CCListLabels/Infix/index.html +++ b/dev/containers/CCListLabels/Infix/index.html @@ -1,2 +1,2 @@ -Infix (containers.CCListLabels.Infix)

Module CCListLabels.Infix

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

Infix version of map with reversed arguments.

val (@) : 'a t ‑> 'a t ‑> 'a t

As append. Concatenate two lists.

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

fun <*> l is product (fun f x -> f x) funs l.

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

As map.

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

l >>= f is flat_map f l.

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

Infix alias for range. Bounds included.

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

Infix alias for range'. Second bound excluded.

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

Module CCListLabels.Infix

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

Infix version of map with reversed arguments.

val (@) : 'a t -> 'a t -> 'a t

As append. Concatenate two lists.

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

funs <*> l is product (fun f x -> f x) funs l.

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

As map.

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

l >>= f is flat_map f l.

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

Infix alias for range. Bounds included.

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

Infix alias for range'. Second bound excluded.

\ No newline at end of file diff --git a/dev/containers/CCListLabels/Ref/index.html b/dev/containers/CCListLabels/Ref/index.html index 0d34dd03..6800d63f 100644 --- a/dev/containers/CCListLabels/Ref/index.html +++ b/dev/containers/CCListLabels/Ref/index.html @@ -1,3 +1,2 @@ -Ref (containers.CCListLabels.Ref)

Module CCListLabels.Ref

type 'a t = 'a list Pervasives.ref
val push : 'a t ‑> 'a ‑> unit
val pop : 'a t ‑> 'a option
val pop_exn : 'a t ‑> 'a

Unsafe version of pop.

  • Raises Failure: if the list is empty.
val create : unit ‑> 'a t

Create a new list reference.

val clear : _ t ‑> unit

Remove all elements.

val lift : ('a list ‑> 'b) ‑> 'a t ‑> 'b

Apply a list function to the content.

val push_list : 'a t ‑> 'a list ‑> unit

Add elements of the list at the beginning of the list ref. Elements -at the end of the list will be at the beginning of the list ref.

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

Module CCListLabels.Ref

type 'a t = 'a list Pervasives.ref
val push : 'a t -> 'a -> unit
val pop : 'a t -> 'a option
val pop_exn : 'a t -> 'a

Unsafe version of pop.

raises Failure

if the list is empty.

val create : unit -> 'a t

Create a new list reference.

val clear : _ t -> unit

Remove all elements.

val lift : ('a list -> 'b) -> 'a t -> 'b

Apply a list function to the content.

val push_list : 'a t -> 'a list -> unit

Add elements of the list at the beginning of the list ref. Elements at the end of the list will be at the beginning of the list ref.

\ No newline at end of file diff --git a/dev/containers/CCListLabels/Traverse/argument-1-M/index.html b/dev/containers/CCListLabels/Traverse/argument-1-M/index.html index 4d3ab9eb..65e681cf 100644 --- a/dev/containers/CCListLabels/Traverse/argument-1-M/index.html +++ b/dev/containers/CCListLabels/Traverse/argument-1-M/index.html @@ -1,2 +1,2 @@ -1-M (containers.CCListLabels.Traverse.1-M)

Parameter CCListLabels.Traverse.1-M

type 'a t
val return : 'a ‑> 'a t

Monadic return.

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

Monadic bind.

\ No newline at end of file +1-M (containers.CCListLabels.Traverse.1-M)

Parameter Traverse.1-M

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

Monadic return.

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

Monadic bind.

\ No newline at end of file diff --git a/dev/containers/CCListLabels/Traverse/index.html b/dev/containers/CCListLabels/Traverse/index.html index e8fbf9d2..f2e38b53 100644 --- a/dev/containers/CCListLabels/Traverse/index.html +++ b/dev/containers/CCListLabels/Traverse/index.html @@ -1,4 +1,2 @@ -Traverse (containers.CCListLabels.Traverse)

Module CCListLabels.Traverse

Parameters

Signature

val sequence_m : 'a M.t t ‑> 'a t M.t
val fold_m : f:('b ‑> 'a ‑> 'b M.t) ‑> init:'b ‑> 'a t ‑> 'b M.t
val map_m : f:('a ‑> 'b M.t) ‑> 'a t ‑> 'b t M.t
val map_m_par : f:('a ‑> 'b M.t) ‑> 'a t ‑> 'b t M.t

Like map_m but map_m_par f (x::l) evaluates f x and -f l "in parallel" before combining their result (for instance -in Lwt).

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

Module CCListLabels.Traverse

Parameters

Signature

val sequence_m : 'a M.t t -> 'a t M.t
val fold_m : f:('b -> 'a -> 'b M.t) -> init:'b -> 'a t -> 'b M.t
val map_m : f:('a -> 'b M.t) -> 'a t -> 'b t M.t
val map_m_par : f:('a -> 'b M.t) -> 'a t -> 'b t M.t

Like map_m but map_m_par f (x::l) evaluates f x and f l "in parallel" before combining their result (for instance in Lwt).

\ No newline at end of file diff --git a/dev/containers/CCListLabels/index.html b/dev/containers/CCListLabels/index.html index be35c37d..8322b385 100644 --- a/dev/containers/CCListLabels/index.html +++ b/dev/containers/CCListLabels/index.html @@ -1,60 +1,6 @@ -CCListLabels (containers.CCListLabels)

Module CCListLabels

Complements to list

include module type of ListLabels
val length : 'a list ‑> int
val hd : 'a list ‑> 'a
val compare_lengths : 'a list ‑> 'b list ‑> int
val compare_length_with : 'a list ‑> len:int ‑> int
val cons : 'a ‑> 'a list ‑> 'a list
val tl : 'a list ‑> 'a list
val nth : 'a list ‑> int ‑> 'a
val nth_opt : 'a list ‑> int ‑> 'a option
val rev : 'a list ‑> 'a list
val init : len:int ‑> f:(int ‑> 'a) ‑> 'a list
val append : 'a list ‑> 'a list ‑> 'a list
val rev_append : 'a list ‑> 'a list ‑> 'a list
val concat : 'a list list ‑> 'a list
val flatten : 'a list list ‑> 'a list
val iter : f:('a ‑> unit) ‑> 'a list ‑> unit
val iteri : f:(int ‑> 'a ‑> unit) ‑> 'a list ‑> unit
val map : f:('a ‑> 'b) ‑> 'a list ‑> 'b list
val mapi : f:(int ‑> 'a ‑> 'b) ‑> 'a list ‑> 'b list
val rev_map : f:('a ‑> 'b) ‑> 'a list ‑> 'b list
val fold_left : f:('a ‑> 'b ‑> 'a) ‑> init:'a ‑> 'b list ‑> 'a
val fold_right : f:('a ‑> 'b ‑> 'b) ‑> 'a list ‑> init:'b ‑> 'b
val iter2 : f:('a ‑> 'b ‑> unit) ‑> 'a list ‑> 'b list ‑> unit
val map2 : f:('a ‑> 'b ‑> 'c) ‑> 'a list ‑> 'b list ‑> 'c list
val rev_map2 : f:('a ‑> 'b ‑> 'c) ‑> 'a list ‑> 'b list ‑> 'c list
val fold_left2 : f:('a ‑> 'b ‑> 'c ‑> 'a) ‑> init:'a ‑> 'b list ‑> 'c list ‑> 'a
val fold_right2 : f:('a ‑> 'b ‑> 'c ‑> 'c) ‑> 'a list ‑> 'b list ‑> init:'c ‑> 'c
val for_all : f:('a ‑> bool) ‑> 'a list ‑> bool
val exists : f:('a ‑> bool) ‑> 'a list ‑> bool
val for_all2 : f:('a ‑> 'b ‑> bool) ‑> 'a list ‑> 'b list ‑> bool
val exists2 : f:('a ‑> 'b ‑> bool) ‑> 'a list ‑> 'b list ‑> bool
val mem : 'a ‑> set:'a list ‑> bool
val memq : 'a ‑> set:'a list ‑> bool
val find : f:('a ‑> bool) ‑> 'a list ‑> 'a
val find_opt : f:('a ‑> bool) ‑> 'a list ‑> 'a option
val filter : f:('a ‑> bool) ‑> 'a list ‑> 'a list
val find_all : f:('a ‑> bool) ‑> 'a list ‑> 'a list
val partition : f:('a ‑> bool) ‑> 'a list ‑> 'a list * 'a list
val assoc : 'a ‑> ('a * 'b) list ‑> 'b
val assoc_opt : 'a ‑> ('a * 'b) list ‑> 'b option
val assq : 'a ‑> ('a * 'b) list ‑> 'b
val assq_opt : 'a ‑> ('a * 'b) list ‑> 'b option
val mem_assoc : 'a ‑> map:('a * 'b) list ‑> bool
val mem_assq : 'a ‑> map:('a * 'b) list ‑> bool
val remove_assoc : 'a ‑> ('a * 'b) list ‑> ('a * 'b) list
val remove_assq : 'a ‑> ('a * 'b) list ‑> ('a * 'b) list
val split : ('a * 'b) list ‑> 'a list * 'b list
val combine : 'a list ‑> 'b list ‑> ('a * 'b) list
val sort : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a list
val stable_sort : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a list
val fast_sort : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a list
val sort_uniq : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a list
val merge : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a list ‑> 'a list
type 'a t = 'a list
val empty : 'a t

empty is .

val is_empty : _ t ‑> bool

is_empty l returns true iff l = [].

  • Since: 0.11
val map : f:('a ‑> 'b) ‑> 'a t ‑> 'b t

Safe version of List.map.

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

Infix version of map with reversed arguments.

  • Since: 0.5
val cons : 'a ‑> 'a t ‑> 'a t

cons x l is x::l.

  • Since: 0.12
val append : 'a t ‑> 'a t ‑> 'a t

Safe version of List.append. -Concatenate two lists.

val cons_maybe : 'a option ‑> 'a t ‑> 'a t

cons_maybe (Some x) l is x :: l. -cons_maybe None l is l.

  • Since: 0.13
val (@) : 'a t ‑> 'a t ‑> 'a t

Like append. -Concatenate two lists.

val filter : f:('a ‑> bool) ‑> 'a t ‑> 'a t

Safe version of List.filter. -filter p l returns all the elements of the list l -that satisfy the predicate p. The order of the elements -in the input list is preserved.

val fold_right : ('a ‑> 'b ‑> 'b) ‑> 'a t ‑> 'b ‑> 'b

Safe version of fold_right. -fold_right f [a1; ...; an] b is -f a1 (f a2 (... (f an b) ...)). Not tail-recursive.

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

Fold 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 list ‑> 'acc * 'b list

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

  • Since: 0.14
val fold_map2 : f:('acc ‑> 'a ‑> 'b ‑> 'acc * 'c) ‑> init:'acc ‑> 'a list ‑> 'b list ‑> 'acc * 'c list

fold_map2 is to fold_map what List.map2 is to List.map.

  • Raises Invalid_argument: if the lists do not have the same length.
  • Since: 0.16
val fold_filter_map : f:('acc ‑> 'a ‑> 'acc * 'b option) ‑> init:'acc ‑> 'a list ‑> 'acc * 'b list

fold_filter_map ~f ~init l is a fold_left-like function, but also -generates a list of output in a way similar to filter_map.

  • Since: 0.17
val fold_flat_map : f:('acc ‑> 'a ‑> 'acc * 'b list) ‑> init:'acc ‑> 'a list ‑> 'acc * 'b list

fold_flat_map f acc l is a fold_left-like function, but it also maps the -list to a list of lists that is then flatten'd.

  • Since: 0.14
val init : int ‑> f:(int ‑> 'a) ‑> 'a t

init len ~f is f 0; f 1; ...; f (len-1).

  • Raises Invalid_argument: if len < 0.
  • Since: 0.6
val compare : ('a ‑> 'a ‑> int) ‑> 'a t ‑> 'a t ‑> int
val equal : ('a ‑> 'a ‑> bool) ‑> 'a t ‑> 'a t ‑> bool
val flat_map : f:('a ‑> 'b t) ‑> 'a t ‑> 'b t

Map and flatten at the same time (safe). Evaluation order is not guaranteed.

val flatten : 'a t t ‑> 'a t

Safe flatten. Concatenate a list of lists.

val product : f:('a ‑> 'b ‑> 'c) ‑> 'a t ‑> 'b t ‑> 'c t

Cartesian product of the two lists, with the given combinator.

val fold_product : f:('c ‑> 'a ‑> 'b ‑> 'c) ‑> init:'c ‑> 'a t ‑> 'b t ‑> 'c

Fold on the cartesian product.

val diagonal : 'a t ‑> ('a * 'a) t

All pairs of distinct positions of the list. list_diagonal l will -return the list of List.nth i l, List.nth j l if i < j.

val partition_map : f:('a ‑> [< `Left of 'b | `Right of 'c | `Drop ]) ‑> 'a list ‑> 'b list * 'c list

partition_map ~f l maps f on l and gather results in lists: -

  • if f x = `Left y, adds y to the first list.
  • if f x = `Right z, adds z to the second list.
  • if f x = `Drop, ignores x.
  • Since: 0.11
val sublists_of_len : ?⁠last:('a list ‑> 'a list option) ‑> ?⁠offset:int ‑> len:int ‑> 'a list ‑> 'a list list

sublists_of_len n l returns sub-lists of l that have length n. -By default, these sub-lists are non overlapping: -sublists_of_len 2 [1;2;3;4;5;6] returns [1;2]; [3;4]; [5;6].

See CCList.sublists_of_len for more details.

  • Since: 1.5
val pure : 'a ‑> 'a t

pure is return.

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

funs <*> l is product fun f x -> f x) funs l.

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

(<$>) is map.

val return : 'a ‑> 'a t

return x is x.

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

l >>= f is flat_map f l.

val take : int ‑> 'a t ‑> 'a t

Take the n first elements, drop the rest.

val drop : int ‑> 'a t ‑> 'a t

Drop the n first elements, keep the rest.

val hd_tl : 'a t ‑> 'a * 'a t

hd_tl (x :: l) returns hd, l.

  • Raises Failure: if the list is empty.
  • Since: 0.16
val take_drop : int ‑> 'a t ‑> 'a t * 'a t

take_drop n l returns l1, l2 such that l1 @ l2 = l and -length l1 = min (length l) n.

val take_while : f:('a ‑> bool) ‑> 'a t ‑> 'a t

take_while ~f l returns the longest prefix of l for which f is true.

  • Since: 0.13
val drop_while : f:('a ‑> bool) ‑> 'a t ‑> 'a t

drop_while ~f l drops the longest prefix of l for which f is true.

  • Since: 0.13
val last : int ‑> 'a t ‑> 'a t

last n l takes the last n elements of l (or less if -l doesn't have that many elements.

val head_opt : 'a t ‑> 'a option

First element.

  • Since: 0.20
val tail_opt : 'a t ‑> 'a t option

Return the given list without its first element.

  • Since: 2.0
val last_opt : 'a t ‑> 'a option

Last element.

  • Since: 0.20
val find_pred : f:('a ‑> bool) ‑> 'a t ‑> 'a option

find_pred p l finds the first element of l that satisfies p, -or returns None if no element satisfies p.

  • Since: 0.11
val find_pred_exn : f:('a ‑> bool) ‑> 'a t ‑> 'a

Unsafe version of find_pred.

  • Raises Not_found: if no such element is found.
  • Since: 0.11
val find_map : f:('a ‑> 'b option) ‑> 'a t ‑> 'b option

find_map ~f l traverses l, applying f to each element. If for -some element x, f x = Some y, then Some y is returned. Otherwise -the call returns None.

  • Since: 0.11
val find_mapi : f:(int ‑> 'a ‑> 'b option) ‑> 'a t ‑> 'b option

Like find_map, but also pass the index to the predicate function.

  • Since: 0.11
val find_idx : f:('a ‑> bool) ‑> 'a t ‑> (int * 'a) option

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

val remove : eq:('a ‑> 'a ‑> bool) ‑> key:'a ‑> 'a t ‑> 'a t

remove ~key l removes every instance of key from l. Tail-recursive.

  • Parameter eq: equality function.
  • Since: 0.11
val filter_map : f:('a ‑> 'b option) ‑> 'a t ‑> 'b t

filter_map ~f l is the sublist of l containing only elements for which -f returns Some e. -Map and remove elements at the same time.

val sorted_merge : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a list ‑> 'a list

Merges elements from both sorted list.

val sort_uniq : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a list

Sort the list and remove duplicate elements.

val sorted_merge_uniq : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a list ‑> 'a list

sorted_merge_uniq l1 l2 merges the sorted lists l1 and l2 and -removes duplicates.

  • Since: 0.10
val is_sorted : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> bool

is_sorted l returns true iff l is sorted (according to given order).

  • Parameter cmp: the comparison function (default Pervasives.compare).
  • Since: 0.17
val sorted_insert : cmp:('a ‑> 'a ‑> int) ‑> ?⁠uniq:bool ‑> 'a ‑> 'a list ‑> 'a list

sorted_insert x l inserts x into l such that, if l was sorted, -then sorted_insert x l is sorted too.

  • Parameter uniq: if true and x is already in sorted position in l, then -x is not duplicated. Default false (x will be inserted in any case).
  • Since: 0.17
val uniq_succ : eq:('a ‑> 'a ‑> bool) ‑> 'a list ‑> 'a list

uniq_succ l removes duplicate elements that occur one next to the other. -Examples: -uniq_succ [1;2;1] = [1;2;1]. -uniq_succ [1;1;2] = [1;2].

  • Since: 0.10
val group_succ : eq:('a ‑> 'a ‑> bool) ‑> 'a list ‑> 'a list list

group_succ ~eq l groups together consecutive elements that are equal -according to eq.

  • Since: 0.11

Indices

val mapi : f:(int ‑> 'a ‑> 'b) ‑> 'a t ‑> 'b t

Like map, but the function is applied to the index of -the element as first argument (counting from 0), and the element -itself as second argument.

val iteri : f:(int ‑> 'a ‑> unit) ‑> 'a t ‑> unit

Like iter, but the function is applied to the index of -the element as first argument (counting from 0), and the element -itself as second argument.

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

Like fold but it also passes in the index of each element to the folded function. Tail-recursive.

val get_at_idx : int ‑> 'a t ‑> 'a option

Get by index in the list. -If the index is negative, it will get element starting from the end -of the list.

val get_at_idx_exn : int ‑> 'a t ‑> 'a

Get the i-th element, or

  • Raises Not_found: if the index is invalid. -If the index is negative, it will get element starting from the end -of the list.
val set_at_idx : int ‑> 'a ‑> 'a t ‑> 'a t

Set i-th element (removes the old one), or does nothing if -index is too high. -If the index is negative, it will set element starting from the end -of the list.

val insert_at_idx : int ‑> 'a ‑> 'a t ‑> 'a t

Insert at i-th position, between the two existing elements. If the -index is too high, append at the end of the list. -If the index is negative, it will insert element starting from the end -of the list.

val remove_at_idx : int ‑> 'a t ‑> 'a t

Remove element at given index. Does nothing if the index is -too high. -If the index is negative, it will remove element starting from the end -of the list.

Set Operators

Those operations maintain the invariant that the list does not -contain duplicates (if it already satisfies it).

val add_nodup : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> 'a t ‑> 'a t

add_nodup x set adds x to set if it was not already present. Linear time.

  • Since: 0.11
val remove_one : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> 'a t ‑> 'a t

remove_one x set removes one occurrence of x from set. Linear time.

  • Since: 0.11
val mem : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> 'a t ‑> bool

Membership to the list. Linear time.

val subset : eq:('a ‑> 'a ‑> bool) ‑> 'a t ‑> 'a t ‑> bool

Test for inclusion.

val uniq : eq:('a ‑> 'a ‑> bool) ‑> 'a t ‑> 'a t

Remove duplicates w.r.t the equality predicate. -Complexity is quadratic in the length of the list, but the order -of elements is preserved. If you wish for a faster de-duplication -but do not care about the order, use sort_uniq.

val union : eq:('a ‑> 'a ‑> bool) ‑> 'a t ‑> 'a t ‑> 'a t

List union. Complexity is product of length of inputs.

val inter : eq:('a ‑> 'a ‑> bool) ‑> 'a t ‑> 'a t ‑> 'a t

List intersection. Complexity is product of length of inputs.

Other Constructors

val range_by : step:int ‑> int ‑> int ‑> int t

range_by ~step i j iterates on integers from i to j included, -where the difference between successive elements is step. -use a negative step for a decreasing list.

  • Raises Invalid_argument: if step=0.
  • Since: 0.18
val range : int ‑> int ‑> int t

range i j iterates on integers from i to j included. It works -both for decreasing and increasing ranges.

val range' : int ‑> int ‑> int t

Like range but the second bound is excluded. -For instance range' 0 5 = [0;1;2;3;4].

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

Infix alias for range.

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

Infix alias for range'.

  • Since: 0.17
val replicate : int ‑> 'a ‑> 'a t

Replicate the given element n times.

val repeat : int ‑> 'a t ‑> 'a t

Concatenate the list with itself n times.

Association Lists

module Assoc : sig ... end
val assoc : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> ('a * 'b) t ‑> 'b

Like Assoc.get_exn.

  • Since: 2.0
val assoc_opt : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> ('a * 'b) t ‑> 'b option

Like Assoc.get.

  • Since: 2.0
val assq_opt : 'a ‑> ('a * 'b) t ‑> 'b option

Safe version of assq.

  • Since: 2.0
val mem_assoc : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> ('a * _) t ‑> bool

Like Assoc.mem.

  • Since: 2.0
val remove_assoc : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> ('a * 'b) t ‑> ('a * 'b) t

Like Assoc.remove.

  • Since: 2.0

References on Lists

module Ref : sig ... end
module type MONAD : sig ... end

Monadic Operations

module Traverse : functor (M : MONAD) -> sig ... end

Conversions

type 'a sequence = ('a ‑> unit) ‑> unit
type 'a gen = unit ‑> 'a option
type 'a klist = unit ‑> [ `Nil | `Cons of 'a * 'a klist ]
type 'a printer = Format.formatter ‑> 'a ‑> unit
type 'a random_gen = Random.State.t ‑> 'a
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
val random_choose : 'a t ‑> 'a random_gen

Randomly choose an element in the list.

  • Raises Not_found: if the list is empty.
val random_sequence : 'a random_gen t ‑> 'a t random_gen
val to_seq : 'a t ‑> 'a sequence

Return a sequence of the elements of the list.

val of_seq : 'a sequence ‑> 'a t

Build a list from a given sequence.

val to_gen : 'a t ‑> 'a gen

Return a gen of the elements of the list.

val of_gen : 'a gen ‑> 'a t

Build a list from a given gen.

val to_klist : 'a t ‑> 'a klist

Return a klist of the elements of the list.

val of_klist : 'a klist ‑> 'a t

Build a list from a given klist.

Infix Operators

-It is convenient to open CCList.Infix to access the infix operators -without cluttering the scope too much.

module Infix : sig ... end

IO

val pp : ?⁠start:string ‑> ?⁠stop:string ‑> ?⁠sep:string ‑> 'a printer ‑> 'a t printer

Print the contents of a list.

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

Module CCListLabels

Complements to list

type 'a sequence = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
type 'a klist = unit -> [ `Nil | `Cons of 'a * 'a klist ]
type 'a printer = Format.formatter -> 'a -> unit
type 'a random_gen = Random.State.t -> 'a
include module type of ListLabels
val length : 'a list -> int
val hd : 'a list -> 'a
val compare_lengths : 'a list -> 'b list -> int
val compare_length_with : 'a list -> len:int -> int
val cons : 'a -> 'a list -> 'a list
val tl : 'a list -> 'a list
val nth : 'a list -> int -> 'a
val nth_opt : 'a list -> int -> 'a option
val rev : 'a list -> 'a list
val init : len:int -> f:(int -> 'a) -> 'a list
val append : 'a list -> 'a list -> 'a list
val rev_append : 'a list -> 'a list -> 'a list
val concat : 'a list list -> 'a list
val flatten : 'a list list -> 'a list
val iter : f:('a -> unit) -> 'a list -> unit
val iteri : f:(int -> 'a -> unit) -> 'a list -> unit
val map : f:('a -> 'b) -> 'a list -> 'b list
val mapi : f:(int -> 'a -> 'b) -> 'a list -> 'b list
val rev_map : f:('a -> 'b) -> 'a list -> 'b list
val fold_left : f:('a -> 'b -> 'a) -> init:'a -> 'b list -> 'a
val fold_right : f:('a -> 'b -> 'b) -> 'a list -> init:'b -> 'b
val iter2 : f:('a -> 'b -> unit) -> 'a list -> 'b list -> unit
val map2 : f:('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
val rev_map2 : f:('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
val fold_left2 : f:('a -> 'b -> 'c -> 'a) -> init:'a -> 'b list -> 'c list -> 'a
val fold_right2 : f:('a -> 'b -> 'c -> 'c) -> 'a list -> 'b list -> init:'c -> 'c
val for_all : f:('a -> bool) -> 'a list -> bool
val exists : f:('a -> bool) -> 'a list -> bool
val for_all2 : f:('a -> 'b -> bool) -> 'a list -> 'b list -> bool
val exists2 : f:('a -> 'b -> bool) -> 'a list -> 'b list -> bool
val mem : 'a -> set:'a list -> bool
val memq : 'a -> set:'a list -> bool
val find : f:('a -> bool) -> 'a list -> 'a
val find_opt : f:('a -> bool) -> 'a list -> 'a option
val filter : f:('a -> bool) -> 'a list -> 'a list
val find_all : f:('a -> bool) -> 'a list -> 'a list
val partition : f:('a -> bool) -> 'a list -> 'a list * 'a list
val assoc : 'a -> ('a * 'b) list -> 'b
val assoc_opt : 'a -> ('a * 'b) list -> 'b option
val assq : 'a -> ('a * 'b) list -> 'b
val assq_opt : 'a -> ('a * 'b) list -> 'b option
val mem_assoc : 'a -> map:('a * 'b) list -> bool
val mem_assq : 'a -> map:('a * 'b) list -> bool
val remove_assoc : 'a -> ('a * 'b) list -> ('a * 'b) list
val remove_assq : 'a -> ('a * 'b) list -> ('a * 'b) list
val split : ('a * 'b) list -> 'a list * 'b list
val combine : 'a list -> 'b list -> ('a * 'b) list
val sort : cmp:('a -> 'a -> int) -> 'a list -> 'a list
val stable_sort : cmp:('a -> 'a -> int) -> 'a list -> 'a list
val fast_sort : cmp:('a -> 'a -> int) -> 'a list -> 'a list
val sort_uniq : cmp:('a -> 'a -> int) -> 'a list -> 'a list
val merge : cmp:('a -> 'a -> int) -> 'a list -> 'a list -> 'a list
type 'a t = 'a list
val empty : 'a t

empty is [].

val is_empty : _ t -> bool

is_empty l returns true iff l = [].

since
0.11
val map : f:('a -> 'b) -> 'a t -> 'b t

Safe version of List.map.

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

Infix version of map with reversed arguments.

since
0.5
val cons : 'a -> 'a t -> 'a t

cons x l is x::l.

since
0.12
val append : 'a t -> 'a t -> 'a t

Safe version of List.append. Concatenate two lists.

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

cons_maybe (Some x) l is x :: l. cons_maybe None l is l.

since
0.13
val (@) : 'a t -> 'a t -> 'a t

Like append. Concatenate two lists.

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

Safe version of List.filter. filter p l returns all the elements of the list l that satisfy the predicate p. The order of the elements in the input list is preserved.

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

Safe version of fold_right. fold_right f [a1; ...; an] b is f a1 (f a2 (... (f an b) ...)).

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

Fold 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 list -> 'acc * 'b list

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

since
0.14
val scan_left : f:('acc -> 'a -> 'acc) -> init:'acc -> 'a list -> 'acc list

scan_left ~f ~init l returns the list [init; f init x0; f (f init x0) x1; ...] where x0, x1, etc. are the elements of l.

since
1.2, but only
since
2.2 with labels
val fold_map2 : f:('acc -> 'a -> 'b -> 'acc * 'c) -> init:'acc -> 'a list -> 'b list -> 'acc * 'c list

fold_map2 is to fold_map what List.map2 is to List.map.

raises Invalid_argument

if the lists do not have the same length.

since
0.16
val fold_filter_map : f:('acc -> 'a -> 'acc * 'b option) -> init:'acc -> 'a list -> 'acc * 'b list

fold_filter_map ~f ~init l is a fold_left-like function, but also generates a list of output in a way similar to filter_map.

since
0.17
val fold_flat_map : f:('acc -> 'a -> 'acc * 'b list) -> init:'acc -> 'a list -> 'acc * 'b list

fold_flat_map f acc l is a fold_left-like function, but it also maps the list to a list of lists that is then flatten'd.

since
0.14
val count : f:('a -> bool) -> 'a list -> int

count p l counts how many elements of l satisfy predicate p.

since
1.5, but only
since
2.2 with labels
val count_true_false : f:('a -> bool) -> 'a list -> int * int
since
2.4
val init : int -> f:(int -> 'a) -> 'a t

init len ~f is f 0; f 1; ...; f (len-1).

raises Invalid_argument

if len < 0.

since
0.6
val combine : 'a list -> 'b list -> ('a * 'b) list

Like List.combine but tail-recursive. Transform a pair of lists into a list of pairs: combine [a1; ...; an] [b1; ...; bn] is [(a1,b1); ...; (an,bn)].

raises Invalid_argument

if the lists have distinct lengths.

since
1.2, but only
since
2.2 with labels
val combine_gen : 'a list -> 'b list -> ('a * 'b) gen

Lazy version of combine. Unlike combine, it does not fail if the lists have different lengths; instead, the output has as many pairs as the smallest input list.

since
1.2, but only
since
2.2 with labels
val split : ('a * 'b) t -> 'a t * 'b t

A tail-recursive version of List.split. Transform a list of pairs into a pair of lists: split [(a1,b1); ...; (an,bn)] is ([a1; ...; an], [b1; ...; bn]).

since
1.2, but only
since
2.2 with labels
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
val compare_lengths : 'a t -> 'b t -> int

Equivalent to compare (length l1) (length l2) but more efficient. Compare the lengths of two lists.

since
1.5, but only
since
2.2 with labels
val compare_length_with : 'a t -> int -> int

Equivalent to compare (length l) x but more efficient. Compare the length of a list to an integer.

since
1.5, but only
since
2.2 with labels
val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
val flat_map : f:('a -> 'b t) -> 'a t -> 'b t

Map and flatten at the same time (safe). Evaluation order is not guaranteed.

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

Safe flatten. Concatenate a list of lists.

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

Cartesian product of the two lists, with the given combinator.

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

Fold on the cartesian product.

val cartesian_product : 'a t t -> 'a t t

Produce the cartesian product of this list of lists, by returning all the ways of picking one element per sublist. NOTE the order of the returned list is unspecified. For example:

# cartesian_product [[1;2];[3];[4;5;6]] |> sort =
+[[1;3;4];[1;3;5];[1;3;6];[2;3;4];[2;3;5];[2;3;6]];;
+# cartesian_product [[1;2];[];[4;5;6]] = [];;
+# cartesian_product [[1;2];[3];[4];[5];[6]] |> sort =
+[[1;3;4;5;6];[2;3;4;5;6]];;

invariant: cartesian_product l = map_product id l.

since
1.2, but only
since
2.2 with labels
val map_product_l : f:('a -> 'b list) -> 'a list -> 'b list list

map_product_l f l maps each element of l to a list of objects of type 'b using f. We obtain [l1;l2;...;ln] where length l=n and li : 'b list. Then, it returns all the ways of picking exactly one element per li.

since
1.2, but only
since
2.2 with labels
val diagonal : 'a t -> ('a * 'a) t

All pairs of distinct positions of the list. list_diagonal l will return the list of List.nth i l, List.nth j l if i < j.

val partition_map : f:('a -> [< `Left of 'b | `Right of 'c | `Drop ]) -> 'a list -> 'b list * 'c list

partition_map ~f l maps f on l and gather results in lists:

  • if f x = `Left y, adds y to the first list.
  • if f x = `Right z, adds z to the second list.
  • if f x = `Drop, ignores x.
since
0.11
val group_by : ?⁠hash:('a -> int) -> ?⁠eq:('a -> 'a -> bool) -> 'a t -> 'a list t

Group equal elements, regardless of their order of appearance. precondition: for any x and y, if eq x y then hash x=hash y must hold.

since
2.3
val join : join_row:('a -> 'b -> 'c option) -> 'a t -> 'b t -> 'c t

join ~join_row a b combines every element of a with every element of b using join_row. If join_row returns None, then the two elements do not combine. Assume that b allows for multiple iterations.

since
2.3
val join_by : ?⁠eq:('key -> 'key -> bool) -> ?⁠hash:('key -> int) -> ('a -> 'key) -> ('b -> 'key) -> merge:('key -> 'a -> 'b -> 'c option) -> 'a t -> 'b t -> 'c t

join key1 key2 ~merge is a binary operation that takes two sequences a and b, projects their elements resp. with key1 and key2, and combine values (x,y) from (a,b) with the same key using merge. If merge returns None, the combination of values is discarded. precondition: for any x and y, if eq x y then hash x=hash y must hold.

since
2.3
val join_all_by : ?⁠eq:('key -> 'key -> bool) -> ?⁠hash:('key -> int) -> ('a -> 'key) -> ('b -> 'key) -> merge:('key -> 'a list -> 'b list -> 'c option) -> 'a t -> 'b t -> 'c t

join_all_by key1 key2 ~merge is a binary operation that takes two sequences a and b, projects their elements resp. with key1 and key2, and, for each key k occurring in at least one of them:

  • compute the list l1 of elements of a that map to k
  • compute the list l2 of elements of b that map to k
  • call merge k l1 l2. If merge returns None, the combination of values is discarded, otherwise it returns Some c and c is inserted in the result.
since
2.3
val group_join_by : ?⁠eq:('a -> 'a -> bool) -> ?⁠hash:('a -> int) -> ('b -> 'a) -> 'a t -> 'b t -> ('a * 'b list) t

group_join_by key2 associates to every element x of the first sequence, all the elements y of the second sequence such that eq x (key y). Elements of the first sequences without corresponding values in the second one are mapped to [] precondition: for any x and y, if eq x y then hash x=hash y must hold.

since
2.3
val sublists_of_len : ?⁠last:('a list -> 'a list option) -> ?⁠offset:int -> len:int -> 'a list -> 'a list list

sublists_of_len n l returns sub-lists of l that have length n. By default, these sub-lists are non overlapping: sublists_of_len 2 [1;2;3;4;5;6] returns [1;2]; [3;4]; [5;6].

Examples:

  • sublists_of_len 2 [1;2;3;4;5;6] = [[1;2]; [3;4]; [5;6]].
  • sublists_of_len 2 ~offset:3 [1;2;3;4;5;6] = [1;2];[4;5].
  • sublists_of_len 3 ~last:CCOpt.return [1;2;3;4] = [1;2;3];[4].
  • sublists_of_len 2 [1;2;3;4;5] = [[1;2]; [3;4]].
parameter offset

the number of elements skipped between two consecutive sub-lists. By default it is n. If offset < n, the sub-lists will overlap; if offset > n, some elements will not appear at all.

parameter last

if provided and the last group of elements g is such that length g < n, last g is called. If last g = Some g', g' is appended; otherwise g is dropped. If last = CCOpt.return, it will simply keep the last group. By default, last = fun _ -> None, i.e. the last group is dropped if shorter than n.

raises Invalid_argument

if offset <= 0 or n <= 0. See CCList.sublists_of_len for more details.

since
1.0, but only
since
1.5 with labels
val intersperse : x:'a -> 'a list -> 'a list

Insert the first argument between every element of the list.

since
2.1, but only
since
2.2 with labels
val interleave : 'a list -> 'a list -> 'a list

interleave [x1…xn] [y1…ym] is x1,y1,x2,y2,… and finishes with the suffix of the longest list.

since
2.1, but only
since
2.2 with labels
val pure : 'a -> 'a t

pure is return.

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

funs <*> l is product (fun f x -> f x) funs l.

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

(<$>) is map.

val return : 'a -> 'a t

return x is x.

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

l >>= f is flat_map f l.

val take : int -> 'a t -> 'a t

Take the n first elements, drop the rest.

val drop : int -> 'a t -> 'a t

Drop the n first elements, keep the rest.

val hd_tl : 'a t -> 'a * 'a t

hd_tl (x :: l) returns hd, l.

raises Failure

if the list is empty.

since
0.16
val take_drop : int -> 'a t -> 'a t * 'a t

take_drop n l returns l1, l2 such that l1 @ l2 = l and length l1 = min (length l) n.

val take_while : f:('a -> bool) -> 'a t -> 'a t

take_while ~f l returns the longest prefix of l for which f is true.

since
0.13
val drop_while : f:('a -> bool) -> 'a t -> 'a t

drop_while ~f l drops the longest prefix of l for which f is true.

since
0.13
val take_drop_while : f:('a -> bool) -> 'a t -> 'a t * 'a t

take_drop_while p l = take_while p l, drop_while p l.

since
1.2, but only
since
2.2 with labels
val last : int -> 'a t -> 'a t

last n l takes the last n elements of l (or less if l doesn't have that many elements).

val head_opt : 'a t -> 'a option

First element.

since
0.20
val tail_opt : 'a t -> 'a t option

Return the given list without its first element.

since
2.0
val last_opt : 'a t -> 'a option

Last element.

since
0.20
val find_pred : f:('a -> bool) -> 'a t -> 'a option

find_pred p l finds the first element of l that satisfies p, or returns None if no element satisfies p.

since
0.11
val find_opt : f:('a -> bool) -> 'a t -> 'a option

Safe version of find.

since
1.5, but only
since
2.2 with labels
val find_pred_exn : f:('a -> bool) -> 'a t -> 'a

Unsafe version of find_pred.

raises Not_found

if no such element is found.

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

find_map ~f l traverses l, applying f to each element. If for some element x, f x = Some y, then Some y is returned. Otherwise the call returns None.

since
0.11
val find_mapi : f:(int -> 'a -> 'b option) -> 'a t -> 'b option

Like find_map, but also pass the index to the predicate function.

since
0.11
val find_idx : f:('a -> bool) -> 'a t -> (int * 'a) option

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

val remove : eq:('a -> 'a -> bool) -> key:'a -> 'a t -> 'a t

remove ~key l removes every instance of key from l. Tail-recursive.

parameter eq

equality function.

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

filter_map ~f l is the sublist of l containing only elements for which f returns Some e. Map and remove elements at the same time.

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

keep_some l retains only elements of the form Some x. Like filter_map CCFun.id.

since
1.3, but only
since
2.2 with labels
val keep_ok : ('a_) Result.result t -> 'a t

keep_ok l retains only elements of the form Ok x.

since
1.3, but only
since
2.2 with labels
val all_some : 'a option t -> 'a t option

all_some l returns Some l' if all elements of l are of the form Some x, or None otherwise.

since
1.3, but only
since
2.2 with labels
val all_ok : ('a'err) Result.result t -> ('a t'err) Result.result

all_ok l returns Ok l' if all elements of l are of the form Ok x, or Error e otherwise (with the first error met).

since
1.3, but only
since
2.2 with labels
val sorted_merge : cmp:('a -> 'a -> int) -> 'a list -> 'a list -> 'a list

Merge elements from both sorted list.

val sort_uniq : cmp:('a -> 'a -> int) -> 'a list -> 'a list

Sort the list and remove duplicate elements.

val sorted_merge_uniq : cmp:('a -> 'a -> int) -> 'a list -> 'a list -> 'a list

sorted_merge_uniq l1 l2 merges the sorted lists l1 and l2 and removes duplicates.

since
0.10
val is_sorted : cmp:('a -> 'a -> int) -> 'a list -> bool

is_sorted l returns true iff l is sorted (according to given order).

parameter cmp

the comparison function (default Pervasives.compare).

since
0.17
val sorted_insert : cmp:('a -> 'a -> int) -> ?⁠uniq:bool -> 'a -> 'a list -> 'a list

sorted_insert x l inserts x into l such that, if l was sorted, then sorted_insert x l is sorted too.

parameter uniq

if true and x is already in sorted position in l, then x is not duplicated. Default false (x will be inserted in any case).

since
0.17
val uniq_succ : eq:('a -> 'a -> bool) -> 'a list -> 'a list

uniq_succ l removes duplicate elements that occur one next to the other. Examples: uniq_succ [1;2;1] = [1;2;1]. uniq_succ [1;1;2] = [1;2].

since
0.10
val group_succ : eq:('a -> 'a -> bool) -> 'a list -> 'a list list

group_succ ~eq l groups together consecutive elements that are equal according to eq.

since
0.11

Indices

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

Like map, but the function is applied to the index of the element as first argument (counting from 0), and the element itself as second argument.

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

Like iter, but the function is applied to the index of the element as first argument (counting from 0), and the element itself as second argument.

val iteri2 : f:(int -> 'a -> 'b -> unit) -> 'a t -> 'b t -> unit

Iter on two lists.

raises Invalid_argument

when lists do not have the same length.

since
2.0, but only
since
2.2 with labels
val foldi : f:('b -> int -> 'a -> 'b) -> init:'b -> 'a t -> 'b

Like fold but it also passes in the index of each element to the folded function. Tail-recursive.

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

Fold on two lists, with index.

raises Invalid_argument

when lists do not have the same length.

since
2.0, but only
since
2.2 with labels
val get_at_idx : int -> 'a t -> 'a option

Get by index in the list. If the index is negative, it will get element starting from the end of the list.

val nth_opt : 'a t -> int -> 'a option

Safe version of nth.

raises Invalid_argument

if the int is negative.

since
1.5, but only
since
2.2 with labels
val get_at_idx_exn : int -> 'a t -> 'a

Get the i-th element, or

raises Not_found

if the index is invalid. If the index is negative, it will get element starting from the end of the list.

val set_at_idx : int -> 'a -> 'a t -> 'a t

Set i-th element (removes the old one), or does nothing if index is too high. If the index is negative, it will set element starting from the end of the list.

val insert_at_idx : int -> 'a -> 'a t -> 'a t

Insert at i-th position, between the two existing elements. If the index is too high, append at the end of the list. If the index is negative, it will insert element starting from the end of the list.

val remove_at_idx : int -> 'a t -> 'a t

Remove element at given index. Does nothing if the index is too high. If the index is negative, it will remove element starting from the end of the list.

Set Operators

Those operations maintain the invariant that the list does not contain duplicates (if it already satisfies it).

val add_nodup : eq:('a -> 'a -> bool) -> 'a -> 'a t -> 'a t

add_nodup x set adds x to set if it was not already present. Linear time.

since
0.11
val remove_one : eq:('a -> 'a -> bool) -> 'a -> 'a t -> 'a t

remove_one x set removes one occurrence of x from set. Linear time.

since
0.11
val mem : eq:('a -> 'a -> bool) -> 'a -> 'a t -> bool

Membership to the list. Linear time.

val subset : eq:('a -> 'a -> bool) -> 'a t -> 'a t -> bool

Test for inclusion.

val uniq : eq:('a -> 'a -> bool) -> 'a t -> 'a t

Remove duplicates w.r.t the equality predicate. Complexity is quadratic in the length of the list, but the order of elements is preserved. If you wish for a faster de-duplication but do not care about the order, use sort_uniq.

val union : eq:('a -> 'a -> bool) -> 'a t -> 'a t -> 'a t

List union. Complexity is product of length of inputs.

val inter : eq:('a -> 'a -> bool) -> 'a t -> 'a t -> 'a t

List intersection. Complexity is product of length of inputs.

Other Constructors

val range_by : step:int -> int -> int -> int t

range_by ~step i j iterates on integers from i to j included, where the difference between successive elements is step. Use a negative step for a decreasing list.

raises Invalid_argument

if step=0.

since
0.18
val range : int -> int -> int t

range i j iterates on integers from i to j included. It works both for decreasing and increasing ranges.

val range' : int -> int -> int t

Like range but the second bound is excluded. For instance range' 0 5 = [0;1;2;3;4].

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

Infix alias for range.

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

Infix alias for range'.

since
0.17
val replicate : int -> 'a -> 'a t

Replicate the given element n times.

val repeat : int -> 'a t -> 'a t

Concatenate the list with itself n times.

Association Lists

module Assoc : sig ... end
val assoc : eq:('a -> 'a -> bool) -> 'a -> ('a * 'b) t -> 'b

Like Assoc.get_exn.

since
2.0
val assoc_opt : eq:('a -> 'a -> bool) -> 'a -> ('a * 'b) t -> 'b option

Like Assoc.get.

since
1.5, but only
since
2.0 with labels
val assq_opt : 'a -> ('a * 'b) t -> 'b option

Safe version of assq.

since
1.5, but only
since
2.0 with labels
val mem_assoc : eq:('a -> 'a -> bool) -> 'a -> ('a * _) t -> bool

Like Assoc.mem.

since
2.0
val remove_assoc : eq:('a -> 'a -> bool) -> 'a -> ('a * 'b) t -> ('a * 'b) t

Like Assoc.remove.

since
2.0

References on Lists

since
0.3.3
module Ref : sig ... end
module type MONAD = sig ... end
module Traverse : functor (M : MONAD) -> sig ... end

Conversions

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
val random_choose : 'a t -> 'a random_gen

Randomly choose an element in the list.

raises Not_found

if the list is empty.

val random_sequence : 'a random_gen t -> 'a t random_gen
val to_seq : 'a t -> 'a sequence

Return a sequence of the elements of the list.

val of_seq : 'a sequence -> 'a t

Build a list from a given sequence. In the result, elements appear in the same order as they did in the source sequence.

val to_gen : 'a t -> 'a gen

Return a gen of the elements of the list.

val of_gen : 'a gen -> 'a t

Build a list from a given gen. In the result, elements appear in the same order as they did in the source gen.

val to_klist : 'a t -> 'a klist

Return a klist of the elements of the list.

val of_klist : 'a klist -> 'a t

Build a list from a given klist. In the result, elements appear in the same order as they did in the source klist.

Infix Operators

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

since
0.16
module Infix : sig ... end

IO

val pp : ?⁠start:string -> ?⁠stop:string -> ?⁠sep:string -> 'a printer -> 'a t printer

Print the contents of a list.

\ No newline at end of file diff --git a/dev/containers/CCListLabels/module-type-MONAD/index.html b/dev/containers/CCListLabels/module-type-MONAD/index.html index c74a4bba..f5bf114c 100644 --- a/dev/containers/CCListLabels/module-type-MONAD/index.html +++ b/dev/containers/CCListLabels/module-type-MONAD/index.html @@ -1,2 +1,2 @@ -MONAD (containers.CCListLabels.MONAD)

Module type CCListLabels.MONAD

Monadic Operations

type 'a t
val return : 'a ‑> 'a t

Monadic return.

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

Monadic bind.

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

Module type CCListLabels.MONAD

Monadic Operations

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

Monadic return.

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

Monadic bind.

\ No newline at end of file diff --git a/dev/containers/CCMap/index.html b/dev/containers/CCMap/index.html index d5ee9cc9..a5c3e6f1 100644 --- a/dev/containers/CCMap/index.html +++ b/dev/containers/CCMap/index.html @@ -1,2 +1,2 @@ -CCMap (containers.CCMap)

Module CCMap

Extensions of Standard Map

Provide useful functions and iterators on Map.S

type 'a sequence = ('a ‑> unit) ‑> unit
type 'a printer = Format.formatter ‑> 'a ‑> unit
module type OrderedType = Map.OrderedType
module type S : sig ... end
module Make : functor (O : Map.OrderedType) -> S with type 'a Make.t = 'a Map.Make(O).t and type Make.key = O.t
\ No newline at end of file +CCMap (containers.CCMap)

Module CCMap

Extensions of Standard Map

Provide useful functions and iterators on Map.S

since
0.5
type 'a sequence = ('a -> unit) -> unit
type 'a printer = Format.formatter -> 'a -> unit
module type OrderedType = Map.OrderedType
module type S = sig ... end
module Make : functor (O : Map.OrderedType) -> S with type 'a Make.t = 'a Map.Make(O).t and type Make.key = O.t
\ No newline at end of file diff --git a/dev/containers/CCMap/module-type-S/index.html b/dev/containers/CCMap/module-type-S/index.html index 7b263117..a99cc629 100644 --- a/dev/containers/CCMap/module-type-S/index.html +++ b/dev/containers/CCMap/module-type-S/index.html @@ -1,10 +1,2 @@ -S (containers.CCMap.S)

Module type CCMap.S

include Map.S
type key
type +'a t
val empty : 'a t
val is_empty : 'a t ‑> bool
val mem : key ‑> 'a t ‑> bool
val add : key ‑> 'a ‑> 'a t ‑> 'a t
val update : key ‑> ('a option ‑> 'a option) ‑> 'a t ‑> 'a t
val singleton : key ‑> 'a ‑> 'a t
val remove : key ‑> 'a t ‑> 'a t
val merge : (key ‑> 'a option ‑> 'b option ‑> 'c option) ‑> 'a t ‑> 'b t ‑> 'c t
val union : (key ‑> 'a ‑> 'a ‑> 'a option) ‑> 'a t ‑> 'a t ‑> 'a t
val compare : ('a ‑> 'a ‑> int) ‑> 'a t ‑> 'a t ‑> int
val equal : ('a ‑> 'a ‑> bool) ‑> 'a t ‑> 'a t ‑> bool
val iter : (key ‑> 'a ‑> unit) ‑> 'a t ‑> unit
val fold : (key ‑> 'a ‑> 'b ‑> 'b) ‑> 'a t ‑> 'b ‑> 'b
val for_all : (key ‑> 'a ‑> bool) ‑> 'a t ‑> bool
val exists : (key ‑> 'a ‑> bool) ‑> 'a t ‑> bool
val filter : (key ‑> 'a ‑> bool) ‑> 'a t ‑> 'a t
val partition : (key ‑> 'a ‑> bool) ‑> 'a t ‑> 'a t * 'a t
val cardinal : 'a t ‑> int
val bindings : 'a t ‑> (key * 'a) list
val min_binding : 'a t ‑> key * 'a
val min_binding_opt : 'a t ‑> (key * 'a) option
val max_binding : 'a t ‑> key * 'a
val max_binding_opt : 'a t ‑> (key * 'a) option
val choose : 'a t ‑> key * 'a
val choose_opt : 'a t ‑> (key * 'a) option
val split : key ‑> 'a t ‑> 'a t * 'a option * 'a t
val find : key ‑> 'a t ‑> 'a
val find_opt : key ‑> 'a t ‑> 'a option
val find_first : (key ‑> bool) ‑> 'a t ‑> key * 'a
val find_first_opt : (key ‑> bool) ‑> 'a t ‑> (key * 'a) option
val find_last : (key ‑> bool) ‑> 'a t ‑> key * 'a
val find_last_opt : (key ‑> bool) ‑> 'a t ‑> (key * 'a) option
val map : ('a ‑> 'b) ‑> 'a t ‑> 'b t
val mapi : (key ‑> 'a ‑> 'b) ‑> 'a t ‑> 'b t
val get : key ‑> 'a t ‑> 'a option

Safe version of find.

val get_or : key ‑> 'a t ‑> default:'a ‑> 'a

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

  • Since: 0.16
val update : key ‑> ('a option ‑> 'a option) ‑> 'a t ‑> 'a t

update k f m calls f (Some v) if find k m = v, -otherwise it calls f None. In any case, if the result is Nonek is removed from m, and if the result is Some v' then -add k v' m is returned.

val choose_opt : 'a t ‑> (key * 'a) option

Safe version of choose.

  • Since: 1.5
val min_binding_opt : 'a t ‑> (key * 'a) option

Safe version of min_binding.

  • Since: 1.5
val max_binding_opt : 'a t ‑> (key * 'a) option

Safe version of max_binding.

  • Since: 1.5
val find_opt : key ‑> 'a t ‑> 'a option

Safe version of find.

  • Since: 1.5
val find_first : (key ‑> bool) ‑> 'a t ‑> key * 'a

Find smallest binding satisfying the monotonic predicate. -See Map.S.find_first.

  • Since: 1.5
val find_first_opt : (key ‑> bool) ‑> 'a t ‑> (key * 'a) option

Safe version of find_first.

  • Since: 1.5
val merge_safe : f:(key ‑> [ `Left of 'a | `Right of 'b | `Both of 'a * 'b ] ‑> 'c option) ‑> 'a t ‑> 'b t ‑> 'c t

merge_safe ~f a b merges the maps a and b together.

  • Since: 0.17
val union : (key ‑> 'a ‑> 'a ‑> 'a option) ‑> 'a t ‑> 'a t ‑> 'a t

Union of both maps, using the function to combine bindings -that belong to both inputs.

  • Since: 1.4
val of_seq : (key * 'a) sequence ‑> 'a t

Like of_list.

val add_seq : 'a t ‑> (key * 'a) sequence ‑> 'a t
  • Since: 0.14
val to_seq : 'a t ‑> (key * 'a) sequence
val of_list : (key * 'a) list ‑> 'a t

Build a map from the given list of bindings k_i -> v_i, -added in order using add. -If a key occurs several times, only its last binding -will be present in the result.

val add_list : 'a t ‑> (key * 'a) list ‑> 'a t
  • Since: 0.14
val keys : _ t ‑> key sequence

Iterate on keys only.

  • Since: 0.15
val values : 'a t ‑> 'a sequence

Iterate on values only.

  • Since: 0.15
val to_list : 'a t ‑> (key * 'a) list
val pp : ?⁠start:string ‑> ?⁠stop:string ‑> ?⁠arrow:string ‑> ?⁠sep:string ‑> key printer ‑> 'a printer ‑> 'a t printer
\ No newline at end of file +S (containers.CCMap.S)

Module type CCMap.S

include Map.S
type key
type +'a t
val empty : 'a t
val is_empty : 'a t -> bool
val mem : key -> 'a t -> bool
val add : key -> 'a -> 'a t -> 'a t
val update : key -> ('a option -> 'a option) -> 'a t -> 'a t
val singleton : key -> 'a -> 'a t
val remove : key -> 'a t -> 'a t
val merge : (key -> 'a option -> 'b option -> 'c option) -> 'a t -> 'b t -> 'c t
val union : (key -> 'a -> 'a -> 'a option) -> 'a t -> 'a t -> 'a t
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
val iter : (key -> 'a -> unit) -> 'a t -> unit
val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
val for_all : (key -> 'a -> bool) -> 'a t -> bool
val exists : (key -> 'a -> bool) -> 'a t -> bool
val filter : (key -> 'a -> bool) -> 'a t -> 'a t
val partition : (key -> 'a -> bool) -> 'a t -> 'a t * 'a t
val cardinal : 'a t -> int
val bindings : 'a t -> (key * 'a) list
val min_binding : 'a t -> key * 'a
val min_binding_opt : 'a t -> (key * 'a) option
val max_binding : 'a t -> key * 'a
val max_binding_opt : 'a t -> (key * 'a) option
val choose : 'a t -> key * 'a
val choose_opt : 'a t -> (key * 'a) option
val split : key -> 'a t -> 'a t * 'a option * 'a t
val find : key -> 'a t -> 'a
val find_opt : key -> 'a t -> 'a option
val find_first : (key -> bool) -> 'a t -> key * 'a
val find_first_opt : (key -> bool) -> 'a t -> (key * 'a) option
val find_last : (key -> bool) -> 'a t -> key * 'a
val find_last_opt : (key -> bool) -> 'a t -> (key * 'a) option
val map : ('a -> 'b) -> 'a t -> 'b t
val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t
val get : key -> 'a t -> 'a option

Safe version of find.

val get_or : key -> 'a t -> default:'a -> 'a

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

since
0.16
val update : key -> ('a option -> 'a option) -> 'a t -> 'a t

update k f m calls f (Some v) if find k m = v, otherwise it calls f None. In any case, if the result is None k is removed from m, and if the result is Some v' then add k v' m is returned.

val choose_opt : 'a t -> (key * 'a) option

Safe version of choose.

since
1.5
val min_binding_opt : 'a t -> (key * 'a) option

Safe version of min_binding.

since
1.5
val max_binding_opt : 'a t -> (key * 'a) option

Safe version of max_binding.

since
1.5
val find_opt : key -> 'a t -> 'a option

Safe version of find.

since
1.5
val find_first : (key -> bool) -> 'a t -> key * 'a

Find smallest binding satisfying the monotonic predicate. See Map.S.find_first.

since
1.5
val find_first_opt : (key -> bool) -> 'a t -> (key * 'a) option

Safe version of find_first.

since
1.5
val merge_safe : f:(key -> [ `Left of 'a | `Right of 'b | `Both of 'a * 'b ] -> 'c option) -> 'a t -> 'b t -> 'c t

merge_safe ~f a b merges the maps a and b together.

since
0.17
val union : (key -> 'a -> 'a -> 'a option) -> 'a t -> 'a t -> 'a t

Union of both maps, using the function to combine bindings that belong to both inputs.

since
1.4
val of_seq : (key * 'a) sequence -> 'a t

Like of_list.

val add_seq : 'a t -> (key * 'a) sequence -> 'a t
since
0.14
val to_seq : 'a t -> (key * 'a) sequence
val of_list : (key * 'a) list -> 'a t

Build a map from the given list of bindings k_i -> v_i, added in order using add. If a key occurs several times, only its last binding will be present in the result.

val add_list : 'a t -> (key * 'a) list -> 'a t
since
0.14
val keys : _ t -> key sequence

Iterate on keys only.

since
0.15
val values : 'a t -> 'a sequence

Iterate on values only.

since
0.15
val to_list : 'a t -> (key * 'a) list
val pp : ?⁠start:string -> ?⁠stop:string -> ?⁠arrow:string -> ?⁠sep:string -> key printer -> 'a printer -> 'a t printer
\ No newline at end of file diff --git a/dev/containers/CCNativeint/Infix/index.html b/dev/containers/CCNativeint/Infix/index.html index 48c1b56c..78750191 100644 --- a/dev/containers/CCNativeint/Infix/index.html +++ b/dev/containers/CCNativeint/Infix/index.html @@ -1,2 +1,2 @@ -Infix (containers.CCNativeint.Infix)

Module CCNativeint.Infix

val (+) : t ‑> t ‑> t
val (-) : t ‑> t ‑> t
val (~-) : t ‑> t
val (*) : t ‑> t ‑> t
val (/) : t ‑> t ‑> t
val (mod) : t ‑> t ‑> t
val (land) : t ‑> t ‑> t
val (lor) : t ‑> t ‑> t
val (lxor) : t ‑> t ‑> t
val (lnot) : t ‑> t
val (lsl) : t ‑> int ‑> t
val (lsr) : t ‑> int ‑> t
val (asr) : t ‑> int ‑> t
val (=) : t ‑> t ‑> bool
val (<>) : t ‑> t ‑> bool
val (>) : t ‑> t ‑> bool
val (>=) : t ‑> t ‑> bool
val (<=) : t ‑> t ‑> bool
val (<) : t ‑> t ‑> bool
\ No newline at end of file +Infix (containers.CCNativeint.Infix)

Module CCNativeint.Infix

val (+) : t -> t -> t
val (-) : t -> t -> t
val (~-) : t -> t
val (*) : t -> t -> t
val (/) : t -> t -> t
val (mod) : t -> t -> t
val (land) : t -> t -> t
val (lor) : t -> t -> t
val (lxor) : t -> t -> t
val (lnot) : t -> t
val (lsl) : t -> int -> t
val (lsr) : t -> int -> t
val (asr) : t -> int -> t
val (=) : t -> t -> bool
val (<>) : t -> t -> bool
val (>) : t -> t -> bool
val (>=) : t -> t -> bool
val (<=) : t -> t -> bool
val (<) : t -> t -> bool
\ No newline at end of file diff --git a/dev/containers/CCNativeint/index.html b/dev/containers/CCNativeint/index.html index 57ac31f8..3890d47f 100644 --- a/dev/containers/CCNativeint/index.html +++ b/dev/containers/CCNativeint/index.html @@ -1,40 +1,2 @@ -CCNativeint (containers.CCNativeint)

Module CCNativeint

Nativeint

Helpers for processor-native integers

This module provides operations on the type nativeint of signed 32-bit integers -(on 32-bit platforms) or signed 64-bit integers (on 64-bit platforms). -This integer type has exactly the same width as that of a pointer type in the C compiler. -All arithmetic operations over nativeint are taken modulo 232 or 264 depending -on the word size of the architecture.

Performance notice: values of type nativeint occupy more memory space than values of type int, -and arithmetic operations on nativeint are generally slower than those on int. -Use nativeint only when the application requires the extra bit of precision over the int type.

include module type of sig ... end
val zero : nativeint
val one : nativeint
val minus_one : nativeint
external neg : nativeint ‑> nativeint = "%nativeint_neg"
external add : nativeint ‑> nativeint ‑> nativeint = "%nativeint_add"
external sub : nativeint ‑> nativeint ‑> nativeint = "%nativeint_sub"
external mul : nativeint ‑> nativeint ‑> nativeint = "%nativeint_mul"
external div : nativeint ‑> nativeint ‑> nativeint = "%nativeint_div"
external rem : nativeint ‑> nativeint ‑> nativeint = "%nativeint_mod"
val succ : nativeint ‑> nativeint
val pred : nativeint ‑> nativeint
val abs : nativeint ‑> nativeint
val size : int
val max_int : nativeint
val min_int : nativeint
external logand : nativeint ‑> nativeint ‑> nativeint = "%nativeint_and"
external logor : nativeint ‑> nativeint ‑> nativeint = "%nativeint_or"
external logxor : nativeint ‑> nativeint ‑> nativeint = "%nativeint_xor"
val lognot : nativeint ‑> nativeint
external shift_left : nativeint ‑> int ‑> nativeint = "%nativeint_lsl"
external shift_right : nativeint ‑> int ‑> nativeint = "%nativeint_asr"
external shift_right_logical : nativeint ‑> int ‑> nativeint = "%nativeint_lsr"
external of_int : int ‑> nativeint = "%nativeint_of_int"
external to_int : nativeint ‑> int = "%nativeint_to_int"
external of_float : float ‑> nativeint = "caml_nativeint_of_float" "caml_nativeint_of_float_unboxed"
external to_float : nativeint ‑> float = "caml_nativeint_to_float" "caml_nativeint_to_float_unboxed"
external of_int32 : int32 ‑> nativeint = "%nativeint_of_int32"
external to_int32 : nativeint ‑> int32 = "%nativeint_to_int32"
external of_string : string ‑> nativeint = "caml_nativeint_of_string"
val of_string_opt : string ‑> nativeint option
val to_string : nativeint ‑> string
type t = nativeint
val compare : t ‑> t ‑> int
val equal : t ‑> t ‑> bool
external format : string ‑> nativeint ‑> string = "caml_nativeint_format"
val (+) : t ‑> t ‑> t

Addition.

val (-) : t ‑> t ‑> t

Subtraction.

val (~-) : t ‑> t

Unary negation.

val (*) : t ‑> t ‑> t

Multiplication.

val (/) : t ‑> t ‑> t

Integer division. Raise Division_by_zero if the second -argument is zero. This division rounds the real quotient of -its arguments towards zero, as specified for Pervasives.(/).

val (mod) : t ‑> t ‑> t

x mod y is the integer remainder. -If y <> zero, the result of x mod y satisfies the following properties: -zero <= x mod y < abs y and -x = ((x / y) * y) + (x mod y). -If y = 0, x mod y raises Division_by_zero.

val (land) : t ‑> t ‑> t

Bitwise logical and.

val (lor) : t ‑> t ‑> t

Bitwise logical or.

val (lxor) : t ‑> t ‑> t

Bitwise logical exclusive or.

val (lnot) : t ‑> t

Bitwise logical negation.

val (lsl) : t ‑> int ‑> t

x lsl y shifts x to the left by y bits. -The result is unspecified if y < 0 or y >= bitsize, where bitsize is 32 on a 32-bit platform -and 64 on a 64-bit platform.

val (lsr) : t ‑> int ‑> t

x lsr y shifts x to the right by y bits. -This is a logical shift: zeroes are inserted in the vacated bits -regardless of the sign of x. -The result is unspecified if y < 0 or y >= bitsize.

val (asr) : t ‑> int ‑> t

x asr y shifts x to the right by y bits. -This is an arithmetic shift: the sign bit of x is replicated -and inserted in the vacated bits. -The result is unspecified if y < 0 or y >= bitsize.

module Infix : sig ... end
val equal : t ‑> t ‑> bool

The equal function for native integers. -Like Pervasives.(=) x y).

val hash : t ‑> int

Like Pervasives.abs (to_int x).

Conversion

val to_int : t ‑> int

Convert the given native integer (type nativeint) to an -integer (type int). The high-order bit is lost -during the conversion.

val of_int : int ‑> t

Alias to Nativeint.of_int. -Convert the given integer (type int) to a native integer (type nativeint).

val to_float : t ‑> float

Convert the given native integer to a floating-point number.

val of_float : float ‑> t

Alias to Nativeint.of_float. -Convert the given floating-point number to a native integer, -discarding the fractional part (truncate towards 0). -The result of the conversion is undefined if, after truncation, the number -is outside the range [CCNativeint.min_int, CCNativeint.max_int].

val to_string : t ‑> string

Return the string representation of its argument, in decimal.

val of_string_exn : string ‑> t

Alias to Nativeint.of_string. -Convert the given string to a native integer. -The string is read in decimal (by default, or if the string -begins with 0u) or in hexadecimal, octal or binary if the -string begins with 0x, 0o or 0b respectively.

The 0u prefix reads the input as an unsigned integer in the range -[0, 2*CCNativeint.max_int+1]. If the input exceeds CCNativeint.max_int -it is converted to the signed integer -CCInt64.min_int + input - CCNativeint.max_int - 1.

Raise Failure "Nativeint.of_string" if the given string is not -a valid representation of an integer, or if the integer represented -exceeds the range of integers representable in type nativeint.

val of_string : string ‑> t option

Safe version of of_string_exn. -Like of_string_exn, but return None instead of raising.

val of_string_opt : string ‑> t option

Alias to of_string.

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

Module CCNativeint

Nativeint

Helpers for processor-native integers

This module provides operations on the type nativeint of signed 32-bit integers (on 32-bit platforms) or signed 64-bit integers (on 64-bit platforms). This integer type has exactly the same width as that of a pointer type in the C compiler. All arithmetic operations over nativeint are taken modulo 232 or 264 depending on the word size of the architecture.

Performance notice: values of type nativeint occupy more memory space than values of type int, and arithmetic operations on nativeint are generally slower than those on int. Use nativeint only when the application requires the extra bit of precision over the int type.

since
2.1
include module type of sig ... end
val zero : nativeint
val one : nativeint
val minus_one : nativeint
val neg : nativeint -> nativeint
val add : nativeint -> nativeint -> nativeint
val sub : nativeint -> nativeint -> nativeint
val mul : nativeint -> nativeint -> nativeint
val div : nativeint -> nativeint -> nativeint
val rem : nativeint -> nativeint -> nativeint
val succ : nativeint -> nativeint
val pred : nativeint -> nativeint
val abs : nativeint -> nativeint
val size : int
val max_int : nativeint
val min_int : nativeint
val logand : nativeint -> nativeint -> nativeint
val logor : nativeint -> nativeint -> nativeint
val logxor : nativeint -> nativeint -> nativeint
val lognot : nativeint -> nativeint
val shift_left : nativeint -> int -> nativeint
val shift_right : nativeint -> int -> nativeint
val shift_right_logical : nativeint -> int -> nativeint
val of_int : int -> nativeint
val to_int : nativeint -> int
val of_float : float -> nativeint
val to_float : nativeint -> float
val of_int32 : int32 -> nativeint
val to_int32 : nativeint -> int32
val of_string : string -> nativeint
val of_string_opt : string -> nativeint option
val to_string : nativeint -> string
type t = nativeint
val compare : t -> t -> int
val equal : t -> t -> bool
val format : string -> nativeint -> string
val (+) : t -> t -> t

Addition.

val (-) : t -> t -> t

Subtraction.

val (~-) : t -> t

Unary negation.

val (*) : t -> t -> t

Multiplication.

val (/) : t -> t -> t

Integer division. Raise Division_by_zero if the second argument is zero. This division rounds the real quotient of its arguments towards zero, as specified for Pervasives.(/).

val (mod) : t -> t -> t

x mod y is the integer remainder. If y <> zero, the result of x mod y satisfies the following properties: zero <= x mod y < abs y and x = ((x / y) * y) + (x mod y). If y = 0, x mod y raises Division_by_zero.

val (land) : t -> t -> t

Bitwise logical and.

val (lor) : t -> t -> t

Bitwise logical or.

val (lxor) : t -> t -> t

Bitwise logical exclusive or.

val (lnot) : t -> t

Bitwise logical negation.

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

x lsl y shifts x to the left by y bits. The result is unspecified if y < 0 or y >= bitsize, where bitsize is 32 on a 32-bit platform and 64 on a 64-bit platform.

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

x lsr y shifts x to the right by y bits. This is a logical shift: zeroes are inserted in the vacated bits regardless of the sign of x. The result is unspecified if y < 0 or y >= bitsize.

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

x asr y shifts x to the right by y bits. This is an arithmetic shift: the sign bit of x is replicated and inserted in the vacated bits. The result is unspecified if y < 0 or y >= bitsize.

module Infix : sig ... end
val equal : t -> t -> bool

The equal function for native integers. Like Pervasives.(=) x y).

val hash : t -> int

Like Pervasives.abs (to_int x).

Conversion

val to_int : t -> int

Convert the given native integer (type nativeint) to an integer (type int). The high-order bit is lost during the conversion.

val of_int : int -> t

Alias to Nativeint.of_int. Convert the given integer (type int) to a native integer (type nativeint).

val to_float : t -> float

Convert the given native integer to a floating-point number.

val of_float : float -> t

Alias to Nativeint.of_float. Convert the given floating-point number to a native integer, discarding the fractional part (truncate towards 0). The result of the conversion is undefined if, after truncation, the number is outside the range [CCNativeint.min_int, CCNativeint.max_int].

val to_string : t -> string

Return the string representation of its argument, in decimal.

val of_string_exn : string -> t

Alias to Nativeint.of_string. Convert the given string to a native integer. The string is read in decimal (by default, or if the string begins with 0u) or in hexadecimal, octal or binary if the string begins with 0x, 0o or 0b respectively.

The 0u prefix reads the input as an unsigned integer in the range [0, 2*CCNativeint.max_int+1]. If the input exceeds CCNativeint.max_int it is converted to the signed integer CCInt64.min_int + input - CCNativeint.max_int - 1.

Raise Failure "Nativeint.of_string" if the given string is not a valid representation of an integer, or if the integer represented exceeds the range of integers representable in type nativeint.

val of_string : string -> t option

Safe version of of_string_exn. Like of_string_exn, but return None instead of raising.

val of_string_opt : string -> t option

Alias to of_string.

\ No newline at end of file diff --git a/dev/containers/CCOpt/Infix/index.html b/dev/containers/CCOpt/Infix/index.html index ef52846b..9e7629ed 100644 --- a/dev/containers/CCOpt/Infix/index.html +++ b/dev/containers/CCOpt/Infix/index.html @@ -1,2 +1,2 @@ -Infix (containers.CCOpt.Infix)

Module CCOpt.Infix

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

x >|= f is map f x.

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

Monadic bind.

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

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

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

Like map.

val (<+>) : 'a t ‑> 'a t ‑> 'a t

a <+> b is a if a is Some _, b otherwise.

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

Module CCOpt.Infix

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

x >|= f is map f x.

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

Monadic bind.

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

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

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

Like map.

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

a <+> b is a if a is Some _, b otherwise.

\ No newline at end of file diff --git a/dev/containers/CCOpt/index.html b/dev/containers/CCOpt/index.html index 851cd7dc..294ad56d 100644 --- a/dev/containers/CCOpt/index.html +++ b/dev/containers/CCOpt/index.html @@ -1,10 +1,2 @@ -CCOpt (containers.CCOpt)

Module CCOpt

Options

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

Transform the element inside, if any.

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

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

  • Since: 0.16
val map_lazy : (unit ‑> 'b) ‑> ('a ‑> 'b) ‑> 'a t ‑> 'b

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

  • Since: 1.2
val is_some : _ t ‑> bool

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

val is_none : _ t ‑> bool

is_none None returns true otherwise it returns false.

  • Since: 0.11
val compare : ('a ‑> 'a ‑> int) ‑> 'a t ‑> 'a t ‑> int

Compare two options, using custom comparators for the value. -None is always assumed to be less than Some _.

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

Test for equality between option types using a custom equality predicat.

val return : 'a ‑> 'a t

Monadic return, that is return x = Some x.

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

Infix version of map.

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

Monadic bind.

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

Flip version of >>=.

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

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

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

Iterate on 0 or 1 element.

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

Fold on 0 or 1 element.

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

Filter on 0 or 1 element.

  • Since: 0.5
val if_ : ('a ‑> bool) ‑> 'a ‑> 'a option

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

  • Since: 0.17
val exists : ('a ‑> bool) ‑> 'a t ‑> bool

Return true iff there exists an element for which the provided function evaluates to true.

  • Since: 0.17
val for_all : ('a ‑> bool) ‑> 'a t ‑> bool

Return true iff the provided function evaluates to true for all elements.

  • Since: 0.17
val get_or : default:'a ‑> 'a t ‑> 'a

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

  • Since: 0.18
val get_exn : 'a t ‑> 'a

Open the option, possibly failing if it is None.

  • Raises Invalid_argument: if the option is None.
val get_lazy : (unit ‑> 'a) ‑> 'a t ‑> 'a

get_lazy default_fn x unwraps x, but if x = None it returns default_fn () instead.

  • Since: 0.6.1
val sequence_l : 'a t list ‑> 'a list t

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

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

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

  • Parameter handler: the exception handler, which returns true if the -exception is to be caught.
val wrap2 : ?⁠handler:(exn ‑> bool) ‑> ('a ‑> 'b ‑> 'c) ‑> 'a ‑> 'b ‑> 'c option

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

Applicative

val pure : 'a ‑> 'a t

Alias to return.

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

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

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

Like map.

Alternatives

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

or_ ~else_ a is a if a is Some _, else_ otherwise.

  • Since: 1.2
val or_lazy : else_:(unit ‑> 'a t) ‑> 'a t ‑> 'a t

or_lazy ~else_ a is a if a is Some _, else_ () otherwise.

  • Since: 1.2
val (<+>) : 'a t ‑> 'a t ‑> 'a t

a <+> b is a if a is Some _, b otherwise.

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

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

Infix Operators

module Infix : sig ... end

Conversion and IO

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

Head of list, or None.

val to_result : 'e ‑> 'a t ‑> ('a'e) Result.result
  • Since: 1.2
val to_result_lazy : (unit ‑> 'e) ‑> 'a t ‑> ('a'e) Result.result
  • Since: 1.2
val of_result : ('a_) Result.result ‑> 'a t
  • Since: 1.2
type 'a sequence = ('a ‑> unit) ‑> unit
type 'a gen = unit ‑> 'a option
type 'a printer = Format.formatter ‑> 'a ‑> unit
type 'a random_gen = Random.State.t ‑> 'a
val random : 'a random_gen ‑> 'a t random_gen
val choice_seq : 'a t sequence ‑> 'a t

choice_seq s is similar to choice, but works on sequences. -It returns the first Some x occurring in s, or None otherwise.

  • Since: 0.13
val to_gen : 'a t ‑> 'a gen
val to_seq : 'a t ‑> 'a sequence
val pp : 'a printer ‑> 'a t printer
\ No newline at end of file +CCOpt (containers.CCOpt)

Module CCOpt

Options

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

Transform the element inside, if any.

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

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

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

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

since
1.2
val is_some : _ t -> bool

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

val is_none : _ t -> bool

is_none None returns true otherwise it returns false.

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

Compare two options, using custom comparators for the value. None is always assumed to be less than Some _.

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

Test for equality between option types using a custom equality predicat.

val return : 'a -> 'a t

Monadic return, that is return x = Some x.

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

Infix version of map.

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

Monadic bind.

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

Flip version of >>=.

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

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

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

Iterate on 0 or 1 element.

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

Fold on 0 or 1 element.

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

Filter on 0 or 1 element.

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

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

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

Return true iff there exists an element for which the provided function evaluates to true.

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

Return true iff the provided function evaluates to true for all elements.

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

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

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

Open the option, possibly failing if it is None.

raises Invalid_argument

if the option is None.

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

get_lazy default_fn x unwraps x, but if x = None it returns default_fn () instead.

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

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

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

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

parameter handler

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

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

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

Applicative

val pure : 'a -> 'a t

Alias to return.

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

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

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

Like map.

Alternatives

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

or_ ~else_ a is a if a is Some _, else_ otherwise.

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

or_lazy ~else_ a is a if a is Some _, else_ () otherwise.

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

a <+> b is a if a is Some _, b otherwise.

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

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

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

flatten transforms Some x into x.

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

Apply Some or None depending on a boolean. More precisely, return_if false x is None, and return_if true x is Some x.

since
2.2

Infix Operators

since
0.16
module Infix : sig ... end

Conversion and IO

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

Head of list, or None.

val to_result : 'e -> 'a t -> ('a'e) Result.result
since
1.2
val to_result_lazy : (unit -> 'e) -> 'a t -> ('a'e) Result.result
since
1.2
val of_result : ('a_) Result.result -> 'a t
since
1.2
type 'a sequence = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
type 'a printer = Format.formatter -> 'a -> unit
type 'a random_gen = Random.State.t -> 'a
val random : 'a random_gen -> 'a t random_gen
val choice_seq : 'a t sequence -> 'a t

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

since
0.13
val to_gen : 'a t -> 'a gen
val to_seq : 'a t -> 'a sequence
val pp : 'a printer -> 'a t printer
\ No newline at end of file diff --git a/dev/containers/CCOrd/Infix/index.html b/dev/containers/CCOrd/Infix/index.html index 518312f2..c8488e04 100644 --- a/dev/containers/CCOrd/Infix/index.html +++ b/dev/containers/CCOrd/Infix/index.html @@ -1,4 +1,2 @@ -Infix (containers.CCOrd.Infix)

Module CCOrd.Infix

val (<?>) : int ‑> ('a t * 'a * 'a) ‑> int

c1 <?> (ord, x, y) returns the same as c1 if c1 is not 0; -otherwise it uses ord to compare the two values x and y, -of type 'a.

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

Infix equivalent of map.

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

Module CCOrd.Infix

val (<?>) : int -> ('a t * 'a * 'a) -> int

c1 <?> (ord, x, y) returns the same as c1 if c1 is not 0; otherwise it uses ord to compare the two values x and y, of type 'a.

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

Infix equivalent of map.

\ No newline at end of file diff --git a/dev/containers/CCOrd/index.html b/dev/containers/CCOrd/index.html index bf28fcc5..fd188628 100644 --- a/dev/containers/CCOrd/index.html +++ b/dev/containers/CCOrd/index.html @@ -1,15 +1,6 @@ -CCOrd (containers.CCOrd)

Module CCOrd

Comparisons

type 'a t = 'a ‑> 'a ‑> int

Comparison (total ordering) between two elements, that returns an int.

val compare : 'a t

Polymorphic "magic" comparison.

val opp : 'a t ‑> 'a t

Opposite order.

val equiv : int ‑> int ‑> bool

Returns true iff the two comparison results are the same.

val int : int t
val string : string t
val bool : bool t
val float : float t

Lexicographic Combination

val (<?>) : int ‑> ('a t * 'a * 'a) ‑> int

c1 <?> (ord, x, y) returns the same as c1 if c1 is not 0; -otherwise it uses ord to compare the two values x and y, -of type 'a.

Example: -

CCInt.compare 1 3
+CCOrd (containers.CCOrd)

Module CCOrd

Comparisons

type 'a t = 'a -> 'a -> int

Comparison (total ordering) between two elements, that returns an int.

val compare : 'a t

Polymorphic "magic" comparison.

val opp : 'a t -> 'a t

Opposite order.

val equiv : int -> int -> bool

Returns true iff the two comparison results are the same.

val int : int t
val string : string t
val bool : bool t
val float : float t

Lexicographic Combination

val (<?>) : int -> ('a t * 'a * 'a) -> int

c1 <?> (ord, x, y) returns the same as c1 if c1 is not 0; otherwise it uses ord to compare the two values x and y, of type 'a.

Example:

CCInt.compare 1 3
       <?> (String.compare, "a", "b")
-      <?> (CCBool.compare, true, false)

Same example, using only CCOrd:: -

CCOrd.(int 1 3
+      <?> (CCBool.compare, true, false)

Same example, using only CCOrd::

CCOrd.(int 1 3
         <?> (string, "a", "b")
-        <?> (bool, true, false))
val option : 'a t ‑> 'a option t

Comparison of optional values. None is smaller than any Some _.

  • Since: 0.15
val pair : 'a t ‑> 'b t ‑> ('a * 'b) t
val triple : 'a t ‑> 'b t ‑> 'c t ‑> ('a * 'b * 'c) t
val list : 'a t ‑> 'a list t

Lexicographic combination on lists.

val array : 'a t ‑> 'a array t
val map : ('a ‑> 'b) ‑> 'b t ‑> 'a t

map f ord is the comparison function that, given objects x and y, -projects x and y using f (e.g. using a record field) and then -compares those projections with ord. -Example: -map fst CCInt.compare compares values of type (int * 'a) by their -first component.

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

Infix equivalent of map.

module Infix : sig ... end
\ No newline at end of file + <?> (bool, true, false))
val option : 'a t -> 'a option t

Comparison of optional values. None is smaller than any Some _.

since
0.15
val pair : 'a t -> 'b t -> ('a * 'b) t
val triple : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t
val list : 'a t -> 'a list t

Lexicographic combination on lists.

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

map f ord is the comparison function that, given objects x and y, projects x and y using f (e.g. using a record field) and then compares those projections with ord. Example: map fst CCInt.compare compares values of type (int * 'a) by their first component.

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

Infix equivalent of map.

module Infix : sig ... end
\ No newline at end of file diff --git a/dev/containers/CCPair/index.html b/dev/containers/CCPair/index.html index e236b9aa..819a637d 100644 --- a/dev/containers/CCPair/index.html +++ b/dev/containers/CCPair/index.html @@ -1,4 +1,2 @@ -CCPair (containers.CCPair)

Module CCPair

Tuple Functions

type ('a, 'b) t = 'a * 'b
val make : 'a ‑> 'b ‑> ('a'bt

Make a tuple from its components.

  • Since: 0.16
val map1 : ('a ‑> 'b) ‑> ('a * 'c) ‑> 'b * 'c

map1 f (x, y) returns (f x, y).

val map2 : ('a ‑> 'b) ‑> ('c * 'a) ‑> 'c * 'b

map2 f (x, y) returns (x, f y).

val map : ('a ‑> 'c) ‑> ('b ‑> 'd) ‑> ('a * 'b) ‑> 'c * 'd

Synonym to ( *** ). Map on both sides of a tuple.

val map_same : ('a ‑> 'b) ‑> ('a * 'a) ‑> 'b * 'b

Like map but specialized for pairs with elements of the same type.

val map_fst : ('a ‑> 'b) ‑> ('a * _) ‑> 'b

Compose the given function with fst.

  • Since: 0.3.3
val map_snd : ('a ‑> 'b) ‑> (_ * 'a) ‑> 'b

Compose the given function with snd.

  • Since: 0.3.3
val iter : ('a ‑> 'b ‑> unit) ‑> ('a * 'b) ‑> unit
val swap : ('a * 'b) ‑> 'b * 'a

Swap the components of the tuple.

val (<<<) : ('a ‑> 'b) ‑> ('a * 'c) ‑> 'b * 'c

Map on the left side of the tuple.

val (>>>) : ('a ‑> 'b) ‑> ('c * 'a) ‑> 'c * 'b

Map on the right side of the tuple.

val (***) : ('a ‑> 'c) ‑> ('b ‑> 'd) ‑> ('a * 'b) ‑> 'c * 'd

Map on both sides of a tuple.

val (&&&) : ('a ‑> 'b) ‑> ('a ‑> 'c) ‑> 'a ‑> 'b * 'c

f &&& g is fun x -> f x, g x. It splits the computations into -two parts.

val merge : ('a ‑> 'b ‑> 'c) ‑> ('a * 'b) ‑> 'c

Uncurrying (merges the two components of a tuple).

val fold : ('a ‑> 'b ‑> 'c) ‑> ('a * 'b) ‑> 'c

Synonym to merge.

  • Since: 0.3.3
val dup : 'a ‑> 'a * 'a

dup x = (x,x) (duplicate the value).

  • Since: 0.3.3
val dup_map : ('a ‑> 'b) ‑> 'a ‑> 'a * 'b

dup_map f x = (x, f x). Duplicates the value and applies the function -to the second copy.

  • Since: 0.3.3
val equal : ('a ‑> 'a ‑> bool) ‑> ('b ‑> 'b ‑> bool) ‑> ('a * 'b) ‑> ('a * 'b) ‑> bool
val compare : ('a ‑> 'a ‑> int) ‑> ('b ‑> 'b ‑> int) ‑> ('a * 'b) ‑> ('a * 'b) ‑> int
type 'a printer = Format.formatter ‑> 'a ‑> unit
val pp : ?⁠sep:string ‑> 'a printer ‑> 'b printer ‑> ('a * 'b) printer

Print a pair given an optional separator and a method for printing each of its elements.

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

Module CCPair

Tuple Functions

type ('a, 'b) t = 'a * 'b
val make : 'a -> 'b -> ('a'b) t

Make a tuple from its components.

since
0.16
val map1 : ('a -> 'b) -> ('a * 'c) -> 'b * 'c

map1 f (x, y) returns (f x, y).

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

map2 f (x, y) returns (x, f y).

val map : ('a -> 'c) -> ('b -> 'd) -> ('a * 'b) -> 'c * 'd

Synonym to ( *** ). Map on both sides of a tuple.

val map_same : ('a -> 'b) -> ('a * 'a) -> 'b * 'b

Like map but specialized for pairs with elements of the same type.

val map_fst : ('a -> 'b) -> ('a * _) -> 'b

Compose the given function with fst.

since
0.3.3
val map_snd : ('a -> 'b) -> (_ * 'a) -> 'b

Compose the given function with snd.

since
0.3.3
val iter : ('a -> 'b -> unit) -> ('a * 'b) -> unit
val swap : ('a * 'b) -> 'b * 'a

Swap the components of the tuple.

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

Map on the left side of the tuple.

val (>>>) : ('a -> 'b) -> ('c * 'a) -> 'c * 'b

Map on the right side of the tuple.

val (***) : ('a -> 'c) -> ('b -> 'd) -> ('a * 'b) -> 'c * 'd

Map on both sides of a tuple.

val (&&&) : ('a -> 'b) -> ('a -> 'c) -> 'a -> 'b * 'c

f &&& g is fun x -> f x, g x. It splits the computations into two parts.

val merge : ('a -> 'b -> 'c) -> ('a * 'b) -> 'c

Uncurrying (merges the two components of a tuple).

val fold : ('a -> 'b -> 'c) -> ('a * 'b) -> 'c

Synonym to merge.

since
0.3.3
val dup : 'a -> 'a * 'a

dup x = (x,x) (duplicate the value).

since
0.3.3
val dup_map : ('a -> 'b) -> 'a -> 'a * 'b

dup_map f x = (x, f x). Duplicates the value and applies the function to the second copy.

since
0.3.3
val equal : ('a -> 'a -> bool) -> ('b -> 'b -> bool) -> ('a * 'b) -> ('a * 'b) -> bool
val compare : ('a -> 'a -> int) -> ('b -> 'b -> int) -> ('a * 'b) -> ('a * 'b) -> int
type 'a printer = Format.formatter -> 'a -> unit
val pp : ?⁠sep:string -> 'a printer -> 'b printer -> ('a * 'b) printer

Print a pair given an optional separator and a method for printing each of its elements.

\ No newline at end of file diff --git a/dev/containers/CCParse/Infix/index.html b/dev/containers/CCParse/Infix/index.html index 2db2c0dc..f0b62512 100644 --- a/dev/containers/CCParse/Infix/index.html +++ b/dev/containers/CCParse/Infix/index.html @@ -1,13 +1,2 @@ -Infix (containers.CCParse.Infix)

Module CCParse.Infix

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

Map.

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

Monadic bind. -p >>= f results in a new parser which behaves as p then, -in case of success, applies f to the result.

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

Applicative.

val (<*) : 'a t ‑> _ t ‑> 'a t

a <* b parses a into x, parses b and ignores its result, -and returns x.

val (*>) : _ t ‑> 'a t ‑> 'a t

a *> b parses a, then parses b into x, and returns x. The -results of a is ignored.

val (<|>) : 'a t ‑> 'a t ‑> 'a t

a <|> b tries to parse a, and if a fails without -consuming any input, backtracks and tries -to parse b, otherwise it fails as a. -See try_ to ensure a does not consume anything (but it is best -to avoid wrapping large parsers with try_).

val (<?>) : 'a t ‑> string ‑> 'a t

a <?> msg behaves like a, but if a fails without -consuming any input, it fails with msg -instead. Useful as the last choice in a series of <|>: -a <|> b <|> c <?> "expected a|b|c".

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

Module CCParse.Infix

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

Map.

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

Monadic bind. p >>= f results in a new parser which behaves as p then, in case of success, applies f to the result.

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

Applicative.

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

a <* b parses a into x, parses b and ignores its result, and returns x.

val (*>) : _ t -> 'a t -> 'a t

a *> b parses a, then parses b into x, and returns x. The results of a is ignored.

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

a <|> b tries to parse a, and if a fails without consuming any input, backtracks and tries to parse b, otherwise it fails as a. See try_ to ensure a does not consume anything (but it is best to avoid wrapping large parsers with try_).

val (<?>) : 'a t -> string -> 'a t

a <?> msg behaves like a, but if a fails without consuming any input, it fails with msg instead. Useful as the last choice in a series of <|>: a <|> b <|> c <?> "expected a|b|c".

\ No newline at end of file diff --git a/dev/containers/CCParse/U/index.html b/dev/containers/CCParse/U/index.html index 317eebba..02741176 100644 --- a/dev/containers/CCParse/U/index.html +++ b/dev/containers/CCParse/U/index.html @@ -1,6 +1,2 @@ -U (containers.CCParse.U)

Module CCParse.U

val list : ?⁠start:string ‑> ?⁠stop:string ‑> ?⁠sep:string ‑> 'a t ‑> 'a list t

list p parses a list of p, with the OCaml conventions for -start token "", stop token "" and separator ";". -Whitespace between items are skipped.

val int : int t

Parse an int.

val word : string t

Non empty string of alpha num, start with alpha.

val pair : ?⁠start:string ‑> ?⁠stop:string ‑> ?⁠sep:string ‑> 'a t ‑> 'b t ‑> ('a * 'b) t

Parse a pair using OCaml whitespace conventions. -The default is "(a, b)".

val triple : ?⁠start:string ‑> ?⁠stop:string ‑> ?⁠sep:string ‑> 'a t ‑> 'b t ‑> 'c t ‑> ('a * 'b * 'c) t

Parse a triple using OCaml whitespace conventions. -The default is "(a, b, c)".

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

Module CCParse.U

val list : ?⁠start:string -> ?⁠stop:string -> ?⁠sep:string -> 'a t -> 'a list t

list p parses a list of p, with the OCaml conventions for start token "", stop token "" and separator ";". Whitespace between items are skipped.

val int : int t

Parse an int.

val word : string t

Non empty string of alpha num, start with alpha.

val pair : ?⁠start:string -> ?⁠stop:string -> ?⁠sep:string -> 'a t -> 'b t -> ('a * 'b) t

Parse a pair using OCaml whitespace conventions. The default is "(a, b)".

val triple : ?⁠start:string -> ?⁠stop:string -> ?⁠sep:string -> 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t

Parse a triple using OCaml whitespace conventions. The default is "(a, b, c)".

\ No newline at end of file diff --git a/dev/containers/CCParse/index.html b/dev/containers/CCParse/index.html index 83bcba9e..69393570 100644 --- a/dev/containers/CCParse/index.html +++ b/dev/containers/CCParse/index.html @@ -1,51 +1,27 @@ -CCParse (containers.CCParse)

Module CCParse

Very Simple Parser Combinators

      open CCParse;;
+CCParse (containers.CCParse)

Module CCParse

Very Simple Parser Combinators

open CCParse;;
 
-      type tree = L of int | N of tree * tree;;
+type tree = L of int | N of tree * tree;;
 
-      let mk_leaf x = L x
-      let mk_node x y = N(x,y)
+let mk_leaf x = L x
+let mk_node x y = N(x,y)
 
-      let ptree = fix @@ fun self ->
-        skip_space *>
-          ( (try_ (char '(') *> (pure mk_node <*> self <*> self) <* char ')')
-            <|>
-              (U.int >|= mk_leaf) )
-      ;;
+let ptree = fix @@ fun self ->
+  skip_space *>
+    ( (try_ (char '(') *> (pure mk_node <*> self <*> self) <* char ')')
+      <|>
+        (U.int >|= mk_leaf) )
+;;
 
-      parse_string_exn ptree "(1 (2 3))" ;;
-      parse_string_exn ptree "((1 2) (3 (4 5)))" ;;
-
Parse a list of words
      open Containers.Parse;;
-      let p = U.list ~sep:"," U.word;;
-      parse_string_exn p "[abc , de, hello ,world  ]";;
Stress Test

-This makes a list of 100_000 integers, prints it and parses it back.

      let p = CCParse.(U.list ~sep:"," U.int);;
+parse_string_exn ptree "(1 (2 3))" ;;
+parse_string_exn ptree "((1 2) (3 (4 5)))" ;;
Parse a list of words
open Containers.Parse;;
+let p = U.list ~sep:"," U.word;;
+parse_string_exn p "[abc , de, hello ,world  ]";;
Stress Test

This makes a list of 100_000 integers, prints it and parses it back.

let p = CCParse.(U.list ~sep:"," U.int);;
 
-      let l = CCList.(1 -- 100_000);;
-      let l_printed =
-        CCFormat.(to_string (within "[" "]" (list ~sep:(return ",@,") int))) l;;
+let l = CCList.(1 -- 100_000);;
+let l_printed =
+  CCFormat.(to_string (within "[" "]" (list ~sep:(return ",@,") int))) l;;
 
-      let l' = CCParse.parse_string_exn p l_printed;;
+let l' = CCParse.parse_string_exn p l_printed;;
 
-      assert (l=l');;
type 'a or_error = ('a, string) Result.result
type line_num = int
type col_num = int
type parse_branch
val string_of_branch : parse_branch ‑> string
exception ParseError of parse_branch * unit ‑> string

parsing branch * message.

Input

type position
type state
val state_of_string : string ‑> state

Combinators

type 'a t = state ‑> ok:('a ‑> unit) ‑> err:(exn ‑> unit) ‑> unit

Takes the input and two continuations: -

  • ok to call with the result when it's done
  • err to call when the parser met an error
  • Raises ParseError: in case of failure.
val return : 'a ‑> 'a t

Always succeeds, without consuming its input.

val pure : 'a ‑> 'a t

Synonym to return.

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

Map.

val map : ('a ‑> 'b) ‑> 'a t ‑> 'b t
val map2 : ('a ‑> 'b ‑> 'c) ‑> 'a t ‑> 'b t ‑> 'c t
val map3 : ('a ‑> 'b ‑> 'c ‑> 'd) ‑> 'a t ‑> 'b t ‑> 'c t ‑> 'd t
val (>>=) : 'a t ‑> ('a ‑> 'b t) ‑> 'b t

Monadic bind. -p >>= f results in a new parser which behaves as p then, -in case of success, applies f to the result.

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

Applicative.

val (<*) : 'a t ‑> _ t ‑> 'a t

a <* b parses a into x, parses b and ignores its result, -and returns x.

val (*>) : _ t ‑> 'a t ‑> 'a t

a *> b parses a, then parses b into x, and returns x. The -results of a is ignored.

val fail : string ‑> 'a t

fail msg fails with the given message. It can trigger a backtrack.

val failf : ('a, unit, string, 'b t) Pervasives.format4 ‑> 'a

Format.sprintf version of fail.

val parsing : string ‑> 'a t ‑> 'a t

parsing s p behaves the same as p, with the information that -we are parsing s, if p fails.

val eoi : unit t

Expect the end of input, fails otherwise.

val nop : unit t

Succeed with ().

val char : char ‑> char t

char c parses the character c and nothing else.

val char_if : (char ‑> bool) ‑> char t

char_if f parses a character c if f c = true.

val chars_if : (char ‑> bool) ‑> string t

chars_if f parses a string of chars that satisfy f.

val chars1_if : (char ‑> bool) ‑> string t

Like chars_if, but only non-empty strings.

val endline : char t

Parses '\n'.

val space : char t

Tab or space.

val white : char t

Tab or space or newline.

val skip_chars : (char ‑> bool) ‑> unit t

Skip 0 or more chars satisfying the predicate.

val skip_space : unit t

Skip ' ' and '\t'.

val skip_white : unit t

Skip ' ' and '\t' and '\n'.

val is_alpha : char ‑> bool

Is the char a letter?

val is_num : char ‑> bool

Is the char a digit?

val is_alpha_num : char ‑> bool

Is the char a letter or a digit?

val is_space : char ‑> bool

True on ' ' and '\t'.

val is_white : char ‑> bool

True on ' ' and '\t' and '\n'.

val (<|>) : 'a t ‑> 'a t ‑> 'a t

a <|> b tries to parse a, and if a fails without -consuming any input, backtracks and tries -to parse b, otherwise it fails as a. -See try_ to ensure a does not consume anything (but it is best -to avoid wrapping large parsers with try_).

val (<?>) : 'a t ‑> string ‑> 'a t

a <?> msg behaves like a, but if a fails without -consuming any input, it fails with msg -instead. Useful as the last choice in a series of <|>: -a <|> b <|> c <?> "expected a|b|c".

val try_ : 'a t ‑> 'a t

try_ p tries to parse like p, but backtracks if p fails. -Useful in combination with <|>.

val suspend : (unit ‑> 'a t) ‑> 'a t

suspend f is the same as f (), but evaluates f () only -when needed.

val string : string ‑> string t

string s parses exactly the string s, and nothing else.

val many : 'a t ‑> 'a list t

many p parses a list of p, eagerly (as long as possible).

val many1 : 'a t ‑> 'a list t

Parse a non-empty list.

val skip : _ t ‑> unit t

skip p parses zero or more times p and ignores its result.

val sep : by:_ t ‑> 'a t ‑> 'a list t

sep ~by p parses a list of p separated by by.

val sep1 : by:_ t ‑> 'a t ‑> 'a list t

sep1 ~by p parses a non empty list of p, separated by by.

val fix : ('a t ‑> 'a t) ‑> 'a t

Fixpoint combinator.

val memo : 'a t ‑> 'a t

Memoize the parser. memo p will behave like p, but when called -in a state (read: position in input) it has already processed, memo p -returns a result directly. The implementation uses an underlying -hashtable. -This can be costly in memory, but improve the run time a lot if there -is a lot of backtracking involving p.

This function is not thread-safe.

val fix_memo : ('a t ‑> 'a t) ‑> 'a t

Like fix, but the fixpoint is memoized.

val get_lnum : int t

Reflect the current line number.

val get_cnum : int t

Reflect the current column number.

val get_pos : (int * int) t

Reflect the current (line, column) numbers.

Parse

Those functions have a label ~p on the parser, since 0.14.

val parse : 'a t ‑> state ‑> 'a or_error

parse p st applies p on the input, and returns Ok x if -p succeeds with x, or Error s otherwise.

val parse_exn : 'a t ‑> state ‑> 'a

Unsafe version of parse.

  • Raises ParseError: if it fails.
val parse_string : 'a t ‑> string ‑> 'a or_error

Specialization of parse for string inputs.

val parse_string_exn : 'a t ‑> string ‑> 'a
  • Raises ParseError: if it fails.
val parse_file : 'a t ‑> string ‑> 'a or_error

parse_file p file parses file with p by opening the file -and reading it whole.

val parse_file_exn : 'a t ‑> string ‑> 'a
  • Raises ParseError: if it fails.

Infix

module Infix : sig ... end

Utils

This is useful to parse OCaml-like values in a simple way.

module U : sig ... end
\ No newline at end of file +assert (l=l');;
type 'a or_error = ('a, string) Result.result
type line_num = int
type col_num = int
type parse_branch
val string_of_branch : parse_branch -> string
exception ParseError of parse_branch * unit -> string

parsing branch * message.

Input

type position
type state
val state_of_string : string -> state

Combinators

type 'a t = state -> ok:('a -> unit) -> err:(exn -> unit) -> unit

Takes the input and two continuations:

  • ok to call with the result when it's done
  • err to call when the parser met an error
raises ParseError

in case of failure.

val return : 'a -> 'a t

Always succeeds, without consuming its input.

val pure : 'a -> 'a t

Synonym to return.

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

Map.

val map : ('a -> 'b) -> 'a t -> 'b t
val map2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t
val map3 : ('a -> 'b -> 'c -> 'd) -> 'a t -> 'b t -> 'c t -> 'd t
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t

Monadic bind. p >>= f results in a new parser which behaves as p then, in case of success, applies f to the result.

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

Applicative.

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

a <* b parses a into x, parses b and ignores its result, and returns x.

val (*>) : _ t -> 'a t -> 'a t

a *> b parses a, then parses b into x, and returns x. The results of a is ignored.

val fail : string -> 'a t

fail msg fails with the given message. It can trigger a backtrack.

val failf : ('a, unit, string, 'b t) Pervasives.format4 -> 'a

Format.sprintf version of fail.

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

parsing s p behaves the same as p, with the information that we are parsing s, if p fails.

val eoi : unit t

Expect the end of input, fails otherwise.

val nop : unit t

Succeed with ().

val char : char -> char t

char c parses the character c and nothing else.

val char_if : (char -> bool) -> char t

char_if f parses a character c if f c = true.

val chars_if : (char -> bool) -> string t

chars_if f parses a string of chars that satisfy f.

val chars1_if : (char -> bool) -> string t

Like chars_if, but only non-empty strings.

val endline : char t

Parse '\n'.

val space : char t

Tab or space.

val white : char t

Tab or space or newline.

val skip_chars : (char -> bool) -> unit t

Skip 0 or more chars satisfying the predicate.

val skip_space : unit t

Skip ' ' and '\t'.

val skip_white : unit t

Skip ' ' and '\t' and '\n'.

val is_alpha : char -> bool

Is the char a letter?

val is_num : char -> bool

Is the char a digit?

val is_alpha_num : char -> bool

Is the char a letter or a digit?

val is_space : char -> bool

True on ' ' and '\t'.

val is_white : char -> bool

True on ' ' and '\t' and '\n'.

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

a <|> b tries to parse a, and if a fails without consuming any input, backtracks and tries to parse b, otherwise it fails as a. See try_ to ensure a does not consume anything (but it is best to avoid wrapping large parsers with try_).

val (<?>) : 'a t -> string -> 'a t

a <?> msg behaves like a, but if a fails without consuming any input, it fails with msg instead. Useful as the last choice in a series of <|>: a <|> b <|> c <?> "expected a|b|c".

val try_ : 'a t -> 'a t

try_ p tries to parse like p, but backtracks if p fails. Useful in combination with <|>.

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

suspend f is the same as f (), but evaluates f () only when needed.

val string : string -> string t

string s parses exactly the string s, and nothing else.

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

many p parses a list of p, eagerly (as long as possible).

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

Parse a non-empty list.

val skip : _ t -> unit t

skip p parses zero or more times p and ignores its result.

val sep : by:_ t -> 'a t -> 'a list t

sep ~by p parses a list of p separated by by.

val sep1 : by:_ t -> 'a t -> 'a list t

sep1 ~by p parses a non empty list of p, separated by by.

val fix : ('a t -> 'a t) -> 'a t

Fixpoint combinator.

val memo : 'a t -> 'a t

Memoize the parser. memo p will behave like p, but when called in a state (read: position in input) it has already processed, memo p returns a result directly. The implementation uses an underlying hashtable. This can be costly in memory, but improve the run time a lot if there is a lot of backtracking involving p.

This function is not thread-safe.

val fix_memo : ('a t -> 'a t) -> 'a t

Like fix, but the fixpoint is memoized.

val get_lnum : int t

Reflect the current line number.

val get_cnum : int t

Reflect the current column number.

val get_pos : (int * int) t

Reflect the current (line, column) numbers.

Parse

Those functions have a label ~p on the parser, since 0.14.

val parse : 'a t -> state -> 'a or_error

parse p st applies p on the input, and returns Ok x if p succeeds with x, or Error s otherwise.

val parse_exn : 'a t -> state -> 'a

Unsafe version of Parse.

raises ParseError

if it fails.

val parse_string : 'a t -> string -> 'a or_error

Specialization of Parse for string inputs.

val parse_string_exn : 'a t -> string -> 'a
raises ParseError

if it fails.

val parse_file : 'a t -> string -> 'a or_error

parse_file p file parses file with p by opening the file and reading it whole.

val parse_file_exn : 'a t -> string -> 'a
raises ParseError

if it fails.

Infix

module Infix : sig ... end

Utils

This is useful to parse OCaml-like values in a simple way.

module U : sig ... end
\ No newline at end of file diff --git a/dev/containers/CCRandom/index.html b/dev/containers/CCRandom/index.html index bd38ff55..5799fc3c 100644 --- a/dev/containers/CCRandom/index.html +++ b/dev/containers/CCRandom/index.html @@ -1,23 +1,7 @@ -CCRandom (containers.CCRandom)

Module CCRandom

Random Generators

include module type of sig ... end
val init : int ‑> unit
val full_init : int array ‑> unit
val self_init : unit ‑> unit
val bits : unit ‑> int
val int : int ‑> int
val int32 : Int32.t ‑> Int32.t
val nativeint : Nativeint.t ‑> Nativeint.t
val int64 : Int64.t ‑> Int64.t
val float : float ‑> float
val bool : unit ‑> bool
module State = Random.State
val get_state : unit ‑> State.t
val set_state : State.t ‑> unit
type state = 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 sig ... end
val init : int -> unit
val full_init : int array -> unit
val self_init : unit -> unit
val bits : unit -> int
val int : int -> int
val int32 : Int32.t -> Int32.t
val nativeint : Nativeint.t -> Nativeint.t
val int64 : Int64.t -> Int64.t
val float : float -> float
val bool : unit -> bool
module State = Random.State
val get_state : unit -> State.t
val set_state : State.t -> unit
type state = 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
-        small_int >>= fun i -> return (name,i)
-      )
  • Since: 0.4
val choose : 'a t list ‑> 'a option t

Choose a generator within the list.

val choose_exn : 'a t list ‑> 'a t

Like choose but without option.

  • Raises Invalid_argument: if the list is empty.
val choose_array : 'a t array ‑> 'a option t

Choose a generator within the array.

val choose_return : 'a list ‑> 'a t

Choose among the list.

  • Raises Invalid_argument: if the list is empty.
val replicate : int ‑> 'a t ‑> 'a list t

replicate n g makes a list of n elements which are all generated -randomly using g.

val sample_without_replacement : compare:('a ‑> 'a ‑> int) ‑> int ‑> 'a t ‑> 'a list t

sample_without_replacement n g makes a list of n elements which are all -generated randomly using g with the added constraint that none of the generated -random values are equal.

  • Raises Invalid_argument: if n <= 0.
  • Since: 0.15
val list_seq : 'a t list ‑> 'a list t

Build random lists from lists of random generators.

  • Since: 0.4
exception Pick_from_empty
  • Since: 0.16
val pick_list : 'a list ‑> 'a t

Pick an element at random from the list.

  • Raises Pick_from_empty: if the list is empty.
  • Since: 0.16
val pick_array : 'a array ‑> 'a t

Pick an element at random from the array.

  • Raises Pick_from_empty: if the array is empty.
  • Since: 0.16
val small_int : int t

A small int (100).

val int : int ‑> int t

Random int within the given range.

val int_range : int ‑> int ‑> int t

Inclusive range.

val small_float : float t

A reasonably small float (100.0).

  • Since: 0.6.1
val float : float ‑> float t

Random float within the given range.

  • Since: 0.6.1
val float_range : float ‑> float ‑> float t

Inclusive range. float_range a b assumes a < b.

  • Since: 0.6.1
val split : int ‑> (int * int) option t

Split a positive value n into n1,n2 where n = n1 + n2.

  • Returns None if the value is too small.
val split_list : int ‑> len:int ‑> int list option t

Split a value n into a list of values whose sum is n -and whose length is length. The list is never empty and does not -contain 0.

  • Raises Invalid_argument: if len <= 1.
  • Returns None if the value is too small.
val retry : ?⁠max:int ‑> 'a option t ‑> 'a option t

retry g calls g until it returns some value, or until the maximum -number of retries was reached. If g fails, -then it counts for one iteration, and the generator retries.

  • Parameter max: : maximum number of retries. Default 10.
val try_successively : 'a option t list ‑> 'a option t

try_successively l tries each generator of l, one after the other. -If some generator succeeds its result is returned, else the -next generator is tried.

val (<?>) : 'a option t ‑> 'a option t ‑> 'a option t

a <?> b is a choice operator. It first tries a, and returns its -result if successful. If a fails, then b is returned.

val fix : ?⁠sub1:('a t ‑> 'a t) list ‑> ?⁠sub2:('a t ‑> 'a t ‑> 'a t) list ‑> ?⁠subn:(int t * ('a list t ‑> 'a t)) list ‑> base:'a t ‑> int t ‑> 'a t

Recursion combinators, for building recursive values. -The integer generator is used to provide fuel. The sub_ generators -should use their arguments only once!

  • Parameter sub1: cases that recurse on one value.
  • Parameter sub2: cases that use the recursive gen twice.
  • Parameter subn: cases that use a list of recursive cases.
Applicative
val pure : 'a ‑> 'a t
val (<*>) : ('a ‑> 'b) t ‑> 'a t ‑> 'b t
Run a generator
val run : ?⁠st:state ‑> 'a t ‑> 'a

Using a random state (possibly the one in argument) run a generator.

\ No newline at end of file +delay (fun () -> + let name = gensym() in + small_int >>= fun i -> return (name,i) +)
since
0.4
val choose : 'a t list -> 'a option t

Choose a generator within the list.

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

Like choose but without option.

raises Invalid_argument

if the list is empty.

val choose_array : 'a t array -> 'a option t

Choose a generator within the array.

val choose_return : 'a list -> 'a t

Choose among the list.

raises Invalid_argument

if the list is empty.

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

replicate n g makes a list of n elements which are all generated randomly using g.

val sample_without_replacement : compare:('a -> 'a -> int) -> int -> 'a t -> 'a list t

sample_without_replacement n g makes a list of n elements which are all generated randomly using g with the added constraint that none of the generated random values are equal.

deprecated

use sample_without_duplicates instead

raises Invalid_argument

if n <= 0.

since
0.15
val sample_without_duplicates : cmp:('a -> 'a -> int) -> int -> 'a t -> 'a list t

sample_without_replacement n g makes a list of n elements which are all generated randomly using g with the added constraint that none of the generated random values are equal.

raises Invalid_argument

if n <= 0.

since
2.4
val list_seq : 'a t list -> 'a list t

Build random lists from lists of random generators.

since
0.4
exception Pick_from_empty
since
0.16
val pick_list : 'a list -> 'a t

Pick an element at random from the list.

raises Pick_from_empty

if the list is empty.

since
0.16
val pick_array : 'a array -> 'a t

Pick an element at random from the array.

raises Pick_from_empty

if the array is empty.

since
0.16
val small_int : int t

A small int (100).

val int : int -> int t

Random int within the given range.

val int_range : int -> int -> int t

Inclusive range.

val small_float : float t

A reasonably small float (100.0).

since
0.6.1
val float : float -> float t

Random float within the given range.

since
0.6.1
val float_range : float -> float -> float t

Inclusive range. float_range a b assumes a < b.

since
0.6.1
val split : int -> (int * int) option t

Split a positive value n into n1,n2 where n = n1 + n2.

returns

None if the value is too small.

val split_list : int -> len:int -> int list option t

Split a value n into a list of values whose sum is n and whose length is length. The list is never empty and does not contain 0.

raises Invalid_argument

if len <= 1.

returns

None if the value is too small.

val retry : ?⁠max:int -> 'a option t -> 'a option t

retry g calls g until it returns some value, or until the maximum number of retries was reached. If g fails, then it counts for one iteration, and the generator retries.

parameter max:

maximum number of retries. Default 10.

val try_successively : 'a option t list -> 'a option t

try_successively l tries each generator of l, one after the other. If some generator succeeds its result is returned, else the next generator is tried.

val (<?>) : 'a option t -> 'a option t -> 'a option t

a <?> b is a choice operator. It first tries a, and returns its result if successful. If a fails, then b is returned.

val fix : ?⁠sub1:('a t -> 'a t) list -> ?⁠sub2:('a t -> 'a t -> 'a t) list -> ?⁠subn:(int t * ('a list t -> 'a t)) list -> base:'a t -> int t -> 'a t

Recursion combinators, for building recursive values. The integer generator is used to provide fuel. The sub_ generators should use their arguments only once!

parameter sub1

cases that recurse on one value.

parameter sub2

cases that use the recursive gen twice.

parameter subn

cases that use a list of recursive cases.

Applicative
val pure : 'a -> 'a t
val (<*>) : ('a -> 'b) t -> 'a t -> 'b t
Run a generator
val run : ?⁠st:state -> 'a t -> 'a

Using a random state (possibly the one in argument) run a generator.

\ No newline at end of file diff --git a/dev/containers/CCRef/index.html b/dev/containers/CCRef/index.html index f1787792..46894c23 100644 --- a/dev/containers/CCRef/index.html +++ b/dev/containers/CCRef/index.html @@ -1,2 +1,2 @@ -CCRef (containers.CCRef)

Module CCRef

References

type 'a printer = Format.formatter ‑> 'a ‑> unit
type 'a ord = 'a ‑> 'a ‑> int
type 'a eq = 'a ‑> 'a ‑> bool
type 'a sequence = ('a ‑> unit) ‑> unit
type 'a t = 'a Pervasives.ref
val map : ('a ‑> 'b) ‑> 'a t ‑> 'b t

Transform the value.

val create : 'a ‑> 'a t

Alias to ref.

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

Call the function on the content of the reference.

val update : ('a ‑> 'a) ‑> 'a t ‑> unit

Update the reference's content with the given function.

val incr_then_get : int t ‑> int

incr_then_get r increments r and returns its new value, think ++ r.

  • Since: 0.17
val get_then_incr : int t ‑> int

get_then_incr r increments r and returns its old value, think r++.

  • Since: 0.17
val swap : 'a t ‑> 'a t ‑> unit

swap t1 t2 puts !t2 in t1 and !t1 in t2.

  • Since: 1.4
val compare : 'a ord ‑> 'a t ord
val equal : 'a eq ‑> 'a t eq
val to_list : 'a t ‑> 'a list
val to_seq : 'a t ‑> 'a sequence
val pp : 'a printer ‑> 'a t printer
\ No newline at end of file +CCRef (containers.CCRef)

Module CCRef

References

since
0.9
type 'a printer = Format.formatter -> 'a -> unit
type 'a ord = 'a -> 'a -> int
type 'a eq = 'a -> 'a -> bool
type 'a sequence = ('a -> unit) -> unit
type 'a t = 'a Pervasives.ref
val map : ('a -> 'b) -> 'a t -> 'b t

Transform the value.

val create : 'a -> 'a t

Alias to ref.

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

Call the function on the content of the reference.

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

Update the reference's content with the given function.

val incr_then_get : int t -> int

incr_then_get r increments r and returns its new value, think ++r.

since
0.17
val get_then_incr : int t -> int

get_then_incr r increments r and returns its old value, think r++.

since
0.17
val swap : 'a t -> 'a t -> unit

swap t1 t2 puts !t2 in t1 and !t1 in t2.

since
1.4
val compare : 'a ord -> 'a t ord
val equal : 'a eq -> 'a t eq
val to_list : 'a t -> 'a list
val to_seq : 'a t -> 'a sequence
val pp : 'a printer -> 'a t printer
\ No newline at end of file diff --git a/dev/containers/CCResult/Infix/index.html b/dev/containers/CCResult/Infix/index.html index a6636cf7..3e0da1e9 100644 --- a/dev/containers/CCResult/Infix/index.html +++ b/dev/containers/CCResult/Infix/index.html @@ -1,5 +1,2 @@ -Infix (containers.CCResult.Infix)

Module CCResult.Infix

val (>|=) : ('a'errt ‑> ('a ‑> 'b) ‑> ('b'errt
val (>>=) : ('a'errt ‑> ('a ‑> ('b'errt) ‑> ('b'errt

Monadic composition. e >>= f proceeds as f x if e is Ok x -or returns e if e is an Error.

val (<*>) : ('a ‑> 'b'errt ‑> ('a'errt ‑> ('b'errt

a <*> b evaluates a and b, and, in case of success, returns -Ok (a b). Otherwise, it fails, and the error of a is chosen -over the error of b if both fail.

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

Module CCResult.Infix

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

Monadic composition. e >>= f proceeds as f x if e is Ok x or returns e if e is an Error.

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

a <*> b evaluates a and b, and, in case of success, returns Ok (a b). Otherwise, it fails, and the error of a is chosen over the error of b if both fail.

\ No newline at end of file diff --git a/dev/containers/CCResult/Traverse/argument-1-M/index.html b/dev/containers/CCResult/Traverse/argument-1-M/index.html index 63ae4079..cd198849 100644 --- a/dev/containers/CCResult/Traverse/argument-1-M/index.html +++ b/dev/containers/CCResult/Traverse/argument-1-M/index.html @@ -1,2 +1,2 @@ -1-M (containers.CCResult.Traverse.1-M)

Parameter CCResult.Traverse.1-M

type 'a t
val return : 'a ‑> 'a t

Monadic return.

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

Monadic bind.

\ No newline at end of file +1-M (containers.CCResult.Traverse.1-M)

Parameter Traverse.1-M

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

Monadic return.

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

Monadic bind.

\ No newline at end of file diff --git a/dev/containers/CCResult/Traverse/index.html b/dev/containers/CCResult/Traverse/index.html index 70819ccb..f455d5ab 100644 --- a/dev/containers/CCResult/Traverse/index.html +++ b/dev/containers/CCResult/Traverse/index.html @@ -1,2 +1,2 @@ -Traverse (containers.CCResult.Traverse)

Module CCResult.Traverse

Parameters

Signature

val sequence_m : ('a M.t'errt ‑> ('a'errt M.t
val fold_m : ('b ‑> 'a ‑> 'b M.t) ‑> 'b ‑> ('a'errt ‑> 'b M.t
val map_m : ('a ‑> 'b M.t) ‑> ('a'errt ‑> ('b'errt M.t
val retry_m : int ‑> (unit ‑> ('a'errt M.t) ‑> ('a'err list) t M.t
\ No newline at end of file +Traverse (containers.CCResult.Traverse)

Module CCResult.Traverse

Parameters

Signature

val sequence_m : ('a M.t'err) t -> ('a'err) t M.t
val fold_m : ('b -> 'a -> 'b M.t) -> 'b -> ('a'err) t -> 'b M.t
val map_m : ('a -> 'b M.t) -> ('a'err) t -> ('b'err) t M.t
val retry_m : int -> (unit -> ('a'err) t M.t) -> ('a'err list) t M.t
\ No newline at end of file diff --git a/dev/containers/CCResult/index.html b/dev/containers/CCResult/index.html index a1eecf7d..e9e24ddc 100644 --- a/dev/containers/CCResult/index.html +++ b/dev/containers/CCResult/index.html @@ -1,27 +1,2 @@ -CCResult (containers.CCResult)

Module CCResult

Error Monad

Uses the new "result" type from OCaml 4.03.

type 'a sequence = ('a ‑> unit) ‑> unit
type 'a equal = 'a ‑> 'a ‑> bool
type 'a ord = 'a ‑> 'a ‑> int
type 'a printer = Format.formatter ‑> 'a ‑> unit

Basics

  • Since: 1.5
include module type of sig ... end
type ('a, 'b) result = ('a'b) Pervasives.result =
| Ok of 'a
| Error of 'b
type (+'good, +'bad) t = ('good'bad) Result.result =
| Ok of 'good
| Error of 'bad
val return : 'a ‑> ('a'errt

Successfully return a value.

val fail : 'err ‑> ('a'errt

Fail with an error.

val of_exn : exn ‑> ('a, string) t

of_exn e uses Printexc to print the exception as a string.

val of_exn_trace : exn ‑> ('a, string) t

of_exn_trace e is similar to of_exn e, but it adds the stacktrace -to the error message.

Remember to call Printexc.record_backtrace true and compile with the -debug flag for this to work.

val fail_printf : ('a, Buffer.t, unit, ('b, string) t) Pervasives.format4 ‑> 'a

fail_printf format uses format to obtain an error message -and then returns Error msg.

val fail_fprintf : ('a, Format.formatter, unit, ('b, string) t) Pervasives.format4 ‑> 'a

fail_fprintf format uses format to obtain an error message -and then returns Error msg.

val add_ctx : string ‑> ('a, string) t ‑> ('a, string) t

add_ctx msg leaves Ok x untouched, but transforms -Error s into Error s' where s' contains the additional -context given by msg.

  • Since: 1.2
val add_ctxf : ('a, Format.formatter, unit, ('b, string) t ‑> ('b, string) t) Pervasives.format4 ‑> 'a

add_ctxf format_message is similar to add_ctx but with -Format for printing the message (eagerly). -Example:

      add_ctxf "message(number %d, foo: %B)" 42 true (Error "error)"
  • Since: 1.2
val map : ('a ‑> 'b) ‑> ('a'errt ‑> ('b'errt

Map on success.

val map_err : ('err1 ‑> 'err2) ‑> ('a'err1t ‑> ('a'err2t

Map on the error variant.

val map2 : ('a ‑> 'b) ‑> ('err1 ‑> 'err2) ‑> ('a'err1t ‑> ('b'err2t

Like map, but also with a function that can transform -the error message in case of failure.

val iter : ('a ‑> unit) ‑> ('a_t ‑> unit

Apply the function only in case of Ok.

exception Get_error
val get_exn : ('a_t ‑> 'a

Extract the value x from Ok x, fails otherwise. -You should be careful with this function, and favor other combinators -whenever possible.

  • Raises Get_error: if the value is an error.
val get_or : ('a_t ‑> default:'a ‑> 'a

get_or e ~default returns x if e = Ok x, default otherwise.

val map_or : ('a ‑> 'b) ‑> ('a'ct ‑> default:'b ‑> 'b

map_or f e ~default returns f x if e = Ok x, default otherwise.

val catch : ('a'errt ‑> ok:('a ‑> 'b) ‑> err:('err ‑> 'b) ‑> 'b

catch e ~ok ~err calls either ok or err depending on -the value of e.

val flat_map : ('a ‑> ('b'errt) ‑> ('a'errt ‑> ('b'errt
val (>|=) : ('a'errt ‑> ('a ‑> 'b) ‑> ('b'errt
val (>>=) : ('a'errt ‑> ('a ‑> ('b'errt) ‑> ('b'errt

Monadic composition. e >>= f proceeds as f x if e is Ok x -or returns e if e is an Error.

val equal : err:'err equal ‑> 'a equal ‑> ('a'errt equal
val compare : err:'err ord ‑> 'a ord ‑> ('a'errt ord
val fold : ok:('a ‑> 'b) ‑> error:('err ‑> 'b) ‑> ('a'errt ‑> 'b

fold ~ok ~error e opens e and, if e = Ok x, returns -ok x, otherwise e = Error s and it returns error s.

val fold_ok : ('a ‑> 'b ‑> 'a) ‑> 'a ‑> ('b_t ‑> 'a

fold_ok f acc r will compute f acc x if r=Ok x, -and return acc otherwise, as if the result were a mere option.

  • Since: 1.2
val is_ok : ('a'errt ‑> bool

Return true if Ok.

  • Since: 1.0
val is_error : ('a'errt ‑> bool

Return true if Error.

  • Since: 1.0

Wrappers

val guard : (unit ‑> 'a) ‑> ('a, exn) t

guard f runs f () and returns its result wrapped in Ok. If -f () raises some exception e, then it fails with Error e.

val guard_str : (unit ‑> 'a) ‑> ('a, string) t

Like guard but uses of_exn to print the exception.

val guard_str_trace : (unit ‑> 'a) ‑> ('a, string) t

Like guard_str but uses of_exn_trace instead of of_exn so -that the stack trace is printed.

val wrap1 : ('a ‑> 'b) ‑> 'a ‑> ('b, exn) t

Like guard but gives the function one argument.

val wrap2 : ('a ‑> 'b ‑> 'c) ‑> 'a ‑> 'b ‑> ('c, exn) t

Like guard but gives the function two arguments.

val wrap3 : ('a ‑> 'b ‑> 'c ‑> 'd) ‑> 'a ‑> 'b ‑> 'c ‑> ('d, exn) t

Like guard but gives the function three arguments.

Applicative

val pure : 'a ‑> ('a'errt

Synonym of return.

val (<*>) : ('a ‑> 'b'errt ‑> ('a'errt ‑> ('b'errt

a <*> b evaluates a and b, and, in case of success, returns -Ok (a b). Otherwise, it fails, and the error of a is chosen -over the error of b if both fail.

val join : (('a'errt'errt ‑> ('a'errt

join t, in case of success, returns Ok o from Ok (Ok o). Otherwise, -it fails with Error e where e is the unwrapped error of t.

val both : ('a'errt ‑> ('b'errt ‑> ('a * 'b'errt

both a b, in case of success, returns Ok (o, o') with the ok values -of a and b. Otherwise, it fails, and the error of a is chosen over the -error of b if both fail.

Infix

module Infix : sig ... end

Collections

val map_l : ('a ‑> ('b'errt) ‑> 'a list ‑> ('b list, 'errt
val fold_l : ('b ‑> 'a ‑> ('b'errt) ‑> 'b ‑> 'a list ‑> ('b'errt
val fold_seq : ('b ‑> 'a ‑> ('b'errt) ‑> 'b ‑> 'a sequence ‑> ('b'errt

Misc

val choose : ('a'errt list ‑> ('a'err list) t

choose l selects a member of l that is a Ok _ value, -or returns Error l otherwise, where l is the list of errors.

val retry : int ‑> (unit ‑> ('a'errt) ‑> ('a'err list) t

retry n f calls f at most n times, returning the first result -of f () that doesn't fail. If f fails n times, retry n f fails -with the list of successive errors.

module type MONAD : sig ... end

Monadic Operations

module Traverse : functor (M : MONAD) -> sig ... end

Conversions

val to_opt : ('a_t ‑> 'a option

Convert a result to an option.

val of_opt : 'a option ‑> ('a, string) t

Convert an option to a result.

val to_seq : ('a_t ‑> 'a sequence
type ('a, 'b) error = [
| `Ok of 'a
| `Error of 'b
]
val of_err : ('a'berror ‑> ('a'bt
  • Since: 0.17
val to_err : ('a'bt ‑> ('a'berror
  • Since: 0.17

IO

val pp : 'a printer ‑> ('a, string) t printer
val pp' : 'a printer ‑> 'e printer ‑> ('a'et printer

Printer that is generic on the error type.

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

Module CCResult

Error Monad

Uses the new "result" type from OCaml 4.03.

since
0.16
type 'a sequence = ('a -> unit) -> unit
type 'a equal = 'a -> 'a -> bool
type 'a ord = 'a -> 'a -> int
type 'a printer = Format.formatter -> 'a -> unit

Basics

since
1.5
include module type of sig ... end
type ('a, 'b) result = ('a'b) Pervasives.result =
| Ok of 'a
| Error of 'b
type (+'good, +'bad) t = ('good'bad) Result.result =
| Ok of 'good
| Error of 'bad
val return : 'a -> ('a'err) t

Successfully return a value.

val fail : 'err -> ('a'err) t

Fail with an error.

val of_exn : exn -> ('a, string) t

of_exn e uses Printexc to print the exception as a string.

val of_exn_trace : exn -> ('a, string) t

of_exn_trace e is similar to of_exn e, but it adds the stacktrace to the error message.

Remember to call Printexc.record_backtrace true and compile with the debug flag for this to work.

val fail_printf : ('a, Buffer.t, unit, ('b, string) t) Pervasives.format4 -> 'a

fail_printf format uses format to obtain an error message and then returns Error msg.

val fail_fprintf : ('a, Format.formatter, unit, ('b, string) t) Pervasives.format4 -> 'a

fail_fprintf format uses format to obtain an error message and then returns Error msg.

val add_ctx : string -> ('a, string) t -> ('a, string) t

add_ctx msg leaves Ok x untouched, but transforms Error s into Error s' where s' contains the additional context given by msg.

since
1.2
val add_ctxf : ('a, Format.formatter, unit, ('b, string) t -> ('b, string) t) Pervasives.format4 -> 'a

add_ctxf format_message is similar to add_ctx but with Format for printing the message (eagerly). Example:

add_ctxf "message(number %d, foo: %B)" 42 true (Error "error)"
since
1.2
val map : ('a -> 'b) -> ('a'err) t -> ('b'err) t

Map on success.

val map_err : ('err1 -> 'err2) -> ('a'err1) t -> ('a'err2) t

Map on the error variant.

val map2 : ('a -> 'b) -> ('err1 -> 'err2) -> ('a'err1) t -> ('b'err2) t

Like map, but also with a function that can transform the error message in case of failure.

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

Apply the function only in case of Ok.

val iter_err : ('err -> unit) -> (_'err) t -> unit

Apply the function in case of Error.

since
2.4
exception Get_error
val get_exn : ('a_) t -> 'a

Extract the value x from Ok x, fails otherwise. You should be careful with this function, and favor other combinators whenever possible.

raises Get_error

if the value is an error.

val get_or : ('a_) t -> default:'a -> 'a

get_or e ~default returns x if e = Ok x, default otherwise.

val get_or_failwith : ('a, string) t -> 'a

get_or_failwith e returns x if e = Ok x, fails otherwise.

raises Failure

with msg if e = Error msg.

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

map_or f e ~default returns f x if e = Ok x, default otherwise.

val catch : ('a'err) t -> ok:('a -> 'b) -> err:('err -> 'b) -> 'b

catch e ~ok ~err calls either ok or err depending on the value of e.

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

Monadic composition. e >>= f proceeds as f x if e is Ok x or returns e if e is an Error.

val equal : err:'err equal -> 'a equal -> ('a'err) t equal
val compare : err:'err ord -> 'a ord -> ('a'err) t ord
val fold : ok:('a -> 'b) -> error:('err -> 'b) -> ('a'err) t -> 'b

fold ~ok ~error e opens e and, if e = Ok x, returns ok x, otherwise e = Error s and it returns error s.

val fold_ok : ('a -> 'b -> 'a) -> 'a -> ('b_) t -> 'a

fold_ok f acc r will compute f acc x if r=Ok x, and return acc otherwise, as if the result were a mere option.

since
1.2
val is_ok : ('a'err) t -> bool

Return true if Ok.

since
1.0
val is_error : ('a'err) t -> bool

Return true if Error.

since
1.0

Wrappers

val guard : (unit -> 'a) -> ('a, exn) t

guard f runs f () and returns its result wrapped in Ok. If f () raises some exception e, then it fails with Error e.

val guard_str : (unit -> 'a) -> ('a, string) t

Like guard but uses of_exn to print the exception.

val guard_str_trace : (unit -> 'a) -> ('a, string) t

Like guard_str but uses of_exn_trace instead of of_exn so that the stack trace is printed.

val wrap1 : ('a -> 'b) -> 'a -> ('b, exn) t

Like guard but gives the function one argument.

val wrap2 : ('a -> 'b -> 'c) -> 'a -> 'b -> ('c, exn) t

Like guard but gives the function two arguments.

val wrap3 : ('a -> 'b -> 'c -> 'd) -> 'a -> 'b -> 'c -> ('d, exn) t

Like guard but gives the function three arguments.

Applicative

val pure : 'a -> ('a'err) t

Synonym of return.

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

a <*> b evaluates a and b, and, in case of success, returns Ok (a b). Otherwise, it fails, and the error of a is chosen over the error of b if both fail.

val join : (('a'err) t'err) t -> ('a'err) t

join t, in case of success, returns Ok o from Ok (Ok o). Otherwise, it fails with Error e where e is the unwrapped error of t.

val both : ('a'err) t -> ('b'err) t -> ('a * 'b'err) t

both a b, in case of success, returns Ok (o, o') with the ok values of a and b. Otherwise, it fails, and the error of a is chosen over the error of b if both fail.

Infix

module Infix : sig ... end

Collections

val map_l : ('a -> ('b'err) t) -> 'a list -> ('b list, 'err) t

map_l f [a1; ...; an] applies the function f to a1, ..., an , and, in case of success for every element, returns the list of Ok-value. Otherwise, it fails and returns the first error encountered. Tail-recursive.

val fold_l : ('b -> 'a -> ('b'err) t) -> 'b -> 'a list -> ('b'err) t
val fold_seq : ('b -> 'a -> ('b'err) t) -> 'b -> 'a sequence -> ('b'err) t

Misc

val choose : ('a'err) t list -> ('a'err list) t

choose l selects a member of l that is a Ok _ value, or returns Error l otherwise, where l is the list of errors.

val retry : int -> (unit -> ('a'err) t) -> ('a'err list) t

retry n f calls f at most n times, returning the first result of f () that doesn't fail. If f fails n times, retry n f fails with the list of successive errors.

module type MONAD = sig ... end
module Traverse : functor (M : MONAD) -> sig ... end

Conversions

val to_opt : ('a_) t -> 'a option

Convert a result to an option.

val of_opt : 'a option -> ('a, string) t

Convert an option to a result.

val to_seq : ('a_) t -> 'a sequence
type ('a, 'b) error = [
| `Ok of 'a
| `Error of 'b
]
val of_err : ('a'b) error -> ('a'b) t
since
0.17
val to_err : ('a'b) t -> ('a'b) error
since
0.17

IO

val pp : 'a printer -> ('a, string) t printer
val pp' : 'a printer -> 'e printer -> ('a'e) t printer

Printer that is generic on the error type.

\ No newline at end of file diff --git a/dev/containers/CCResult/module-type-MONAD/index.html b/dev/containers/CCResult/module-type-MONAD/index.html index 95d076f3..62dd06d6 100644 --- a/dev/containers/CCResult/module-type-MONAD/index.html +++ b/dev/containers/CCResult/module-type-MONAD/index.html @@ -1,2 +1,2 @@ -MONAD (containers.CCResult.MONAD)

Module type CCResult.MONAD

Monadic Operations

type 'a t
val return : 'a ‑> 'a t

Monadic return.

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

Monadic bind.

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

Module type CCResult.MONAD

Monadic Operations

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

Monadic return.

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

Monadic bind.

\ No newline at end of file diff --git a/dev/containers/CCSet/index.html b/dev/containers/CCSet/index.html index 55922017..e649373b 100644 --- a/dev/containers/CCSet/index.html +++ b/dev/containers/CCSet/index.html @@ -1,2 +1,2 @@ -CCSet (containers.CCSet)

Module CCSet

Wrapper around Set

type 'a sequence = ('a ‑> unit) ‑> unit
type 'a printer = Format.formatter ‑> 'a ‑> unit
module type OrderedType = Set.OrderedType
module type S : sig ... end
module Make : functor (O : Set.OrderedType) -> S with type Make.t = Set.Make(O).t and type Make.elt = O.t
\ No newline at end of file +CCSet (containers.CCSet)

Module CCSet

Wrapper around Set

since
0.9
type 'a sequence = ('a -> unit) -> unit
type 'a printer = Format.formatter -> 'a -> unit
module type OrderedType = Set.OrderedType
module type S = sig ... end
module Make : functor (O : Set.OrderedType) -> S with type Make.t = Set.Make(O).t and type Make.elt = O.t
\ No newline at end of file diff --git a/dev/containers/CCSet/module-type-S/index.html b/dev/containers/CCSet/module-type-S/index.html index 05f676c5..3b6449f1 100644 --- a/dev/containers/CCSet/module-type-S/index.html +++ b/dev/containers/CCSet/module-type-S/index.html @@ -1,3 +1,2 @@ -S (containers.CCSet.S)

Module type CCSet.S

include Set.S
type elt
type t
val empty : t
val is_empty : t ‑> bool
val mem : elt ‑> t ‑> bool
val add : elt ‑> t ‑> t
val singleton : elt ‑> t
val remove : elt ‑> t ‑> t
val union : t ‑> t ‑> t
val inter : t ‑> t ‑> t
val diff : t ‑> t ‑> t
val compare : t ‑> t ‑> int
val equal : t ‑> t ‑> bool
val subset : t ‑> t ‑> bool
val iter : (elt ‑> unit) ‑> t ‑> unit
val map : (elt ‑> elt) ‑> t ‑> t
val fold : (elt ‑> 'a ‑> 'a) ‑> t ‑> 'a ‑> 'a
val for_all : (elt ‑> bool) ‑> t ‑> bool
val exists : (elt ‑> bool) ‑> t ‑> bool
val filter : (elt ‑> bool) ‑> t ‑> t
val partition : (elt ‑> bool) ‑> t ‑> t * t
val cardinal : t ‑> int
val elements : t ‑> elt list
val min_elt : t ‑> elt
val min_elt_opt : t ‑> elt option
val max_elt : t ‑> elt
val max_elt_opt : t ‑> elt option
val choose : t ‑> elt
val choose_opt : t ‑> elt option
val split : elt ‑> t ‑> t * bool * t
val find : elt ‑> t ‑> elt
val find_opt : elt ‑> t ‑> elt option
val find_first : (elt ‑> bool) ‑> t ‑> elt
val find_first_opt : (elt ‑> bool) ‑> t ‑> elt option
val find_last : (elt ‑> bool) ‑> t ‑> elt
val find_last_opt : (elt ‑> bool) ‑> t ‑> elt option
val of_list : elt list ‑> t
val min_elt_opt : t ‑> elt option

Safe version of min_elt.

  • Since: 1.5
val max_elt_opt : t ‑> elt option

Safe version of max_elt.

  • Since: 1.5
val choose_opt : t ‑> elt option

Safe version of choose.

  • Since: 1.5
val find_opt : elt ‑> t ‑> elt option

Safe version of find.

  • Since: 1.5
val find_first : (elt ‑> bool) ‑> t ‑> elt

Find minimum element satisfying predicate.

  • Since: 1.5
val find_first_opt : (elt ‑> bool) ‑> t ‑> elt option

Safe version of find_first.

  • Since: 1.5
val find_last : (elt ‑> bool) ‑> t ‑> elt

Find maximum element satisfying predicate.

  • Since: 1.5
val find_last_opt : (elt ‑> bool) ‑> t ‑> elt option

Safe version of find_last.

  • Since: 1.5
val of_seq : elt sequence ‑> t

Build a set from the given sequence of elements.

val add_seq : t ‑> elt sequence ‑> t
  • Since: 0.14
val to_seq : t ‑> elt sequence

to_seq t converts the set t to a sequence of the elements.

val of_list : elt list ‑> t

Build a set from the given list of elements, -added in order using add.

val add_list : t ‑> elt list ‑> t
  • Since: 0.14
val to_list : t ‑> elt list

to_list t converts the set t to a list of the elements.

val pp : ?⁠start:string ‑> ?⁠stop:string ‑> ?⁠sep:string ‑> elt printer ‑> t printer

Print the set

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

Module type CCSet.S

include Set.S
type elt
type t
val empty : t
val is_empty : t -> bool
val mem : elt -> t -> bool
val add : elt -> t -> t
val singleton : elt -> t
val remove : elt -> t -> t
val union : t -> t -> t
val inter : t -> t -> t
val diff : t -> t -> t
val compare : t -> t -> int
val equal : t -> t -> bool
val subset : t -> t -> bool
val iter : (elt -> unit) -> t -> unit
val map : (elt -> elt) -> t -> t
val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a
val for_all : (elt -> bool) -> t -> bool
val exists : (elt -> bool) -> t -> bool
val filter : (elt -> bool) -> t -> t
val partition : (elt -> bool) -> t -> t * t
val cardinal : t -> int
val elements : t -> elt list
val min_elt : t -> elt
val min_elt_opt : t -> elt option
val max_elt : t -> elt
val max_elt_opt : t -> elt option
val choose : t -> elt
val choose_opt : t -> elt option
val split : elt -> t -> t * bool * t
val find : elt -> t -> elt
val find_opt : elt -> t -> elt option
val find_first : (elt -> bool) -> t -> elt
val find_first_opt : (elt -> bool) -> t -> elt option
val find_last : (elt -> bool) -> t -> elt
val find_last_opt : (elt -> bool) -> t -> elt option
val of_list : elt list -> t
val min_elt_opt : t -> elt option

Safe version of min_elt.

since
1.5
val max_elt_opt : t -> elt option

Safe version of max_elt.

since
1.5
val choose_opt : t -> elt option

Safe version of choose.

since
1.5
val find_opt : elt -> t -> elt option

Safe version of find.

since
1.5
val find_first : (elt -> bool) -> t -> elt

Find minimum element satisfying predicate.

since
1.5
val find_first_opt : (elt -> bool) -> t -> elt option

Safe version of find_first.

since
1.5
val find_last : (elt -> bool) -> t -> elt

Find maximum element satisfying predicate.

since
1.5
val find_last_opt : (elt -> bool) -> t -> elt option

Safe version of find_last.

since
1.5
val of_seq : elt sequence -> t

Build a set from the given sequence of elements.

val add_seq : t -> elt sequence -> t
since
0.14
val to_seq : t -> elt sequence

to_seq t converts the set t to a sequence of the elements.

val of_list : elt list -> t

Build a set from the given list of elements, added in order using add.

val add_list : t -> elt list -> t
since
0.14
val to_list : t -> elt list

to_list t converts the set t to a list of the elements.

val pp : ?⁠start:string -> ?⁠stop:string -> ?⁠sep:string -> elt printer -> t printer

Print the set.

\ No newline at end of file diff --git a/dev/containers/CCString/Find/index.html b/dev/containers/CCString/Find/index.html index b2e36b81..17af4ee8 100644 --- a/dev/containers/CCString/Find/index.html +++ b/dev/containers/CCString/Find/index.html @@ -1,2 +1,2 @@ -Find (containers.CCString.Find)

Module CCString.Find

type _ pattern
val compile : string ‑> [ `Direct ] pattern
val rcompile : string ‑> [ `Reverse ] pattern
val find : ?⁠start:int ‑> pattern:[ `Direct ] pattern ‑> string ‑> int

Search for pattern in the string, left-to-right.

  • Returns the offset of the first match, -1 otherwise.
  • Parameter start: offset in string at which we start.
val rfind : ?⁠start:int ‑> pattern:[ `Reverse ] pattern ‑> string ‑> int

Search for pattern in the string, right-to-left.

  • Returns the offset of the start of the first match from the right, -1 otherwise.
  • Parameter start: right-offset in string at which we start.
\ No newline at end of file +Find (containers.CCString.Find)

Module CCString.Find

type _ pattern
val compile : string -> [ `Direct ] pattern
val rcompile : string -> [ `Reverse ] pattern
val find : ?⁠start:int -> pattern:[ `Direct ] pattern -> string -> int

Search for pattern in the string, left-to-right.

returns

the offset of the first match, -1 otherwise.

parameter start

offset in string at which we start.

val rfind : ?⁠start:int -> pattern:[ `Reverse ] pattern -> string -> int

Search for pattern in the string, right-to-left.

returns

the offset of the start of the first match from the right, -1 otherwise.

parameter start

right-offset in string at which we start.

\ No newline at end of file diff --git a/dev/containers/CCString/Split/index.html b/dev/containers/CCString/Split/index.html index 91e9235e..6204aa63 100644 --- a/dev/containers/CCString/Split/index.html +++ b/dev/containers/CCString/Split/index.html @@ -1,9 +1,2 @@ -Split (containers.CCString.Split)

Module CCString.Split

type drop_if_empty = {
first : bool;
last : bool;
}

Specification of what to do with empty blocks, as in split ~by:"-" "-a-b-".

  • {first=false; last=false} will return ""; "a"; "b"; ""
  • {first=true; last=false} will return "a"; "b" ""
  • {first=false; last=true} will return ""; "a"; "b"
  • {first=true; last=true} will return "a"; "b"

The default value of all remaining functions is Drop_none.

  • Since: 1.5
val no_drop : drop_if_empty

Do not drop any group, even empty and on borders.

  • Since: 1.5
val list_ : ?⁠drop:drop_if_empty ‑> by:string ‑> string ‑> (string * int * int) list

Split the given string along the given separator by. Should only -be used with very small separators, otherwise -use Containers_string.KMP.

  • Returns a list of slices (s,index,length) that are -separated by by. String.sub can then be used to actually extract -a string from the slice.
  • Raises Failure: if by = "".
val gen : ?⁠drop:drop_if_empty ‑> by:string ‑> string ‑> (string * int * int) gen
val seq : ?⁠drop:drop_if_empty ‑> by:string ‑> string ‑> (string * int * int) sequence
val klist : ?⁠drop:drop_if_empty ‑> by:string ‑> string ‑> (string * int * int) klist
Copying functions

Those split functions actually copy the substrings, which can be -more convenient but less efficient in general.

val list_cpy : ?⁠drop:drop_if_empty ‑> by:string ‑> string ‑> string list
val gen_cpy : ?⁠drop:drop_if_empty ‑> by:string ‑> string ‑> string gen
val seq_cpy : ?⁠drop:drop_if_empty ‑> by:string ‑> string ‑> string sequence
val klist_cpy : ?⁠drop:drop_if_empty ‑> by:string ‑> string ‑> string klist
val left : by:string ‑> string ‑> (string * string) option

Split on the first occurrence of by from the leftmost part of -the string.

  • Since: 0.12
val left_exn : by:string ‑> string ‑> string * string

Split on the first occurrence of by from the leftmost part of the string.

  • Raises Not_found: if by is not part of the string.
  • Since: 0.16
val right : by:string ‑> string ‑> (string * string) option

Split on the first occurrence of by from the rightmost part of -the string.

  • Since: 0.12
val right_exn : by:string ‑> string ‑> string * string

Split on the first occurrence of by from the rightmost part of the string.

  • Raises Not_found: if by is not part of the string.
  • Since: 0.16
\ No newline at end of file +Split (containers.CCString.Split)

Module CCString.Split

type drop_if_empty = {
first : bool;
last : bool;
}

Specification of what to do with empty blocks, as in split ~by:"-" "-a-b-".

  • {first=false; last=false} will return ""; "a"; "b"; ""
  • {first=true; last=false} will return "a"; "b" ""
  • {first=false; last=true} will return ""; "a"; "b"
  • {first=true; last=true} will return "a"; "b"

The default value of all remaining functions is Drop_none.

since
1.5
val no_drop : drop_if_empty

Do not drop any group, even empty and on borders.

since
1.5
val list_ : ?⁠drop:drop_if_empty -> by:string -> string -> (string * int * int) list

Split the given string along the given separator by. Should only be used with very small separators, otherwise use Containers_string.KMP.

returns

a list of slices (s,index,length) that are separated by by. String.sub can then be used to actually extract a string from the slice.

raises Failure

if by = "".

val gen : ?⁠drop:drop_if_empty -> by:string -> string -> (string * int * int) gen
val seq : ?⁠drop:drop_if_empty -> by:string -> string -> (string * int * int) sequence
val klist : ?⁠drop:drop_if_empty -> by:string -> string -> (string * int * int) klist
Copying functions

Those split functions actually copy the substrings, which can be more convenient but less efficient in general.

val list_cpy : ?⁠drop:drop_if_empty -> by:string -> string -> string list
val gen_cpy : ?⁠drop:drop_if_empty -> by:string -> string -> string gen
val seq_cpy : ?⁠drop:drop_if_empty -> by:string -> string -> string sequence
val klist_cpy : ?⁠drop:drop_if_empty -> by:string -> string -> string klist
val left : by:string -> string -> (string * string) option

Split on the first occurrence of by from the leftmost part of the string.

since
0.12
val left_exn : by:string -> string -> string * string

Split on the first occurrence of by from the leftmost part of the string.

raises Not_found

if by is not part of the string.

since
0.16
val right : by:string -> string -> (string * string) option

Split on the first occurrence of by from the rightmost part of the string.

since
0.12
val right_exn : by:string -> string -> string * string

Split on the first occurrence of by from the rightmost part of the string.

raises Not_found

if by is not part of the string.

since
0.16
\ No newline at end of file diff --git a/dev/containers/CCString/Sub/index.html b/dev/containers/CCString/Sub/index.html index 7dfdd05c..327b3aa7 100644 --- a/dev/containers/CCString/Sub/index.html +++ b/dev/containers/CCString/Sub/index.html @@ -1,3 +1,2 @@ -Sub (containers.CCString.Sub)

Module CCString.Sub

type t = string * int * int

A string, an offset, and the length of the slice.

val make : string ‑> int ‑> len:int ‑> t
val full : string ‑> t

Full string.

val copy : t ‑> string

Make a copy of the substring.

val underlying : t ‑> string
val sub : t ‑> int ‑> int ‑> t

Sub-slice.

val get : t ‑> int ‑> char

get s i gets the i-th element, or fails.

  • Raises Invalid_argument: if the index is not within 0 ... length - 1.
  • Since: 1.2
include S with type t := t
type t
val length : t ‑> int

Return the length (number of characters) of the given string.

val blit : t ‑> int ‑> Bytes.t ‑> int ‑> int ‑> unit

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 on chars by increasing index.

  • Since: 0.7

Conversions

val to_gen : t ‑> char gen

Return the gen of characters contained in the string.

val to_seq : t ‑> char sequence

Return the sequence of characters contained in the string.

val to_klist : t ‑> char klist

Return the klist of characters contained in the string.

val to_list : t ‑> char list

Return the list of characters contained in the string.

val pp_buf : Buffer.t ‑> t ‑> unit

Renamed from pp since 2.0.

val pp : Format.formatter ‑> t ‑> unit

Print the string within quotes.

Renamed from print since 2.0.

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

Module CCString.Sub

type t = string * int * int

A string, an offset, and the length of the slice.

val make : string -> int -> len:int -> t
val full : string -> t

Full string.

val copy : t -> string

Make a copy of the substring.

val underlying : t -> string
val sub : t -> int -> int -> t

Sub-slice.

val get : t -> int -> char

get s i gets the i-th element, or fails.

raises Invalid_argument

if the index is not within 0 ... length - 1.

since
1.2
include S with type t := t
type t
val length : t -> int

Return the length (number of characters) of the given string.

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

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 on chars by increasing index.

since
0.7

Conversions

val to_gen : t -> char gen

Return the gen of characters contained in the string.

val to_seq : t -> char sequence

Return the sequence of characters contained in the string.

val to_klist : t -> char klist

Return the klist of characters contained in the string.

val to_list : t -> char list

Return the list of characters contained in the string.

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

Renamed from pp since 2.0.

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

Print the string within quotes.

Renamed from print since 2.0.

\ No newline at end of file diff --git a/dev/containers/CCString/index.html b/dev/containers/CCString/index.html index c5e1f7a5..968b9362 100644 --- a/dev/containers/CCString/index.html +++ b/dev/containers/CCString/index.html @@ -1,21 +1,2 @@ -CCString (containers.CCString)

Module CCString

Basic String Utils

Consider using Containers_string.KMP for pattern search, or Regex -libraries.

type 'a gen = unit ‑> 'a option
type 'a sequence = ('a ‑> unit) ‑> unit
type 'a klist = unit ‑> [ `Nil | `Cons of 'a * 'a klist ]

Common Signature

module type S : sig ... end

Strings

include module type of sig ... end
external length : string ‑> int = "%string_length"
external get : string ‑> int ‑> char = "%string_safe_get"
external set : bytes ‑> int ‑> char ‑> unit = "%string_safe_set"
  • Deprecated Use Bytes.set instead.
external create : int ‑> bytes = "caml_create_string"
  • Deprecated Use Bytes.create instead.
val make : int ‑> char ‑> string
val init : int ‑> (int ‑> char) ‑> string
val copy : string ‑> string
val sub : string ‑> int ‑> int ‑> string
val fill : bytes ‑> int ‑> int ‑> char ‑> unit
  • Deprecated Use Bytes.fill instead.
val blit : string ‑> int ‑> bytes ‑> int ‑> int ‑> unit
val concat : string ‑> string list ‑> string
val iter : (char ‑> unit) ‑> string ‑> unit
val iteri : (int ‑> char ‑> unit) ‑> string ‑> unit
val map : (char ‑> char) ‑> string ‑> string
val mapi : (int ‑> char ‑> char) ‑> string ‑> string
val trim : string ‑> string
val escaped : string ‑> string
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 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 contains : string ‑> char ‑> bool
val contains_from : string ‑> int ‑> char ‑> bool
val rcontains_from : string ‑> int ‑> char ‑> bool
val uppercase : string ‑> string
  • Deprecated Use String.uppercase_ascii instead.
val lowercase : string ‑> string
  • Deprecated Use String.lowercase_ascii instead.
val capitalize : string ‑> string
  • Deprecated Use String.capitalize_ascii instead.
val uncapitalize : string ‑> string
  • Deprecated Use String.uncapitalize_ascii instead.
val uppercase_ascii : string ‑> string
val lowercase_ascii : string ‑> string
val capitalize_ascii : string ‑> string
val uncapitalize_ascii : string ‑> string
type t = string
val compare : t ‑> t ‑> int
val equal : t ‑> t ‑> bool
val split_on_char : char ‑> string ‑> string list
external unsafe_get : string ‑> int ‑> char = "%string_unsafe_get"
external unsafe_set : bytes ‑> int ‑> char ‑> unit = "%string_unsafe_set"
external unsafe_blit : string ‑> int ‑> bytes ‑> int ‑> int ‑> unit = "caml_blit_string"
external unsafe_fill : bytes ‑> int ‑> int ‑> char ‑> unit = "caml_fill_string"
val equal : string ‑> string ‑> bool

Equality function on strings.

val compare : string ‑> string ‑> int
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
val init : int ‑> (int ‑> char) ‑> string

Like Array.init.

  • Since: 0.3.3
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 n str ensures that str 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

Convert a gen of characters to a string.

val of_seq : char sequence ‑> string

Convert a sequence of characters to a string.

val of_klist : char klist ‑> string

Convert a klist of characters to a string.

val of_list : char list ‑> string

Convert a list of characters to a string.

val of_array : char array ‑> string

Convert an array of characters to a string.

val to_array : string ‑> char array

Return the array of characters contained in the string.

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

Find sub in string, returns its first index or -1.

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

find_all ~sub s finds all occurrences of sub in s, even overlapping -instances.

  • 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 ~sub s is true iff sub is a substring of s.

  • Since: 0.12
val rfind : sub:string ‑> string ‑> int

Find sub in string 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 ~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 ‑> len:int ‑> bool

is_sub ~sub i s j ~len returns true iff the substring of -sub starting at position i and of length len is a substring -of s starting at position j.

val repeat : string ‑> int ‑> string

The same string, repeated 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 = 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 of the lines of s (splits along '\n').

  • Since: 0.10
val concat_gen : sep:string ‑> string gen ‑> string

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

  • Since: 0.10
val unlines : string list ‑> string

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

  • Since: 0.10
val unlines_gen : string gen ‑> string

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

  • Since: 0.10
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

Alias to String.iter.

  • Since: 0.12
val iteri : (int ‑> char ‑> unit) ‑> string ‑> unit

Iter on chars with their index.

  • Since: 0.12
val map : (char ‑> char) ‑> string ‑> string

Map chars.

  • Since: 0.12
val mapi : (int ‑> char ‑> char) ‑> string ‑> string

Map chars with their index.

  • 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 not satisfying f.

  • Since: 0.17
val flat_map : ?⁠sep:string ‑> (char ‑> string) ‑> string ‑> string

Map each chars 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

True for all chars?

  • Since: 0.12
val exists : (char ‑> bool) ‑> string ‑> bool

True for some char?

  • Since: 0.12
include S with type S.t := string
type t
val length : t ‑> int

Return the length (number of characters) of the given string.

val blit : t ‑> int ‑> Bytes.t ‑> int ‑> int ‑> unit

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 on chars by increasing index.

  • Since: 0.7

Conversions

val to_gen : t ‑> char gen

Return the gen of characters contained in the string.

val to_seq : t ‑> char sequence

Return the sequence of characters contained in the string.

val to_klist : t ‑> char klist

Return the klist of characters contained in the string.

val to_list : t ‑> char list

Return the list of characters contained in the string.

val pp_buf : Buffer.t ‑> t ‑> unit

Renamed from pp since 2.0.

val pp : Format.formatter ‑> t ‑> unit

Print the string within quotes.

Renamed from print since 2.0.

val ltrim : t ‑> t

Trim space on the left (see String.trim for more details).

  • Since: 1.2
val rtrim : t ‑> t

Trim 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

Map 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

Iterate 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

Iterate 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

Fold 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

All pairs of chars respect the predicate?

  • Raises Invalid_argument: if the strings have not the same length.
  • Since: 0.12
val exists2 : (char ‑> char ‑> bool) ‑> string ‑> string ‑> bool

Exists a pair of chars?

  • 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

See String.

  • Since: 0.18
val uncapitalize_ascii : string ‑> string

See String.

  • Since: 0.18
val uppercase_ascii : string ‑> string

See String.

  • Since: 0.18
val lowercase_ascii : string ‑> string

See String.

  • Since: 0.18
val equal_caseless : string ‑> string ‑> bool

Comparison without respect to ascii lowercase.

  • Since: 1.2

Finding

A relatively efficient algorithm for finding sub-strings.

module Find : sig ... end

Splitting

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

Split the string along the given char.

  • Since: 1.2
val split : by:string ‑> string ‑> string list

Alias to Split.list_cpy.

  • Since: 1.2

Utils

val compare_versions : string ‑> string ‑> int

compare_versions a b compares version stringsa and b, -considering that numbers are above text.

  • Since: 0.13
val compare_natural : string ‑> string ‑> int

Natural Sort Order, comparing chunks of digits as natural numbers. -https://en.wikipedia.org/wiki/Natural_sort_order

  • Since: 1.3
val edit_distance : string ‑> string ‑> int

Edition distance between two strings. This satisfies the classical -distance axioms: it is always positive, symmetric, and satisfies -the formula distance a b + distance b c >= distance a c.

Slices

A contiguous part of a string

module Sub : sig ... end
\ No newline at end of file +CCString (containers.CCString)

Module CCString

Basic String Utils

type 'a gen = unit -> 'a option
type 'a sequence = ('a -> unit) -> unit
type 'a klist = unit -> [ `Nil | `Cons of 'a * 'a klist ]

Common Signature

module type S = sig ... end

Strings

include module type of sig ... end
val length : string -> int
val get : string -> int -> char
val set : bytes -> int -> char -> unit
val create : int -> bytes
val make : int -> char -> string
val init : int -> (int -> char) -> string
val copy : string -> string
val sub : string -> int -> int -> string
val fill : bytes -> int -> int -> char -> unit
val blit : string -> int -> bytes -> int -> int -> unit
val concat : string -> string list -> string
val iter : (char -> unit) -> string -> unit
val iteri : (int -> char -> unit) -> string -> unit
val map : (char -> char) -> string -> string
val mapi : (int -> char -> char) -> string -> string
val trim : string -> string
val escaped : string -> string
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 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 contains : string -> char -> bool
val contains_from : string -> int -> char -> bool
val rcontains_from : string -> int -> char -> bool
val uppercase : string -> string
val lowercase : string -> string
val capitalize : string -> string
val uncapitalize : string -> string
val uppercase_ascii : string -> string
val lowercase_ascii : string -> string
val capitalize_ascii : string -> string
val uncapitalize_ascii : string -> string
type t = string
val compare : t -> t -> int
val equal : t -> t -> bool
val split_on_char : char -> string -> string list
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 equal : string -> string -> bool

Equality function on strings.

val compare : string -> string -> int
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
val init : int -> (int -> char) -> string

Like Array.init.

since
0.3.3
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 n str ensures that str 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

Convert a gen of characters to a string.

val of_seq : char sequence -> string

Convert a sequence of characters to a string.

val of_klist : char klist -> string

Convert a klist of characters to a string.

val of_list : char list -> string

Convert a list of characters to a string.

val of_array : char array -> string

Convert an array of characters to a string.

val to_array : string -> char array

Return the array of characters contained in the string.

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

Find sub in string, returns its first index or -1.

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

find_all ~sub s finds all occurrences of sub in s, even overlapping instances.

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 ~sub s is true iff sub is a substring of s.

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

Find sub in string 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 ~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 i s j ~len returns true iff the substring of sub starting at position i and of length len is a substring of s starting at position j.

val repeat : string -> int -> string

The same string, repeated 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 = 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 of the lines of s (splits along '\n').

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

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

since
0.10
val unlines : string list -> string

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

since
0.10
val unlines_gen : string gen -> string

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

since
0.10
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

Alias to String.iter.

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

Iter on chars with their index.

since
0.12
val map : (char -> char) -> string -> string

Map chars.

since
0.12
val mapi : (int -> char -> char) -> string -> string

Map chars with their index.

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 not satisfying f.

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

Map each chars 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

True for all chars?

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

True for some char?

since
0.12
include S with type S.t := string
type t
val length : t -> int

Return the length (number of characters) of the given string.

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

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 on chars by increasing index.

since
0.7

Conversions

val to_gen : t -> char gen

Return the gen of characters contained in the string.

val to_seq : t -> char sequence

Return the sequence of characters contained in the string.

val to_klist : t -> char klist

Return the klist of characters contained in the string.

val to_list : t -> char list

Return the list of characters contained in the string.

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

Renamed from pp since 2.0.

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

Print the string within quotes.

Renamed from print since 2.0.

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

drop_while f s discards any characters 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 starting from the right, up to the first character c not satisfying f c.

since
2.2
val ltrim : t -> t

Trim space on the left (see String.trim for more details).

since
1.2
val rtrim : t -> t

Trim 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

Map 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

Iterate 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

Iterate 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

Fold 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

All pairs of chars respect the predicate?

raises Invalid_argument

if the strings have not the same length.

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

Exists a pair of chars?

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

See String.

since
0.18
val uncapitalize_ascii : string -> string

See String.

since
0.18
val uppercase_ascii : string -> string

See String.

since
0.18
val lowercase_ascii : string -> string

See String.

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

Comparison 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 the string along the given char.

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

Alias to Split.list_cpy.

since
1.2

Utils

val compare_versions : string -> string -> int

compare_versions a b compares version strings a and b, considering that numbers are above text.

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

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

since
1.3
val edit_distance : string -> string -> int

Edition distance between two strings. This satisfies the classical distance axioms: it is always positive, symmetric, and satisfies the formula distance a b + distance b c >= distance a c.

Slices

A contiguous part of a string

module Sub : sig ... end
\ No newline at end of file diff --git a/dev/containers/CCString/module-type-S/index.html b/dev/containers/CCString/module-type-S/index.html index e91d8c6d..fea9855c 100644 --- a/dev/containers/CCString/module-type-S/index.html +++ b/dev/containers/CCString/module-type-S/index.html @@ -1,3 +1,2 @@ -S (containers.CCString.S)

Module type CCString.S

type t
val length : t ‑> int

Return the length (number of characters) of the given string.

val blit : t ‑> int ‑> Bytes.t ‑> int ‑> int ‑> unit

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 on chars by increasing index.

  • Since: 0.7

Conversions

val to_gen : t ‑> char gen

Return the gen of characters contained in the string.

val to_seq : t ‑> char sequence

Return the sequence of characters contained in the string.

val to_klist : t ‑> char klist

Return the klist of characters contained in the string.

val to_list : t ‑> char list

Return the list of characters contained in the string.

val pp_buf : Buffer.t ‑> t ‑> unit

Renamed from pp since 2.0.

val pp : Format.formatter ‑> t ‑> unit

Print the string within quotes.

Renamed from print since 2.0.

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

Module type CCString.S

type t
val length : t -> int

Return the length (number of characters) of the given string.

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

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 on chars by increasing index.

since
0.7

Conversions

val to_gen : t -> char gen

Return the gen of characters contained in the string.

val to_seq : t -> char sequence

Return the sequence of characters contained in the string.

val to_klist : t -> char klist

Return the klist of characters contained in the string.

val to_list : t -> char list

Return the list of characters contained in the string.

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

Renamed from pp since 2.0.

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

Print the string within quotes.

Renamed from print since 2.0.

\ No newline at end of file diff --git a/dev/containers/CCUtf8_string/index.html b/dev/containers/CCUtf8_string/index.html index b421e73e..8c441678 100644 --- a/dev/containers/CCUtf8_string/index.html +++ b/dev/containers/CCUtf8_string/index.html @@ -1,3 +1,2 @@ -CCUtf8_string (containers.CCUtf8_string)

Module CCUtf8_string

Unicode String, in UTF8

type uchar = Uchar.t
type 'a gen = unit ‑> 'a option
type 'a sequence = ('a ‑> unit) ‑> unit
type t = private string

A UTF8 string

val equal : t ‑> t ‑> bool
val hash : t ‑> int
val compare : t ‑> t ‑> int
val pp : Format.formatter ‑> t ‑> unit
val to_string : t ‑> string

Identity.

exception Malformed of string * int

Malformed string at given offset

val to_gen : ?⁠idx:int ‑> t ‑> uchar gen

Generator of unicode codepoints.

  • Parameter idx: offset where to start the decoding.
val to_seq : ?⁠idx:int ‑> t ‑> uchar sequence

Sequence of unicode codepoints.

  • Parameter idx: offset where to start the decoding.
val to_list : ?⁠idx:int ‑> t ‑> uchar list

List of unicode codepoints.

  • Parameter idx: offset where to start the decoding.
val fold : ?⁠idx:int ‑> ('a ‑> uchar ‑> 'a) ‑> 'a ‑> t ‑> 'a
val iter : ?⁠idx:int ‑> (uchar ‑> unit) ‑> t ‑> unit
val n_chars : t ‑> int

Number of characters.

val n_bytes : t ‑> int

Number of bytes.

val map : (uchar ‑> uchar) ‑> t ‑> t
val filter_map : (uchar ‑> uchar option) ‑> t ‑> t
val flat_map : (uchar ‑> t) ‑> t ‑> t
val append : t ‑> t ‑> t
val concat : t ‑> t list ‑> t
val of_seq : uchar sequence ‑> t
val of_gen : uchar gen ‑> t
val of_list : uchar list ‑> t
val of_string_exn : string ‑> t

Validate string by checking it is valid UTF8.

  • Raises Invalid_argument: if the string is not valid UTF8.
val of_string : string ‑> t option

Safe version of of_string_exn.

val is_valid : string ‑> bool

Valid UTF8?

val unsafe_of_string : string ‑> t

Conversion from a string without validating. -Upon iteration, if an invalid substring is met, Malformed will be raised.

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

Module CCUtf8_string

Unicode String, in UTF8

type uchar = Uchar.t
type 'a gen = unit -> 'a option
type 'a sequence = ('a -> unit) -> unit
type t = private string

A UTF8 string

val equal : t -> t -> bool
val hash : t -> int
val compare : t -> t -> int
val pp : Format.formatter -> t -> unit
val to_string : t -> string

Identity.

exception Malformed of string * int

Malformed string at given offset

val to_gen : ?⁠idx:int -> t -> uchar gen

Generator of unicode codepoints.

parameter idx

offset where to start the decoding.

val to_seq : ?⁠idx:int -> t -> uchar sequence

Iter of unicode codepoints.

parameter idx

offset where to start the decoding.

val to_list : ?⁠idx:int -> t -> uchar list

List of unicode codepoints.

parameter idx

offset where to start the decoding.

val fold : ?⁠idx:int -> ('a -> uchar -> 'a) -> 'a -> t -> 'a
val iter : ?⁠idx:int -> (uchar -> unit) -> t -> unit
val n_chars : t -> int

Number of characters.

val n_bytes : t -> int

Number of bytes.

val map : (uchar -> uchar) -> t -> t
val filter_map : (uchar -> uchar option) -> t -> t
val flat_map : (uchar -> t) -> t -> t
val append : t -> t -> t
val concat : t -> t list -> t
val of_seq : uchar sequence -> t
val of_gen : uchar gen -> t
val of_list : uchar list -> t
val of_string_exn : string -> t

Validate string by checking it is valid UTF8.

raises Invalid_argument

if the string is not valid UTF8.

val of_string : string -> t option

Safe version of of_string_exn.

val is_valid : string -> bool

Valid UTF8?

val unsafe_of_string : string -> t

Conversion from a string without validating. Upon iteration, if an invalid substring is met, Malformed will be raised.

\ No newline at end of file diff --git a/dev/containers/CCVector/index.html b/dev/containers/CCVector/index.html index 3fad8da5..40494b1d 100644 --- a/dev/containers/CCVector/index.html +++ b/dev/containers/CCVector/index.html @@ -1,23 +1,2 @@ -CCVector (containers.CCVector)

Module CCVector

Growable, mutable vector

type ro = [
| `RO
]
type rw = [
| `RW
]

Mutability is rw (read-write) or ro (read-only).

type ('a, 'mut) t

The type of a vector of elements of type 'a, with -a mutability flat 'mut.

type 'a vector = ('arwt

Type synonym: a 'a vector is mutable.

type 'a ro_vector = ('arot

Alias for immutable vectors.

  • Since: 0.15
type 'a sequence = ('a ‑> unit) ‑> unit
type 'a klist = unit ‑> [ `Nil | `Cons of 'a * 'a klist ]
type 'a gen = unit ‑> 'a option
type 'a equal = 'a ‑> 'a ‑> bool
type 'a ord = 'a ‑> 'a ‑> int
type 'a printer = Format.formatter ‑> 'a ‑> unit
val freeze : ('a_t ‑> ('arot

Make an immutable vector (no copy! Don't use the old version).

val freeze_copy : ('a_t ‑> ('arot

Copy the vector into an immutable version.

val create : unit ‑> ('arwt

Create a new, empty vector.

val create_with : ?⁠capacity:int ‑> 'a ‑> ('arwt

Create a new vector, using the given value as a filler.

  • Parameter capacity: the size of the underlying array. -caution: the value will likely not be GC'd before the vector is.
val return : 'a ‑> ('a'mutt

Singleton vector.

  • Since: 0.14
val make : int ‑> 'a ‑> ('a'mutt

make n x makes a vector of size n, filled with x.

val init : int ‑> (int ‑> 'a) ‑> ('a'mutt

Init the vector with the given function and size.

val clear : ('arwt ‑> unit

Clear the content of the vector.

val ensure_with : init:'a ‑> ('arwt ‑> int ‑> unit

Hint to the vector that it should have at least the given capacity.

  • Parameter init: if capacity v = 0, used as a filler -element for the underlying array (see create_with).
  • Since: 0.14
val ensure : ('arwt ‑> int ‑> unit

Hint to the vector that it should have at least the given capacity. -Just a hint, will not be enforced if the vector is empty and init -is not provided.

val is_empty : ('a_t ‑> bool

Is the vector empty?

val push : ('arwt ‑> 'a ‑> unit

Add an element at the end of the vector.

val append : ('arwt ‑> ('a_t ‑> unit

append a b adds all elements of b to a.

val append_array : ('arwt ‑> 'a array ‑> unit

Like append, with an array.

val append_seq : ('arwt ‑> 'a sequence ‑> unit

Append content of sequence.

val append_list : ('arwt ‑> 'a list ‑> unit

Append content of list.

  • Since: 0.14
val append_gen : ('arwt ‑> 'a gen ‑> unit

Append content of generator.

  • Since: 0.20
val equal : 'a equal ‑> ('a_t equal
val compare : 'a ord ‑> ('a_t ord

Total ordering on vectors. Lexicographic comparison.

exception Empty

Raised on empty stack.

val pop : ('arwt ‑> 'a option

Remove last element, or None.

val pop_exn : ('arwt ‑> 'a

Remove last element, or raise a Failure if empty.

  • Raises Empty: on an empty vector.
val top : ('a_t ‑> 'a option

Top element, if present.

  • Since: 0.6
val top_exn : ('a_t ‑> 'a

Top element, if present.

  • Raises Empty: on an empty vector.
  • Since: 0.6
val copy : ('a_t ‑> ('a'mutt

Shallow copy (may give an immutable or mutable vector).

val shrink : ('arwt ‑> int ‑> unit

Shrink to the given size (remove elements above this size). -Does nothing if the parameter is bigger than the current size.

val member : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> ('a_t ‑> bool

Is the element a member of the vector?

val sort : ('a ‑> 'a ‑> int) ‑> ('a_t ‑> ('a'mutt

Sort the vector, returning a copy of it that is sorted -w.r.t the given ordering. The vector itself is unchanged.

val sort' : ('a ‑> 'a ‑> int) ‑> ('arwt ‑> unit

Sort the vector in place (modifying it).

val uniq_sort : ('a ‑> 'a ‑> int) ‑> ('arwt ‑> unit

Sort the array and remove duplicates, in place (e.g. modifying -the vector itself).

val iter : ('a ‑> unit) ‑> ('a_t ‑> unit

Iterate on the vector's content.

val iteri : (int ‑> 'a ‑> unit) ‑> ('a_t ‑> unit

Iterate on the vector, with indexes.

val map : ('a ‑> 'b) ‑> ('a_t ‑> ('b'mutt

Map elements of the vector, yielding a new vector.

val filter : ('a ‑> bool) ‑> ('a_t ‑> ('a'mutt

Filter elements from the vector. filter p v leaves v unchanged but -returns a new vector that only contains elements of v satisfying p.

val filter' : ('a ‑> bool) ‑> ('arwt ‑> unit

Filter elements in place.

val fold : ('b ‑> 'a ‑> 'b) ‑> 'b ‑> ('a_t ‑> 'b

Fold on elements of the vector

val exists : ('a ‑> bool) ‑> ('a_t ‑> bool

Existential test (is there an element that satisfies the predicate?).

val for_all : ('a ‑> bool) ‑> ('a_t ‑> bool

Universal test (do all the elements satisfy the predicate?).

val find : ('a ‑> bool) ‑> ('a_t ‑> 'a option

Find an element that satisfies the predicate.

val find_exn : ('a ‑> bool) ‑> ('a_t ‑> 'a

Find an element that satisfies the predicate, or

  • Raises Not_found: if no element does.
val find_map : ('a ‑> 'b option) ‑> ('a_t ‑> 'b option

find_map f v returns the first Some y = f x for x in v, -or None if f x = None for each x in v.

  • Since: 0.14
val filter_map : ('a ‑> 'b option) ‑> ('a_t ‑> ('b'mutt

Map elements with a function, possibly filtering some of them out.

val flat_map : ('a ‑> ('b_t) ‑> ('a_t ‑> ('b'mutt

Map each element to a sub-vector.

val flat_map_seq : ('a ‑> 'b sequence) ‑> ('a_t ‑> ('b'mutt

Like flat_map, but using sequence for -intermediate collections.

  • Since: 0.14
val flat_map_list : ('a ‑> 'b list) ‑> ('a_t ‑> ('b'mutt

Like flat_map, but using list for -intermediate collections.

  • Since: 0.14
val (>>=) : ('a_t ‑> ('a ‑> ('b_t) ‑> ('b'mutt

Infix version of flat_map.

val (>|=) : ('a_t ‑> ('a ‑> 'b) ‑> ('b'mutt

Infix version of map.

val get : ('a_t ‑> int ‑> 'a

Access element by its index, or

  • Raises Invalid_argument: if bad index.
val set : ('arwt ‑> int ‑> 'a ‑> unit

Modify element at given index, or

  • Raises Invalid_argument: if bad index.
val remove : ('arwt ‑> int ‑> unit

Remove the n-th element of the vector. Does NOT preserve the order -of the elements (might swap with the last element).

val rev : ('a_t ‑> ('a'mutt

Reverse the vector.

val rev_in_place : ('arwt ‑> unit

Reverse the vector in place.

  • Since: 0.14
val rev_iter : ('a ‑> unit) ‑> ('a_t ‑> unit

rev_iter f a is the same as iter f (rev a), only more efficient.

  • Since: 0.14
val size : ('a_t ‑> int

Number of elements in the vector.

val length : (__t ‑> int

Synonym for size.

val capacity : (__t ‑> int

Number of elements the vector can contain without being resized.

val unsafe_get_array : ('arwt ‑> 'a array

Access the underlying shared array (do not modify!). -unsafe_get_array v is longer than size v, but elements at higher -index than size v are undefined (do not access!).

val (--) : int ‑> int ‑> (int, 'mutt

Range of integers, either ascending or descending (both included, -therefore the result is never empty). -Example: 1 -- 10 returns the vector [1;2;3;4;5;6;7;8;9;10].

val (--^) : int ‑> int ‑> (int, 'mutt

Range of integers, either ascending or descending, but excluding right. -Example: 1 --^ 10 returns the vector [1;2;3;4;5;6;7;8;9].

  • Since: 0.17
val of_array : 'a array ‑> ('a'mutt

of_array a returns a vector corresponding to the array a. Operates in O(n) time.

val of_list : 'a list ‑> ('a'mutt
val to_array : ('a_t ‑> 'a array

to_array v returns an array corresponding to the vector v.

val to_list : ('a_t ‑> 'a list

Return a list with the elements contained in the vector.

val of_seq : ?⁠init:('arwt ‑> 'a sequence ‑> ('arwt
val to_seq : ('a_t ‑> 'a sequence

Return a sequence with the elements contained in the vector.

val to_seq_rev : ('a_t ‑> 'a sequence

to_seq_rev v returns the sequence of elements of v in reverse order, -that is, the last elements of v are iterated on first.

  • Since: 0.14
val slice : ('arwt ‑> 'a array * int * int

Vector as an array slice. By doing it we expose the internal array, so -be careful!.

val slice_seq : ('a_t ‑> int ‑> int ‑> 'a sequence

slice_seq v start len is the sequence of elements from v.(start) -to v.(start+len-1).

val of_klist : ?⁠init:('arwt ‑> 'a klist ‑> ('arwt
val to_klist : ('a_t ‑> 'a klist
val of_gen : ?⁠init:('arwt ‑> 'a gen ‑> ('arwt
val to_gen : ('a_t ‑> 'a gen
val pp : ?⁠start:string ‑> ?⁠stop:string ‑> ?⁠sep:string ‑> 'a printer ‑> ('a_t printer
\ No newline at end of file +CCVector (containers.CCVector)

Module CCVector

Growable, mutable vector

type ro = [
| `RO
]
type rw = [
| `RW
]
type ('a, 'mut) t

The type of a vector of elements of type 'a, with a mutability flat 'mut.

type 'a vector = ('arw) t

Type synonym: a 'a vector is mutable.

type 'a ro_vector = ('aro) t

Alias for immutable vectors.

since
0.15
type 'a sequence = ('a -> unit) -> unit
type 'a klist = unit -> [ `Nil | `Cons of 'a * 'a klist ]
type 'a gen = unit -> 'a option
type 'a equal = 'a -> 'a -> bool
type 'a ord = 'a -> 'a -> int
type 'a printer = Format.formatter -> 'a -> unit
val freeze : ('a_) t -> ('aro) t

Make an immutable vector (no copy! Don't use the old version).

val freeze_copy : ('a_) t -> ('aro) t

Copy the vector into an immutable version.

val create : unit -> ('arw) t

Create a new, empty vector.

val create_with : ?⁠capacity:int -> 'a -> ('arw) t

Create a new vector, using the given value as a filler.

parameter capacity

the size of the underlying array. caution: the value will likely not be GC'd before the vector is.

val return : 'a -> ('a'mut) t

Singleton vector.

since
0.14
val make : int -> 'a -> ('a'mut) t

make n x makes a vector of size n, filled with x.

val init : int -> (int -> 'a) -> ('a'mut) t

Init the vector with the given function and size.

val clear : ('arw) t -> unit

Clear the content of the vector.

val ensure_with : init:'a -> ('arw) t -> int -> unit

Hint to the vector that it should have at least the given capacity.

parameter init

if capacity v = 0, used as a filler element for the underlying array (see create_with).

since
0.14
val ensure : ('arw) t -> int -> unit

Hint to the vector that it should have at least the given capacity. Just a hint, will not be enforced if the vector is empty and init is not provided.

val is_empty : ('a_) t -> bool

Is the vector empty?

val push : ('arw) t -> 'a -> unit

Add an element at the end of the vector.

val append : ('arw) t -> ('a_) t -> unit

append a b adds all elements of b to a.

val append_array : ('arw) t -> 'a array -> unit

Like append, with an array.

val append_seq : ('arw) t -> 'a sequence -> unit

Append content of sequence.

val append_list : ('arw) t -> 'a list -> unit

Append content of list.

since
0.14
val append_gen : ('arw) t -> 'a gen -> unit

Append content of generator.

since
0.20
val equal : 'a equal -> ('a_) t equal
val compare : 'a ord -> ('a_) t ord

Total ordering on vectors. Lexicographic comparison.

exception Empty

Raised on empty stack.

val pop : ('arw) t -> 'a option

Remove last element, or None.

val pop_exn : ('arw) t -> 'a

Remove last element, or raise a Failure if empty.

raises Empty

on an empty vector.

val top : ('a_) t -> 'a option

Top element, if present.

since
0.6
val top_exn : ('a_) t -> 'a

Top element, if present.

raises Empty

on an empty vector.

since
0.6
val copy : ('a_) t -> ('a'mut) t

Shallow copy (may give an immutable or mutable vector).

val shrink : ('arw) t -> int -> unit

Shrink to the given size (remove elements above this size). Does nothing if the parameter is bigger than the current size.

val member : eq:('a -> 'a -> bool) -> 'a -> ('a_) t -> bool

Is the element a member of the vector?

val sort : ('a -> 'a -> int) -> ('a_) t -> ('a'mut) t

Sort the vector, returning a copy of it that is sorted w.r.t the given ordering. The vector itself is unchanged.

val sort' : ('a -> 'a -> int) -> ('arw) t -> unit

Sort the vector in place (modifying it).

val uniq_sort : ('a -> 'a -> int) -> ('arw) t -> unit

Sort the array and remove duplicates, in place (e.g. modifying the vector itself).

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

Iterate on the vector's content.

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

Iterate on the vector, with indexes.

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

Map elements of the vector, yielding a new vector.

val map_in_place : ('a -> 'a) -> ('a_) t -> unit

Map elements of the vector in place

since
2.3
val filter : ('a -> bool) -> ('a_) t -> ('a'mut) t

Filter elements from the vector. filter p v leaves v unchanged but returns a new vector that only contains elements of v satisfying p.

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

Filter elements in place.

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

Fold on elements of the vector

val exists : ('a -> bool) -> ('a_) t -> bool

Existential test (is there an element that satisfies the predicate?).

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

Universal test (do all the elements satisfy the predicate?).

val find : ('a -> bool) -> ('a_) t -> 'a option

Find an element that satisfies the predicate.

val find_exn : ('a -> bool) -> ('a_) t -> 'a

Find an element that satisfies the predicate, or

raises Not_found

if no element does.

val find_map : ('a -> 'b option) -> ('a_) t -> 'b option

find_map f v returns the first Some y = f x for x in v, or None if f x = None for each x in v.

since
0.14
val filter_map : ('a -> 'b option) -> ('a_) t -> ('b'mut) t

Map elements with a function, possibly filtering some of them out.

val filter_map_in_place : ('a -> 'a option) -> ('a_) t -> unit

Filter-map elements of the vector in place

since
2.3
val flat_map : ('a -> ('b_) t) -> ('a_) t -> ('b'mut) t

Map each element to a sub-vector.

val flat_map_seq : ('a -> 'b sequence) -> ('a_) t -> ('b'mut) t

Like flat_map, but using sequence for intermediate collections.

since
0.14
val flat_map_list : ('a -> 'b list) -> ('a_) t -> ('b'mut) t

Like flat_map, but using list for intermediate collections.

since
0.14
val (>>=) : ('a_) t -> ('a -> ('b_) t) -> ('b'mut) t

Infix version of flat_map.

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

Infix version of map.

val get : ('a_) t -> int -> 'a

Access element by its index, or

raises Invalid_argument

if bad index.

val set : ('arw) t -> int -> 'a -> unit

Modify element at given index, or

raises Invalid_argument

if bad index.

val remove : ('arw) t -> int -> unit

Remove the n-th element of the vector. Does NOT preserve the order of the elements (might swap with the last element).

val rev : ('a_) t -> ('a'mut) t

Reverse the vector.

val rev_in_place : ('arw) t -> unit

Reverse the vector in place.

since
0.14
val rev_iter : ('a -> unit) -> ('a_) t -> unit

rev_iter f a is the same as iter f (rev a), only more efficient.

since
0.14
val size : ('a_) t -> int

Number of elements in the vector.

val length : (__) t -> int

Synonym for size.

val capacity : (__) t -> int

Number of elements the vector can contain without being resized.

val unsafe_get_array : ('arw) t -> 'a array

Access the underlying shared array (do not modify!). unsafe_get_array v is longer than size v, but elements at higher index than size v are undefined (do not access!).

val (--) : int -> int -> (int, 'mut) t

Range of integers, either ascending or descending (both included, therefore the result is never empty). Example: 1 -- 10 returns the vector [1;2;3;4;5;6;7;8;9;10].

val (--^) : int -> int -> (int, 'mut) t

Range of integers, either ascending or descending, but excluding right. Example: 1 --^ 10 returns the vector [1;2;3;4;5;6;7;8;9].

since
0.17
val of_array : 'a array -> ('a'mut) t

of_array a returns a vector corresponding to the array a. Operates in O(n) time.

val of_list : 'a list -> ('a'mut) t
val to_array : ('a_) t -> 'a array

to_array v returns an array corresponding to the vector v.

val to_list : ('a_) t -> 'a list

Return a list with the elements contained in the vector.

val of_seq : ?⁠init:('arw) t -> 'a sequence -> ('arw) t
val to_seq : ('a_) t -> 'a sequence

Return a sequence with the elements contained in the vector.

val to_seq_rev : ('a_) t -> 'a sequence

to_seq_rev v returns the sequence of elements of v in reverse order, that is, the last elements of v are iterated on first.

since
0.14
val slice : ('arw) t -> 'a array * int * int

Vector as an array slice. By doing it we expose the internal array, so be careful!.

val slice_seq : ('a_) t -> int -> int -> 'a sequence

slice_seq v start len is the sequence of elements from v.(start) to v.(start+len-1).

val fill_empty_slots_with : ('a_) t -> 'a -> unit

fill_empty_slots_with v x puts x in the slots of v's underlying array that are not used (ie in the last capacity v - length v slots). This is useful if you removed some elements from the vector and want to be sure they can be GC'd by erasing them from the vector.

since
2.4
val of_klist : ?⁠init:('arw) t -> 'a klist -> ('arw) t
val to_klist : ('a_) t -> 'a klist
val of_gen : ?⁠init:('arw) t -> 'a gen -> ('arw) t
val to_gen : ('a_) t -> 'a gen
val pp : ?⁠start:string -> ?⁠stop:string -> ?⁠sep:string -> 'a printer -> ('a_) t printer
\ 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 6a64d417..e1883401 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 Containers.Hashtbl.Make

Parameters

H : Hashtbl.HashedType

Signature

type key = H.t
type 'a t = 'a 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 ‑> Hashtbl.statistics
\ No newline at end of file +Make (containers.Containers.Hashtbl.Make)

Module Hashtbl.Make

Parameters

Signature

type key = H.t
type 'a t = 'a 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 -> Hashtbl.statistics
\ No newline at end of file diff --git a/dev/containers/Containers/Hashtbl/MakeSeeded/argument-1-H/index.html b/dev/containers/Containers/Hashtbl/MakeSeeded/argument-1-H/index.html index 6ee3e6f7..e90f4416 100644 --- a/dev/containers/Containers/Hashtbl/MakeSeeded/argument-1-H/index.html +++ b/dev/containers/Containers/Hashtbl/MakeSeeded/argument-1-H/index.html @@ -1,2 +1,2 @@ -1-H (containers.Containers.Hashtbl.MakeSeeded.1-H)

Parameter Containers.Hashtbl.MakeSeeded.1-H

type t
val equal : t ‑> t ‑> bool
val hash : int ‑> t ‑> int
\ No newline at end of file +1-H (containers.Containers.Hashtbl.MakeSeeded.1-H)

Parameter MakeSeeded.1-H

type t
val equal : t -> t -> bool
val hash : int -> t -> int
\ 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 2c54f0b7..657a3864 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 Containers.Hashtbl.MakeSeeded

Parameters

Signature

type key = H.t
type 'a 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
\ No newline at end of file +MakeSeeded (containers.Containers.Hashtbl.MakeSeeded)

Module Hashtbl.MakeSeeded

Parameters

Signature

type key = H.t
type 'a 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
\ No newline at end of file diff --git a/dev/containers/Containers/Hashtbl/index.html b/dev/containers/Containers/Hashtbl/index.html index a813928c..2abcdeb3 100644 --- a/dev/containers/Containers/Hashtbl/index.html +++ b/dev/containers/Containers/Hashtbl/index.html @@ -1,21 +1,2 @@ -Hashtbl (containers.Containers.Hashtbl)

Module Containers.Hashtbl

include module type of Hashtbl with type Hashtbl.statistics = Hashtbl.statistics and module Hashtbl.Make = Hashtbl.Make and type ('a, 'b) Hashtbl.t = ('a'b) Hashtbl.t
type ('a, 'b) t = ('a'b) Hashtbl.t
val create : ?⁠random:bool ‑> int ‑> ('a'bt
val clear : ('a'bt ‑> unit
val reset : ('a'bt ‑> unit
val copy : ('a'bt ‑> ('a'bt
val add : ('a'bt ‑> 'a ‑> 'b ‑> unit
val find : ('a'bt ‑> 'a ‑> 'b
val find_opt : ('a'bt ‑> 'a ‑> 'b option
val find_all : ('a'bt ‑> 'a ‑> 'b list
val mem : ('a'bt ‑> 'a ‑> bool
val remove : ('a'bt ‑> 'a ‑> unit
val replace : ('a'bt ‑> 'a ‑> 'b ‑> unit
val iter : ('a ‑> 'b ‑> unit) ‑> ('a'bt ‑> unit
val filter_map_inplace : ('a ‑> 'b ‑> 'b option) ‑> ('a'bt ‑> unit
val fold : ('a ‑> 'b ‑> 'c ‑> 'c) ‑> ('a'bt ‑> 'c ‑> 'c
val length : ('a'bt ‑> int
val randomize : unit ‑> unit
val is_randomized : unit ‑> bool
type statistics = Hashtbl.statistics = {
num_bindings : int;
num_buckets : int;
max_bucket_length : int;
bucket_histogram : int array;
}
val stats : ('a'bt ‑> statistics
module type HashedType : sig ... end
module type S : sig ... end
module Make : functor (H : Hashtbl.HashedType) -> sig ... end
module type SeededHashedType : sig ... end
module type SeededS : sig ... end
module MakeSeeded : functor (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 CCHashtbl.Poly
val get : ('a'b) Hashtbl.t ‑> 'a ‑> 'b option

Safe version of Hashtbl.find.

val get_or : ('a'b) 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) Hashtbl.t ‑> 'a CCHashtbl.sequence

Iterate on keys (similar order as Hashtbl.iter).

val values : ('a'b) Hashtbl.t ‑> 'b CCHashtbl.sequence

Iterate on values in the table.

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

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

  • Since: 0.8
val values_list : ('a'b) Hashtbl.t ‑> 'b list

values_list t is the list of values in t.

  • Since: 0.8
val map_list : ('a ‑> 'b ‑> 'c) ‑> ('a'b) Hashtbl.t ‑> 'c list

Map on a hashtable's items, collect into a list.

val incr : ?⁠by:int ‑> ('a, int) 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) Hashtbl.t ‑> 'a ‑> unit

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_seq : ('a'b) Hashtbl.t ‑> ('a * 'b) CCHashtbl.sequence

Iterate on bindings in the table.

val add_list : ('a'b list) 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_seq : ('a'b) Hashtbl.t ‑> ('a * 'b) CCHashtbl.sequence ‑> unit

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

  • Since: 0.16
val of_seq : ('a * 'b) CCHashtbl.sequence ‑> ('a'b) Hashtbl.t

From the given bindings, added in order.

val add_seq_count : ('a, int) Hashtbl.t ‑> 'a CCHashtbl.sequence ‑> 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.

  • Since: 0.16
val of_seq_count : 'a CCHashtbl.sequence ‑> ('a, int) Hashtbl.t

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

  • Since: 0.16
val to_list : ('a'b) Hashtbl.t ‑> ('a * 'b) list

List of bindings (order unspecified).

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

Build a table from the given list 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 update : ('a'b) 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) 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 : 'a CCHashtbl.printer ‑> 'b CCHashtbl.printer ‑> ('a'b) Hashtbl.t CCHashtbl.printer
module type S' = CCHashtbl.S
module Make' = CCHashtbl.Make
\ No newline at end of file +Hashtbl (containers.Containers.Hashtbl)

Module Containers.Hashtbl

since
0.14
include module type of Hashtbl with type Hashtbl.statistics = Hashtbl.statistics and module Hashtbl.Make = Hashtbl.Make and type ('a, 'b) Hashtbl.t = ('a'b) Hashtbl.t
type ('a, 'b) t = ('a'b) 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
type statistics = Hashtbl.statistics = {
num_bindings : int;
num_buckets : int;
max_bucket_length : int;
bucket_histogram : int array;
}
val stats : ('a'b) t -> statistics
module type HashedType = sig ... end
module type S = sig ... end
module Make : functor (H : Hashtbl.HashedType) -> sig ... end
module type SeededHashedType = sig ... end
module type SeededS = sig ... end
module MakeSeeded : functor (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 CCHashtbl.Poly
val get : ('a'b) Hashtbl.t -> 'a -> 'b option

Safe version of Hashtbl.find.

val get_or : ('a'b) 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) Hashtbl.t -> 'a CCHashtbl.sequence

Iterate on keys (similar order as Hashtbl.iter).

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

Iterate on values in the table.

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

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

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

values_list t is the list of values in t.

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

Map on a hashtable's items, collect into a list.

val incr : ?⁠by:int -> ('a, int) 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) Hashtbl.t -> 'a -> unit

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_seq : ('a'b) Hashtbl.t -> ('a * 'b) CCHashtbl.sequence

Iterate on bindings in the table.

val add_list : ('a'b list) 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_seq : ('a'b) Hashtbl.t -> ('a * 'b) CCHashtbl.sequence -> unit

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

since
0.16
val of_seq : ('a * 'b) CCHashtbl.sequence -> ('a'b) Hashtbl.t

From the given bindings, added in order.

val add_seq_count : ('a, int) Hashtbl.t -> 'a CCHashtbl.sequence -> 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.

since
0.16
val of_seq_count : 'a CCHashtbl.sequence -> ('a, int) Hashtbl.t

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

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

List of bindings (order unspecified).

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

Build a table from the given list 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 update : ('a'b) 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) 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 : 'a CCHashtbl.printer -> 'b CCHashtbl.printer -> ('a'b) Hashtbl.t CCHashtbl.printer

Printer for table. 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/Containers/Hashtbl/module-type-HashedType/index.html b/dev/containers/Containers/Hashtbl/module-type-HashedType/index.html index 5ebe8dd7..550d5afc 100644 --- a/dev/containers/Containers/Hashtbl/module-type-HashedType/index.html +++ b/dev/containers/Containers/Hashtbl/module-type-HashedType/index.html @@ -1,2 +1,2 @@ -HashedType (containers.Containers.Hashtbl.HashedType)

Module type Containers.Hashtbl.HashedType

type t
val equal : t ‑> t ‑> bool
val hash : t ‑> int
\ No newline at end of file +HashedType (containers.Containers.Hashtbl.HashedType)

Module type Hashtbl.HashedType

type t
val equal : t -> t -> bool
val hash : t -> int
\ No newline at end of file diff --git a/dev/containers/Containers/Hashtbl/module-type-S'/index.html b/dev/containers/Containers/Hashtbl/module-type-S'/index.html index 8262087a..5e656e4c 100644 --- a/dev/containers/Containers/Hashtbl/module-type-S'/index.html +++ b/dev/containers/Containers/Hashtbl/module-type-S'/index.html @@ -1,21 +1,2 @@ -S' (containers.Containers.Hashtbl.S')

Module type Containers.Hashtbl.S'

include Hashtbl.S
type key
type 'a 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 ‑> Hashtbl.statistics
val get : 'a t ‑> key ‑> 'a option

Safe version of Hashtbl.find.

val get_or : 'a t ‑> key ‑> default:'a ‑> 'a

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 add_list : 'a list t ‑> key ‑> 'a ‑> 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 incr : ?⁠by:int ‑> int t ‑> key ‑> 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 ‑> int t ‑> key ‑> unit

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 keys : 'a t ‑> key CCHashtbl.sequence

Iterate on keys (similar order as Hashtbl.iter).

val values : 'a t ‑> 'a CCHashtbl.sequence

Iterate on values in the table.

val keys_list : _ t ‑> key list

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

  • Since: 0.8
val values_list : 'a t ‑> 'a list

values_list t is the list of values in t.

  • Since: 0.8
val map_list : (key ‑> 'a ‑> 'b) ‑> 'a t ‑> 'b list

Map on a hashtable's items, collect into a list.

val to_seq : 'a t ‑> (key * 'a) CCHashtbl.sequence

Iterate on values in the table.

val of_seq : (key * 'a) CCHashtbl.sequence ‑> 'a t

From the given bindings, added in order.

val add_seq : 'a t ‑> (key * 'a) CCHashtbl.sequence ‑> unit

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

  • Since: 0.16
val add_seq_count : int t ‑> key CCHashtbl.sequence ‑> 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.

  • Since: 0.16
val of_seq_count : key CCHashtbl.sequence ‑> int t

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

  • Since: 0.16
val to_list : 'a t ‑> (key * 'a) list

List of bindings (order unspecified).

val of_list : (key * 'a) list ‑> 'a t

Build a table from the given list 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 update : 'a t ‑> f:(key ‑> 'a option ‑> 'a option) ‑> k:key ‑> 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 t ‑> f:(key ‑> 'a) ‑> k:key ‑> 'a

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
\ No newline at end of file +S' (containers.Containers.Hashtbl.S')

Module type Hashtbl.S'

include Hashtbl.S
type key
type 'a 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 -> Hashtbl.statistics
val get : 'a t -> key -> 'a option

Safe version of Hashtbl.find.

val get_or : 'a t -> key -> default:'a -> 'a

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 add_list : 'a list t -> key -> 'a -> 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 incr : ?⁠by:int -> int t -> key -> 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 -> int t -> key -> unit

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 keys : 'a t -> key CCHashtbl.sequence

Iterate on keys (similar order as Hashtbl.iter).

val values : 'a t -> 'a CCHashtbl.sequence

Iterate on values in the table.

val keys_list : _ t -> key list

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

since
0.8
val values_list : 'a t -> 'a list

values_list t is the list of values in t.

since
0.8
val map_list : (key -> 'a -> 'b) -> 'a t -> 'b list

Map on a hashtable's items, collect into a list.

val to_seq : 'a t -> (key * 'a) CCHashtbl.sequence

Iterate on values in the table.

val of_seq : (key * 'a) CCHashtbl.sequence -> 'a t

From the given bindings, added in order.

val add_seq : 'a t -> (key * 'a) CCHashtbl.sequence -> unit

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

since
0.16
val add_seq_count : int t -> key CCHashtbl.sequence -> 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.

since
0.16
val of_seq_count : key CCHashtbl.sequence -> int t

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

since
0.16
val to_list : 'a t -> (key * 'a) list

List of bindings (order unspecified).

val of_list : (key * 'a) list -> 'a t

Build a table from the given list 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 update : 'a t -> f:(key -> 'a option -> 'a option) -> k:key -> 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 t -> f:(key -> 'a) -> k:key -> 'a

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 : key CCHashtbl.printer -> 'a CCHashtbl.printer -> 'a t CCHashtbl.printer

Printer for tables. Renamed from print since 2.0.

since
0.13
\ No newline at end of file diff --git a/dev/containers/Containers/Hashtbl/module-type-S/index.html b/dev/containers/Containers/Hashtbl/module-type-S/index.html index 1fc7cd07..49738ab9 100644 --- a/dev/containers/Containers/Hashtbl/module-type-S/index.html +++ b/dev/containers/Containers/Hashtbl/module-type-S/index.html @@ -1,2 +1,2 @@ -S (containers.Containers.Hashtbl.S)

Module type Containers.Hashtbl.S

type key
type 'a 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 ‑> statistics
\ No newline at end of file +S (containers.Containers.Hashtbl.S)

Module type Hashtbl.S

type key
type 'a 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 -> statistics
\ No newline at end of file diff --git a/dev/containers/Containers/Hashtbl/module-type-SeededHashedType/index.html b/dev/containers/Containers/Hashtbl/module-type-SeededHashedType/index.html index e7c21d46..65a3daba 100644 --- a/dev/containers/Containers/Hashtbl/module-type-SeededHashedType/index.html +++ b/dev/containers/Containers/Hashtbl/module-type-SeededHashedType/index.html @@ -1,2 +1,2 @@ -SeededHashedType (containers.Containers.Hashtbl.SeededHashedType)

Module type Containers.Hashtbl.SeededHashedType

type t
val equal : t ‑> t ‑> bool
val hash : int ‑> t ‑> int
\ No newline at end of file +SeededHashedType (containers.Containers.Hashtbl.SeededHashedType)

Module type Hashtbl.SeededHashedType

type t
val equal : t -> t -> bool
val hash : int -> t -> int
\ No newline at end of file diff --git a/dev/containers/Containers/Hashtbl/module-type-SeededS/index.html b/dev/containers/Containers/Hashtbl/module-type-SeededS/index.html index 906f36c0..b0ededae 100644 --- a/dev/containers/Containers/Hashtbl/module-type-SeededS/index.html +++ b/dev/containers/Containers/Hashtbl/module-type-SeededS/index.html @@ -1,2 +1,2 @@ -SeededS (containers.Containers.Hashtbl.SeededS)

Module type Containers.Hashtbl.SeededS

type key
type 'a 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
\ No newline at end of file +SeededS (containers.Containers.Hashtbl.SeededS)

Module type Hashtbl.SeededS

type key
type 'a 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
\ No newline at end of file diff --git a/dev/containers/Containers/index.html b/dev/containers/Containers/index.html index 00f9e02d..2569d292 100644 --- a/dev/containers/Containers/index.html +++ b/dev/containers/Containers/index.html @@ -1,2 +1,2 @@ -Containers (containers.Containers)

Module Containers

Drop-In replacement to Stdlib

module Array = CCArray
module ArrayLabels = CCArrayLabels
module Array_slice = CCArray_slice
module Bool = CCBool
module Char = Char
module Equal = CCEqual
module Float = CCFloat
module Format = CCFormat
module Fun = CCFun
module Hash = CCHash
module Hashtbl : sig ... end
module Heap = CCHeap
module Int = CCInt
module Int32 = CCInt32
module Int64 = CCInt64
module IO = CCIO
module List = CCList
module ListLabels = CCListLabels
module Map = CCMap
module Nativeint = CCNativeint
module Option = CCOpt
module Ord = CCOrd
module Pair = CCPair
module Parse = CCParse
module Random = CCRandom
module Ref = CCRef
module Result = CCResult
module Set = CCSet
module String = CCString
module Vector = CCVector
module Monomorphic = CCMonomorphic
module Utf8_string = CCUtf8_string
include Monomorphic
val (=) : int ‑> int ‑> bool
val (<>) : int ‑> int ‑> bool
val (<) : int ‑> int ‑> bool
val (>) : int ‑> int ‑> bool
val (<=) : int ‑> int ‑> bool
val (>=) : int ‑> int ‑> bool
val compare : int ‑> int ‑> int
val min : int ‑> int ‑> int
val max : int ‑> int ‑> int
val (=.) : float ‑> float ‑> bool
val (<>.) : float ‑> float ‑> bool
val (<.) : float ‑> float ‑> bool
val (>.) : float ‑> float ‑> bool
val (<=.) : float ‑> float ‑> bool
val (>=.) : float ‑> float ‑> bool
val (==) : [ `Consider_using_CCEqual_physical ]
  • Deprecated Please use CCEqual.physical or Pervasives.(==) instead.
val (!=) : [ `Consider_using_CCEqual_physical ]
  • Deprecated Please use [not CCEqual.physical] or Pervasives.(!=) instead.
\ No newline at end of file +Containers (containers.Containers)

Module Containers

Drop-In replacement to Stdlib

module Array = CCArray
module Array_slice = CCArray_slice
module Bool = CCBool
module Char = Char
module Equal = CCEqual
module Float = CCFloat
module Format = CCFormat
module Fun = CCFun
module Hash = CCHash
module Hashtbl : sig ... end
module Heap = CCHeap
module Int = CCInt
module Int32 = CCInt32
module Int64 = CCInt64
module IO = CCIO
module List = CCList
module Map = CCMap
module Nativeint = CCNativeint
module Option = CCOpt
module Ord = CCOrd
module Pair = CCPair
module Parse = CCParse
module Random = CCRandom
module Ref = CCRef
module Result = CCResult
module Set = CCSet
module String = CCString
module Vector = CCVector
module Monomorphic = CCMonomorphic
module Utf8_string = CCUtf8_string
include Monomorphic

Shadow unsafe functions and operators from Pervasives

val (=) : int -> int -> bool
val (<>) : int -> int -> bool
val (<) : int -> int -> bool
val (>) : int -> int -> bool
val (<=) : int -> int -> bool
val (>=) : int -> int -> bool
val compare : int -> int -> int
val min : int -> int -> int
val max : int -> int -> int

Infix operators for Floats

val (=.) : float -> float -> bool
since
2.1
val (<>.) : float -> float -> bool
since
2.1
val (<.) : float -> float -> bool
since
2.1
val (>.) : float -> float -> bool
since
2.1
val (<=.) : float -> float -> bool
since
2.1
val (>=.) : float -> float -> bool
since
2.1

Shadow Dangerous Operators

val (==) : [ `Consider_using_CCEqual_physical ]
val (!=) : [ `Consider_using_CCEqual_physical ]
since
2.1
\ No newline at end of file diff --git a/dev/containers/index.html b/dev/containers/index.html index fb11fe9a..dd4fe1b3 100644 --- a/dev/containers/index.html +++ b/dev/containers/index.html @@ -1,3 +1,2 @@ -index (containers.index)

Library containers

-This library exposes the following toplevel modules:

CCArray
CCArrayLabels
CCArray_slice
CCBool
CCChar
CCEqual
CCFloat
CCFormat
CCFun
CCHash
CCHashtbl
CCHeap
CCIO
CCInt
CCInt32
CCInt64
CCList
CCListLabels
CCMap
CCNativeint
CCOpt
CCOrd
CCPair
CCParse
CCRandom
CCRef
CCResult
CCSet
CCString
CCUtf8_string
CCVector
Containers

.

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

containers index

Library containers

This library exposes the following toplevel modules:

Library containers.data

This library exposes the following toplevel modules:

Library containers.iter

This library exposes the following toplevel modules:

Library containers.monomorphic

The entry point of this library is the module: CCMonomorphic.

Library containers.sexp

This library exposes the following toplevel modules:

Library containers.thread

This library exposes the following toplevel modules:

Library containers.top

The entry point of this library is the module: Containers_top.

Library containers.unix

The entry point of this library is the module: CCUnix.

\ No newline at end of file diff --git a/dev/index.html b/dev/index.html index 86e83d8a..05854661 100644 --- a/dev/index.html +++ b/dev/index.html @@ -7,17 +7,13 @@ -
-

OCaml package documentation

-
    -
  1. containers.unix 2.1
  2. -
  3. containers.top 2.1
  4. -
  5. containers.thread 2.1
  6. -
  7. containers.sexp 2.1
  8. -
  9. containers.monomorphic 2.1
  10. -
  11. containers.iter 2.1
  12. -
  13. containers.data 2.1
  14. -
  15. containers 2.1
  16. -
- - +
+
+

OCaml package documentation

+
    +
  1. containers 2.5
  2. +
+
+
+ + \ No newline at end of file diff --git a/dev/odoc.css b/dev/odoc.css index e7808926..c86c417e 100644 --- a/dev/odoc.css +++ b/dev/odoc.css @@ -1,224 +1,754 @@ @charset "UTF-8"; -/* Copyright (c) 2016 Daniel C. Bünzli. All rights reserved. +/* Copyright (c) 2016 The odoc contributors. All rights reserved. Distributed under the ISC license, see terms at the end of the file. - odoc 1.2.0 */ + odoc 1.4.0 */ + +/* Fonts */ +@import url('https://fonts.googleapis.com/css?family=Fira+Mono:400,500'); +@import url('https://fonts.googleapis.com/css?family=Noticia+Text:400,400i,700'); +@import url('https://fonts.googleapis.com/css?family=Fira+Sans:400,400i,500,500i,600,600i,700,700i'); + /* Reset a few things. */ -html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre, -a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp, -small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li, -fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td, -article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup, -menu,nav,output,ruby,section,summary,time,mark,audio,video -{ margin:0; padding:0; border:0; /* outline: 0; */ - font-size:100%; font: inherit; line-height:inherit; vertical-align:baseline; - text-align: inherit; color: inherit; background: transparent; } +html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: inherit; + font: inherit; + line-height: inherit; + vertical-align: baseline; + text-align: inherit; + color: inherit; + background: transparent; +} -table { border-collapse: collapse; border-spacing: 0; } -*, *:before, *:after { box-sizing: border-box; } +table { + border-collapse: collapse; + border-spacing: 0; +} -body -{ font-family: Helvetica, "DejaVu Sans", Arial, sans-serif; - font-weight: normal; - font-size: 0.875rem; - line-height:1.25rem; +*, *:before, *:after { + box-sizing: border-box; +} + +html { + font-size: 15px; +} + +body { + font-family: "Fira Sans", Helvetica, Arial, sans-serif; text-align: left; - min-width: 40ex; - max-width: 78ex; - padding: 1.25rem; - margin-left: 3.75rem; - color: #222; background: #FAFAFA; } + color: #333; + background: #FFFFFF; +} + +.content { + max-width: 90ex; + margin-left: calc(10vw + 20ex); + margin-right: 4ex; + margin-top: 20px; + margin-bottom: 50px; + font-family: "Noticia Text", Georgia, serif; + line-height: 1.5; +} + +.content>header { + margin-bottom: 30px; +} + +.content>header nav { + font-family: "Fira Sans", Helvetica, Arial, sans-serif; +} /* Basic markup elements */ -b, strong { font-weight: bold; } -em { font-style: italic; } +b, strong { + font-weight: 500; +} -sup { vertical-align: super; } -sub { vertical-align: sub; } -sup, sub { font-size : 0.75rem; line-height: 0; margin-left: 0.2ex; } +i, em { + font-style: italic; +} -p, div, img { margin-top: 1.25rem; } +sup { + vertical-align: super; +} -ul, ol -{ margin-top: 0.625rem; margin-bottom: 0.625rem; list-style-position: outside } +sub { + vertical-align: sub; +} -ul { list-style-type: square } -ul > li { margin-left: 1.375rem; } -ol > li { margin-left: 1.7rem; } -li > *:first-child { margin-top: 0 } +sup, sub { + font-size: 12px; + line-height: 0; + margin-left: 0.2ex; +} + +pre { + margin-top: 0.8em; + margin-bottom: 1.2em; +} + +p, ul, ol { + margin-top: 0.5em; + margin-bottom: 1em; +} +ul, ol { + list-style-position: outside +} + +ul>li { + margin-left: 22px; +} + +ol>li { + margin-left: 27.2px; +} + +li>*:first-child { + margin-top: 0 +} /* Text alignements, this should be forbidden. */ -.left { text-align: left; } -.right { text-align: right; } -.center { text-align: center; } +.left { + text-align: left; +} + +.right { + text-align: right; +} + +.center { + text-align: center; +} /* Links and anchors */ -a { text-decoration:none; color:#2C5CBD; } -a:hover { box-shadow:0 1px 0 0 #2C5CBD; } -*:target /* Linked highlight */ -{ background-color: #FFF8E5; - box-shadow: 0 0 0 2px #FFF8E5, 0 0 0 3px #DDD; } +a { + text-decoration: none; + color: #2C5CBD; +} -.spec:hover > a.anchor, /* FIXME remove */ -.anchored:hover a.anchor { visibility: visible; } +a:hover { + box-shadow: 0 1px 0 0 #2C5CBD; +} -a.anchor:before { content: "#" } -a.anchor:hover { box-shadow: none; text-decoration: underline } -a.anchor -{ visibility: hidden; position: absolute; /* top: 0px; */ - margin-left: -3ex; +/* Linked highlight */ +*:target { + background-color: rgba(187,239,253,0.3) !important; + box-shadow: 0 0px 0 1px rgba(187,239,253,0.8) !important; + border-radius: 1px; +} + +*:hover>a.anchor { + visibility: visible; +} + +a.anchor:before { + content: "#" +} + +a.anchor:hover { + box-shadow: none; + text-decoration: none; + color: #555; +} + +a.anchor { + visibility: hidden; + position: absolute; + /* top: 0px; */ + /* margin-left: -3ex; */ + margin-left: -1.3em; font-weight: normal; font-style: normal; - padding-right: 1ex; padding-left: 1ex; /* To remain selectable */ - color: #AAA; } + padding-right: 0.4em; + padding-left: 0.4em; + /* To remain selectable */ + color: #d5d5d5; +} -.xref-unresolved { box-shadow:0 1px 0 0 red } +.spec > a.anchor { + margin-left: -2.3em; + padding-right: 0.9em; +} + +.xref-unresolved { + color: #2C5CBD; +} +.xref-unresolved:hover { + box-shadow: 0 1px 0 0 #CC6666; +} /* Section and document divisions. Until at least 4.03 many of the modules of the stdlib start at .h7, we restart the sequence there like h2 */ -h1, h2, h3, h4, h5, h6, .h7, .h8, .h9, .h10 -{ font-weight: bold; margin-top: 1.25rem; } +h1, h2, h3, h4, h5, h6, .h7, .h8, .h9, .h10 { + font-family: "Fira Sans", Helvetica, Arial, sans-serif; + font-weight: 400; + margin: 0.5em 0 0.5em 0; + padding-top: 0.1em; + line-height: 1.2; + overflow-wrap: break-word; +} -h1 + *, h2 + *, .h7 + * { margin-top: 0.625rem; } -h1, h2, .h7 -{ font-size: 1.25rem; - line-height: 2.4375rem; /* 2.5rem - border width */ - padding-top: 0.625rem; - border-top: solid; - border-width: 1px; - border-color: #DDD; } +h1 { + font-weight: 500; + font-size: 2.441em; + margin-top: 1.214em; +} + +h1 { + font-weight: 500; + font-size: 1.953em; + box-shadow: 0 1px 0 0 #ddd; +} + +h2 { + font-size: 1.563em; +} + +h3 { + font-size: 1.25em; +} + +small, .font_small { + font-size: 0.8em; +} + +h1 code, h1 tt { + font-size: inherit; + font-weight: inherit; +} + +h2 code, h2 tt { + font-size: inherit; + font-weight: inherit; +} + +h3 code, h3 tt { + font-size: inherit; + font-weight: inherit; +} + +h3 code, h3 tt { + font-size: inherit; + font-weight: inherit; +} + +h4 { + font-size: 1.12em; +} -h3, .h8 { font-size: 1.125rem; } -h2 + h3, .h7 + .h8 { margin-top: 0.625rem; } /* Preformatted and code */ -tt, code, pre -{ font-family: Menlo, "DejaVu Sans Mono", "Bitstream Vera Sans Mono", - monospace; - font-weight: normal; - font-size: 0.75rem; } +tt, code, pre { + font-family: "Fira Mono", courier; + font-weight: 400; +} -pre -{ padding-left: 0.25rem; padding-right: 0.25rem; - margin-left: -0.25rem; margin-right: -0.25rem; - padding-top: 0.3125rem; padding-bottom: 0.3125rem; - margin-top: 1.25rem; /* margin-bottom: 0.625rem; */ - line-height: 1.1875rem; - background: #F1F1F1; } +pre { + padding: 0.1em; + border: 1px solid #eee; + border-radius: 5px; + overflow-x: auto; +} -h1 tt, h1 code, h2 tt, h2 code, .h7 tt, .h7 code { font-size: 1.125rem } -h3 tt, h3 code { font-size: 1rem } +p code, li code { + background-color: #f6f8fa; + color: #0d2b3e; + border-radius: 3px; + padding: 0 0.3ex; +} + +p a > code { + color: #2C5CBD; +} + +/* Code blocks (e.g. Examples) */ + +pre code { + font-size: 0.893rem; +} /* Code lexemes */ -.keyword { font-weight: bold; } +.keyword { + font-weight: 500; +} /* Module member specification */ -div.def { margin-top: 0rem; text-indent: -2ex; padding-left: 2ex; } -div.def + div.doc { margin-left: 1ex; margin-top: 0.15625rem } -div.doc > *:first-child { margin-top: 0rem; } +.spec:not(.include), .spec.include details summary { + background-color: #f6f8fa; + border-radius: 3px; + border-left: 4px solid #5c9cf5; + border-right: 5px solid transparent; + padding: 0.35em 0.5em; +} + +.spec.include details summary:hover { + background-color: #ebeff2; +} + +dl, div.spec, .doc, aside { + margin-bottom: 20px; +} + +dl > dd { + padding: 0.5em; +} + +dd> :first-child { + margin-top: 0; +} + +dl:last-child, dd> :last-child, aside:last-child, article:last-child { + margin-bottom: 0; +} + +dt+dt { + margin-top: 15px; +} + +section+section, section > header + dl { + margin-top: 25px; +} + +.spec.type .variant { + margin-left: 2ch; +} +.spec.type .variant p { + margin: 0; + font-style: italic; +} +.spec.type .record { + margin-left: 2ch; +} +.spec.type .record p { + margin: 0; + font-style: italic; +} + +div.def { + margin-top: 0; + text-indent: -2ex; + padding-left: 2ex; +} + +div.def+div.doc { + margin-left: 1ex; + margin-top: 2.5px +} + +div.doc>*:first-child { + margin-top: 0; +} + +/* The elements other than heading should be wrapped in