diff --git a/2.1/containers.data/CCBV.odoc b/2.1/containers.data/CCBV.odoc new file mode 100644 index 00000000..a0d881b8 Binary files /dev/null and b/2.1/containers.data/CCBV.odoc differ diff --git a/2.1/containers.data/CCBV/.jbuilder-keep b/2.1/containers.data/CCBV/.jbuilder-keep new file mode 100644 index 00000000..e69de29b diff --git a/2.1/containers.data/CCBV/index.html b/2.1/containers.data/CCBV/index.html new file mode 100644 index 00000000..eb09afc6 --- /dev/null +++ b/2.1/containers.data/CCBV/index.html @@ -0,0 +1,18 @@ + +
BREAKING CHANGES since 1.2: +size is now stored along with the bitvector. Some functions have +a new signature.
The size of the bitvector used to be rounded up to the multiple of 30 or 62. +In other words some functions such as iter would iterate on more +bits than what was originally asked for. This is not the case anymore.
val length : t ‑> intSize of underlying bitvector. +This is not related to the underlying implementation. +Changed at 1.2
val resize : t ‑> int ‑> unitResize the BV so that it has the specified length. This can grow or shrink +the underlying bitvector.
val to_sorted_list : t ‑> int listSame as to_list, but also guarantees the list is sorted in +increasing order.
val of_list : int list ‑> tFrom a list of true bits.
The bits are interpreted as indices into the returned bitvector, so the final
+bitvector will have length t equal to 1 more than max of list indices.
val filter : t ‑> (int ‑> bool) ‑> unitfilter bv p only keeps the true bits of bv whose index
+satisfies p index.
union_into ~into bv sets into to the union of itself and bv.
+Also updates the length of into to be at least length bv.
inter_into ~into bv sets into to the intersection of itself and bv.
+Also updates the length of into to be at most length bv.
val select : t ‑> 'a array ‑> 'a listselect arr bv selects the elements of arr whose index
+corresponds to a true bit in bv. If bv is too short, elements of arr
+with too high an index cannot be selected and are therefore not
+selected.
val selecti : t ‑> 'a array ‑> ('a * int) listSame as select, but selected elements are paired with their indexes.
R : OrderedTypeL : OrderedTypeval empty : tval is_empty : t ‑> boolAdd left and right correspondence to bijection such that
+left and right are unique in their respective sets and only
+correspond to each other.
+Represents 1-to-1 mappings between two types. Each element from the "left" +is mapped to one "right" value, and conversely.
module type OrderedType : sig ... endmodule type S : sig ... endmodule Make : functor (L : OrderedType) -> functor (R : OrderedType) -> S with type left = L.t and type right = R.tval empty : tval is_empty : t ‑> boolAdd left and right correspondence to bijection such that
+left and right are unique in their respective sets and only
+correspond to each other.
Create a new bitfield type
X : sig ... endtype t = private intGenerative type of bitfields. Each instantiation of the functor +should create a new, incompatible type
val freeze : unit ‑> unitPrevent new fields from being added. From now on, creating +a field will raise Frozen.
This module defines efficient bitfields +up to 30 or 62 bits (depending on the architecture) in +a relatively type-safe way.
module B = CCBitField.Make(struct end);;
+
+ let x = B.mk_field ()
+ let y = B.mk_field ()
+ let z = B.mk_field ()
+
+ let f = B.empty |> B.set x true |> B.set y true;;
+
+ assert (not (B.get z f)) ;;
+
+ assert (f |> B.set z true |> B.get z);;
+
\ No newline at end of file
diff --git a/2.1/containers.data/CCBitField/module-type-S/index.html b/2.1/containers.data/CCBitField/module-type-S/index.html
new file mode 100644
index 00000000..b9fe76af
--- /dev/null
+++ b/2.1/containers.data/CCBitField/module-type-S/index.html
@@ -0,0 +1,4 @@
+
+type t = private intGenerative type of bitfields. Each instantiation of the functor +should create a new, incompatible type
val freeze : unit ‑> unitPrevent new fields from being added. From now on, creating +a field will raise Frozen.
Particularly useful for memoization. See with_cache and with_cache_rec +for more details.
Typical use case: one wants to memoize a function f : 'a -> 'b. Code sample:
+
let f x =
+ print_endline "call f";
+ x + 1;;
+
+ let f' = with_cache (lru 256) f;;
+ f' 0;; (* prints *)
+ f' 1;; (* prints *)
+ f' 0;; (* doesn't print, returns cached value *)type ('a, 'b) callback = in_cache:bool ‑> 'a ‑> 'b ‑> unitType of the callback that is called once a cached value is found +or not. +Should never raise.
true if the value was in cache, false
+if the value was just produced.with_cache c f behaves like f, but caches calls to f in the
+cache c. It always returns the same value as
+f x, if f x returns, or raise the same exception.
+However, f may not be called if x is in the cache.
with_cache_rec c f is a function that first, applies f to
+some f' = fix f, such that recursive calls to f' are cached in c.
+It is similar to with_cache but with a function that takes as
+first argument its own recursive version.
+Example (memoized Fibonacci function):
+
let fib = with_cache_rec (lru 256)
+ (fun fib' n -> match n with
+ | 1 | 2 -> 1
+ | _ -> fib' (n-1) + fib' (n-2)
+ );;
+
+ fib 70;;val size : (_, _) t ‑> intSize of the cache (number of entries). At most linear in the number +of entries.
val iter : ('a, 'b) t ‑> ('a ‑> 'b ‑> unit) ‑> unitIterate on cached values. Should yield size cache pairs.
val add : ('a, 'b) t ‑> 'a ‑> 'b ‑> boolManually add a cached value. Return true if the value has successfully
+been added, and false if the value was already bound.
Linear cache with the given size. It stores key/value pairs in +an array and does linear search at every call, so it should only be used +with small size.
Replacing cache of the given size. Equality and hash functions can be +parametrized. It's a hash table that handles collisions by replacing +the old value with the new (so a cache entry is evicted when another +entry with the same hash (modulo size) is added). +Never grows wider than the given size.
LRU cache of the given size ("Least Recently Used": keys that have not been +used recently are deleted first). Never grows wider than the given size.
Unbounded cache, backed by a Hash table. Will grow forever +unless clear is called manually.
This structure provides fast access to its front and back elements, +with O(1) operations.
equal a b checks whether a and b contain the same sequence of
+elements.
compare a b compares lexicographically a and b
Create a deque from the sequence.
+Optional argument deque disappears, use add_seq_back instead since
+0.13
add_seq_front q seq adds elements of seq into the front of q,
+in reverse order.
+O(n) in time, where n is the number of elements to add.
add_seq_back q seq adds elements of seq into the back of q,
+in order.
+O(n) in time, where n is the number of elements to add.
val to_list : 'a t ‑> 'a listList of elements, in order. Less efficient than to_rev_list.
val empty : 'a tval is_empty : 'a t ‑> boolval singleton : 'a ‑> 'a tval doubleton : 'a ‑> 'a ‑> 'a tSame as take_front, but fails on empty queues.
take_front_l n q takes at most n elements from the front
+of q, and returns them wrapped in a list.
Same as take_back, but fails on empty queues.
take_back_l n q removes and returns the last n elements of q. The
+elements are in the order of the queue, that is, the head of the returned
+list is the first element to appear via take_front.
+take_back_l 2 (of_list [1;2;3;4]) = of_list [1;2], [3;4].
val last_exn : 'a t ‑> 'aAppend two queues. Elements from the second one come +after elements of the first one. +Linear in the size of the second queue.
val fold : ('b ‑> 'a ‑> 'b) ‑> 'b ‑> 'a t ‑> 'bval iter : ('a ‑> unit) ‑> 'a t ‑> unitval of_list : 'a list ‑> 'a tval to_list : 'a t ‑> 'a listval (--^) : int ‑> int ‑> int ta -- b is the integer range from a to b, where b is excluded.
Tree with a large branching factor for logarithmic operations with +a low multiplicative factor.
status: experimental. DO NOT USE (yet)
val empty : 'a tval is_empty : _ t ‑> boolval return : 'a ‑> 'a tval length : _ t ‑> intval get : int ‑> 'a t ‑> 'a optionval iter : f:('a ‑> unit) ‑> 'a t ‑> unitval iteri : f:(int ‑> 'a ‑> unit) ‑> 'a t ‑> unitIterate on elements with their index, in increasing order.
val iteri_rev : f:(int ‑> 'a ‑> unit) ‑> 'a t ‑> unitIterate on elements with their index, but starting from the end.
val fold : f:('b ‑> 'a ‑> 'b) ‑> x:'b ‑> 'a t ‑> 'bval foldi : f:('b ‑> int ‑> 'a ‑> 'b) ‑> x:'b ‑> 'a t ‑> 'bval choose : 'a t ‑> 'a optionval to_list : 'a t ‑> 'a listval of_list : 'a list ‑> 'a ttype attribute = [ | `Color of string |
| `Shape of string |
| `Weight of int |
| `Style of string |
| `Label of string |
| `Other of string * string |
]Dot attribute
val pp : tbl:('v, vertex_state) table ‑> eq:('v ‑> 'v ‑> bool) ‑> ?attrs_v:('v ‑> attribute list) ‑> ?attrs_e:('e ‑> attribute list) ‑> ?name:string ‑> graph:('v, 'e) t ‑> Format.formatter ‑> 'v ‑> unitPrint the graph, starting from given vertex, on the formatter.
val fold_v : ('acc ‑> 'v ‑> 'acc) ‑> 'acc ‑> ('v, _) t ‑> 'accval empty : 'a tRemove the vertex and all its outgoing edges. +Edges that point to the vertex are NOT removed, they must be +manually removed with remove_edge.
val return : 'a ‑> 'a sequenceval iter : ('a ‑> unit) ‑> 'a t ‑> unitval fold : ('b ‑> 'a ‑> 'b) ‑> 'b ‑> 'a t ‑> 'bval to_list : 'a t ‑> 'a listtype ('v, 'e) t = [ | `Enter of 'v * int * ('v, 'e) path |
| `Exit of 'v |
| `Edge of 'v * 'e * 'v * edge_kind |
]A traversal is a sequence of such events
val get_vertex : ('v, 'e) t ‑> ('v * [ `Enter | `Exit ]) optionval get_enter : ('v, 'e) t ‑> 'v optionval get_exit : ('v, 'e) t ‑> 'v optionval get_edge : ('v, 'e) t ‑> ('v * 'e * 'v) optionval dfs : tbl:'v set ‑> eq:('v ‑> 'v ‑> bool) ‑> graph:('v, 'e) graph ‑> 'v sequence ‑> ('v, 'e) t sequence_onceFull version of DFS.
val dfs_tag : eq:('v ‑> 'v ‑> bool) ‑> tags:'v tag_set ‑> graph:('v, 'e) graph ‑> 'v sequence ‑> ('v, 'e) t sequence_onceFull version of DFS using integer tags.
val generic : tbl:'v set ‑> bag:'v bag ‑> graph:('v, 'e) t ‑> 'v sequence ‑> 'v sequence_onceTraversal of the given graph, starting from a sequence +of vertices, using the given bag to choose the next vertex to +explore. Each vertex is visited at most once.
val generic_tag : tags:'v tag_set ‑> bag:'v bag ‑> graph:('v, 'e) t ‑> 'v sequence ‑> 'v sequence_onceOne-shot traversal of the graph using a tag set and the given bag.
val dfs : tbl:'v set ‑> graph:('v, 'e) t ‑> 'v sequence ‑> 'v sequence_onceval dfs_tag : tags:'v tag_set ‑> graph:('v, 'e) t ‑> 'v sequence ‑> 'v sequence_onceval bfs : tbl:'v set ‑> graph:('v, 'e) t ‑> 'v sequence ‑> 'v sequence_onceval bfs_tag : tags:'v tag_set ‑> graph:('v, 'e) t ‑> 'v sequence ‑> 'v sequence_onceval dijkstra : tbl:'v set ‑> ?dist:('e ‑> int) ‑> graph:('v, 'e) t ‑> 'v sequence ‑> ('v * int * ('v, 'e) path) sequence_onceDijkstra algorithm, traverses a graph in increasing distance order. +Yields each vertex paired with its distance to the set of initial vertices +(the smallest distance needed to reach the node from the initial vertices).
val dijkstra_tag : ?dist:('e ‑> int) ‑> tags:'v tag_set ‑> graph:('v, 'e) t ‑> 'v sequence ‑> ('v * int * ('v, 'e) path) sequence_onceA collections of algorithms on (mostly read-only) graph structures.
+The user provides her own graph structure as a ('v, 'e) CCGraph.t,
+where 'v is the type of vertices and 'e the type of edges
+(for instance, 'e = ('v * 'v) is perfectly fine in many cases).
Such a ('v, 'e) CCGraph.t structure is a record containing
+three functions: two relate edges to their origin and destination,
+and one maps vertices to their outgoing edges.
+This abstract notion of graph makes it possible to run the algorithms
+on any user-specific type that happens to have a graph structure.
Many graph algorithms here take a sequence of vertices as input.
+If the user only has a single vertex (e.g., for a topological sort
+from a given vertex), she can use Seq.return x to build a sequence
+of one element.
status: unstable
module Seq : sig ... endThis interface is designed for oriented graphs with labels on edges
type ('k, 'a) table = {mem : 'k ‑> bool; | |
find : 'k ‑> 'a; | (**
*) |
add : 'k ‑> 'a ‑> unit; | (** Erases previous binding *) |
}Mutable table with keys 'k and values 'a
val mk_table : eq:('k ‑> 'k ‑> bool) ‑> ?hash:('k ‑> int) ‑> int ‑> ('k, 'a) tableDefault implementation for table: a Hashtbl.t.
type 'a bag = {push : 'a ‑> unit; | |
is_empty : unit ‑> bool; | |
pop : unit ‑> 'a; | (** raises some exception is empty *) |
}Bag of elements of type 'a
val mk_queue : unit ‑> 'a bagval mk_stack : unit ‑> 'a bagval mk_heap : leq:('a ‑> 'a ‑> bool) ‑> 'a bagmk_heap ~leq makes a priority queue where leq x y = true means that
+x is smaller than y and should be prioritary.
module Traverse : sig ... endval topo_sort : eq:('v ‑> 'v ‑> bool) ‑> ?rev:bool ‑> tbl:'v set ‑> graph:('v, 'e) t ‑> 'v sequence ‑> 'v listtopo_sort ~graph seq returns a list of vertices l where each
+element of l is reachable from seq.
+The list is sorted in a way such that if v -> v' in the graph, then
+v comes before v' in the list (i.e. has a smaller index).
+Basically v -> v' means that v is smaller than v'.
+See wikipedia.
(=)).v -> v' means
+v' occurs before v).val topo_sort_tag : eq:('v ‑> 'v ‑> bool) ‑> ?rev:bool ‑> tags:'v tag_set ‑> graph:('v, 'e) t ‑> 'v sequence ‑> 'v listSame as topo_sort but uses an explicit tag set.
module Lazy_tree : sig ... endval spanning_tree : tbl:'v set ‑> graph:('v, 'e) t ‑> 'v ‑> ('v, 'e) Lazy_tree.tspanning_tree ~graph v computes a lazy spanning tree that has v
+as a root. The table tbl is used for the memoization part.
val spanning_tree_tag : tags:'v tag_set ‑> graph:('v, 'e) t ‑> 'v ‑> ('v, 'e) Lazy_tree.tval scc : tbl:('v, 'v scc_state) table ‑> graph:('v, 'e) t ‑> 'v sequence ‑> 'v list sequence_onceStrongly connected components reachable from the given vertices. +Each component is a list of vertices that are all mutually reachable +in the graph. +The components are explored in a topological order (if C1 and C2 are +components, and C1 points to C2, then C2 will be yielded before C1). +Uses Tarjan's algorithm.
Example (print divisors from 42):
let open CCGraph in
+ let open Dot in
+ with_out "/tmp/truc.dot"
+ (fun out ->
+ pp ~attrs_v:(fun i -> [`Label (string_of_int i)]) ~graph:divisors_graph out 42
+ )module Dot : sig ... endtype ('v, 'e) mut_graph = {graph : ('v, 'e) t; |
add_edge : 'v ‑> 'e ‑> 'v ‑> unit; |
remove : 'v ‑> unit; |
}val mk_mut_tbl : eq:('v ‑> 'v ‑> bool) ‑> ?hash:('v ‑> int) ‑> int ‑> ('v, 'a) mut_graphMake a new mutable graph from a Hashtbl. Edges are labelled with type 'a.
A classic implementation of a graph structure on totally ordered vertices, +with unlabelled edges. The graph allows to add and remove edges and vertices, +and to iterate on edges and vertices.
module type MAP : sig ... endval of_list : eq:('v ‑> 'v ‑> bool) ‑> ('v * 'v) list ‑> ('v, unit) tof_list l makes a graph from a list of pairs of vertices.
+Each pair (a,b) is an edge from a to b.
val of_hashtbl : ('v, 'v list) Hashtbl.t ‑> ('v, unit) tof_hashtbl tbl makes a graph from a hashtable that maps vertices
+to lists of children.
val of_fun : ('v ‑> 'v list) ‑> ('v, unit) tof_fun f makes a graph out of a function that maps a vertex to
+the list of its children. The function is assumed to be deterministic.
val empty : 'a tRemove the vertex and all its outgoing edges. +Edges that point to the vertex are NOT removed, they must be +manually removed with remove_edge.
status: unstable
module type S : sig ... endmodule type ELEMENT : sig ... endval hash : t ‑> intval empty : 'a tval is_empty : _ t ‑> boolupdate k ~f m calls f (Some v) if get k m = Some v, f None
+otherwise. Then, if f returns Some v' it binds k to v',
+if f returns None it removes k.
val add_mut : id:Transient.t ‑> key ‑> 'a ‑> 'a t ‑> 'a tadd_mut ~id k v m behaves like add k v m, except it will mutate
+in place whenever possible. Changes done with an id might affect all
+versions of the structure obtained with the same id (but not
+other versions).
id is frozen.val remove_mut : id:Transient.t ‑> key ‑> 'a t ‑> 'a tSame as remove, but modifies in place whenever possible.
id is frozen.val update_mut : id:Transient.t ‑> key ‑> f:('a option ‑> 'a option) ‑> 'a t ‑> 'a tSame as update but with mutability.
id is frozen.val cardinal : _ t ‑> intval add_list_mut : id:Transient.t ‑> 'a t ‑> (key * 'a) list ‑> 'a tval add_seq_mut : id:Transient.t ‑> 'a t ‑> (key * 'a) sequence ‑> 'a tval add_gen_mut : id:Transient.t ‑> 'a t ‑> (key * 'a) gen ‑> 'a tFor debugging purpose: explore the structure of the tree,
+with `L (h,l) being a leaf (with shared hash h)
+and `N an inner node.
type tIdentifiers for transient modifications. A transient modification
+is uniquely identified by a Transient.t. Once Transient.freeze r
+is called, r cannot be used to modify the structure again.
val frozen : t ‑> boolfrozen i returns true if freeze i was called before. In this case,
+the ID cannot be used for modifications again.
val freeze : t ‑> unitfreeze i makes i unusable for new modifications. The values
+created with i will now be immutable.
val with_ : (t ‑> 'a) ‑> 'awith_ f creates a transient ID i, calls f i,
+freezes the ID i and returns the result of f i.
Trie indexed by the hash of the keys, where the branching factor is fixed. +The goal is to have a quite efficient functional structure with fast +update and access if the hash function is good. +The trie is not binary, to improve cache locality and decrease depth.
Preliminary benchmarks (see the "tbl" section of benchmarks) tend to show +that this type is quite efficient for small data sets.
status: unstable
val hash : t ‑> intval empty : 'a tval is_empty : _ t ‑> boolupdate k ~f m calls f (Some v) if get k m = Some v, f None
+otherwise. Then, if f returns Some v' it binds k to v',
+if f returns None it removes k.
val add_mut : id:Transient.t ‑> key ‑> 'a ‑> 'a t ‑> 'a tadd_mut ~id k v m behaves like add k v m, except it will mutate
+in place whenever possible. Changes done with an id might affect all
+versions of the structure obtained with the same id (but not
+other versions).
id is frozen.val remove_mut : id:Transient.t ‑> key ‑> 'a t ‑> 'a tSame as remove, but modifies in place whenever possible.
id is frozen.val update_mut : id:Transient.t ‑> key ‑> f:('a option ‑> 'a option) ‑> 'a t ‑> 'a tSame as update but with mutability.
id is frozen.val cardinal : _ t ‑> intval add_list_mut : id:Transient.t ‑> 'a t ‑> (key * 'a) list ‑> 'a tval add_seq_mut : id:Transient.t ‑> 'a t ‑> (key * 'a) sequence ‑> 'a tval add_gen_mut : id:Transient.t ‑> 'a t ‑> (key * 'a) gen ‑> 'a tFor debugging purpose: explore the structure of the tree,
+with `L (h,l) being a leaf (with shared hash h)
+and `N an inner node.
val create : unit ‑> 'a tval empty : tval length : t ‑> intval cardinal : t ‑> intval create : ?size:int ‑> unit ‑> tval length : t ‑> intThis is similar to CCMixtbl, but the injection is directly used as +a key.
module Key : sig ... endPurely functional use of arrays. Update is costly, but reads are very fast. +Sadly, it is not possible to make this type covariant without using black +magic.
type 'a tArray of values of type 'a. The underlying type really is +an array, but it will never be modified.
It should be covariant but OCaml will not accept it.
val empty : 'a tval length : _ t ‑> intval singleton : 'a ‑> 'a tval doubleton : 'a ‑> 'a ‑> 'a tval init : int ‑> (int ‑> 'a) ‑> 'a tinit n f makes the array [| f 0; f 1; ... ; f (n-1) |].
n < 0.sub a start len returns a fresh array of length len, containing the elements
+from start to pstart + len - 1 of array a.
Raises Invalid_argument "Array.sub" if start and len do not designate a
+valid subarray of a; that is, if start < 0, or len < 0, or start + len > Array.length a.
val iter : ('a ‑> unit) ‑> 'a t ‑> unitval iteri : (int ‑> 'a ‑> unit) ‑> 'a t ‑> unitval foldi : ('a ‑> int ‑> 'b ‑> 'a) ‑> 'a ‑> 'b t ‑> 'aval fold : ('a ‑> 'b ‑> 'a) ‑> 'a ‑> 'b t ‑> 'aval for_all : ('a ‑> bool) ‑> 'a t ‑> boolval exists : ('a ‑> bool) ‑> 'a t ‑> boolval of_list : 'a list ‑> 'a tval to_list : 'a t ‑> 'a listval of_array_unsafe : 'a array ‑> 'a tTake ownership of the given array. Careful, the array must NOT +be modified afterwards!
status: stable
val empty : 'a tval singleton : int ‑> 'a ‑> 'a tval doubleton : int ‑> 'a ‑> int ‑> 'a ‑> 'a tval mem : int ‑> _ t ‑> boolval find : int ‑> 'a t ‑> 'a optionequal ~eq a b checks whether a and b have the same set of pairs
+(key, value), comparing values with eq.
val iter : (int ‑> 'a ‑> unit) ‑> 'a t ‑> unitval fold : (int ‑> 'a ‑> 'b ‑> 'b) ‑> 'a t ‑> 'b ‑> 'bval choose : 'a t ‑> (int * 'a) optionval of_list : (int * 'a) list ‑> 'a tval to_list : 'a t ‑> (int * 'a) listHelpers
\ No newline at end of file diff --git a/2.1/containers.data/CCMixmap.odoc b/2.1/containers.data/CCMixmap.odoc new file mode 100644 index 00000000..fc627234 Binary files /dev/null and b/2.1/containers.data/CCMixmap.odoc differ diff --git a/2.1/containers.data/CCMixmap/.jbuilder-keep b/2.1/containers.data/CCMixmap/.jbuilder-keep new file mode 100644 index 00000000..e69de29b diff --git a/2.1/containers.data/CCMixmap/Make/argument-1-X/index.html b/2.1/containers.data/CCMixmap/Make/argument-1-X/index.html new file mode 100644 index 00000000..7c387271 --- /dev/null +++ b/2.1/containers.data/CCMixmap/Make/argument-1-X/index.html @@ -0,0 +1,2 @@ + +Find the value for the given key, which must be of the right type.
status: experimental
module M = CCMixmap.Make(CCInt)
+
+ let inj_int = CCMixmap.create_inj()
+ let inj_str = CCMixmap.create_inj()
+ let inj_list_int = CCMixmap.create_inj()
+
+ let m =
+ M.empty
+ |> M.add ~inj:inj_int 1 1
+ |> M.add ~inj:inj_str 2 "2"
+ |> M.add ~inj:inj_list_int 3 [3;3;3]
+
+ assert (M.get ~inj:inj_int 1 m = Some 1)
+ assert (M.get ~inj:inj_str 1 m = None)
+ assert (M.get ~inj:inj_str 2 m = Some "2")
+ assert (M.get ~inj:inj_int 2 m = None)
+ assert (M.get ~inj:inj_list_int 3 m = Some [3;3;3])
+ assert (M.get ~inj:inj_str 3 m = None)change of API, the map is last argument to make piping with |> easier since 0.16.
type 'a injectionAn accessor for values of type 'a in any map. Values put +in the map using a key can only be retrieved using this +very same key.
val create_inj : unit ‑> 'a injectionReturn a value that works for a given type of values. This function is +normally called once for each type of value. Several keys may be +created for the same type, but a value set with a given setter can only be +retrieved with the matching getter. The same key can be reused +across multiple maps (although not in a thread-safe way).
module type S : sig ... endmodule type ORD : sig ... endFind the value for the given key, which must be of the right type.
let k1 : int key = newkey () in
+ let k2 : int key = newkey () in
+ let k3 : string key = newkey () in
+ let set =
+ empty
+ |> set ~key:k1 1
+ |> set ~key:k2 2
+ |> set ~key:k3 "3"
+ in
+ assert (get ~key:k1 set = Some 1);
+ assert (get ~key:k2 set = Some 2);
+ assert (get ~key:k3 set = Some "3");
+ ()val newkey : unit ‑> 'a keynewkey () creates a new unique key that can be used to access
+a 'a value in a set. Each key created with newkey is distinct
+from any other key, even if they have the same type.
Not thread-safe.
set ~key v set maps key to v in set. It means that
+for every set, get ~key (set ~key v set) = Some v.
Same as get, but can fail.
From https://github.com/mjambon/mixtbl (thanks to him). +Example:
let inj_int = CCMixtbl.create_inj () ;;
+
+ let tbl = CCMixtbl.create 10 ;;
+
+ OUnit.assert_equal None (CCMixtbl.get ~inj:inj_int tbl "a");;
+
+ CCMixtbl.set inj_int tbl "a" 1;;
+
+ OUnit.assert_equal (Some 1) (CCMixtbl.get ~inj:inj_int tbl "a");;
+
+ let inj_string = CCMixtbl.create_inj () ;;
+
+ CCMixtbl.set inj_string tbl "b" "Hello";
+
+ OUnit.assert_equal (Some "Hello") (CCMixtbl.get inj_string tbl "b");;
+ OUnit.assert_equal None (CCMixtbl.get inj_string tbl "a");;
+ OUnit.assert_equal (Some 1) (CCMixtbl.get inj_int tbl "a");;
+ CCMixtbl.set inj_string tbl "a" "Bye";;
+
+ OUnit.assert_equal None (CCMixtbl.get inj_int tbl "a");;
+ OUnit.assert_equal (Some "Bye") (CCMixtbl.get inj_string tbl "a");;type 'a tA hash table containing values of different types.
+The type parameter 'a represents the type of the keys.
type 'b injectionAn accessor for values of type 'b in any table. Values put +in the table using a key can only be retrieved using this +very same key.
val create_inj : unit ‑> 'b injectionReturn a value that works for a given type of values. This function is +normally called once for each type of value. Several keys may be +created for the same type, but a value set with a given setter can only be +retrieved with the matching getter. The same key can be reused +across multiple tables (although not in a thread-safe way).
Find the value for the given key, which must be of the right type.
V : OrderedTypeK : OrderedTypeR : OrderedTypeL : OrderedTypeval empty : tval is_empty : t ‑> boolmodule type S : sig ... endmodule type OrderedType : sig ... endmodule Make : functor (K : OrderedType) -> functor (V : OrderedType) -> S with type key = K.t and type value = V.t+Represents n-to-n mappings between two types. Each element from the "left" +is mapped to several right values, and conversely.
module type BIDIR : sig ... endmodule MakeBidir : functor (L : OrderedType) -> functor (R : OrderedType) -> BIDIR with type left = L.t and type right = R.tval empty : tval is_empty : t ‑> boolval empty : tval is_empty : t ‑> boolremove_mult set x n removes at most n occurrences of x from set.
n < 0.update set x f calls f n where n is the current multiplicity
+of x in set (0 to indicate its absence); the result of f n
+is the new multiplicity of x.
f n < 0.module type S : sig ... endval empty : tval is_empty : t ‑> boolremove_mult set x n removes at most n occurrences of x from set.
n < 0.update set x f calls f n where n is the current multiplicity
+of x in set (0 to indicate its absence); the result of f n
+is the new multiplicity of x.
f n < 0.From the paper by Jean-Christophe Filliâtre, +"A persistent Union-Find data structure", see +the ps version
val make : int ‑> 'a ‑> 'a tmake n x returns a persistent array of length n, with x. All the
+elements of this new array are initially physically equal to x
+(in the sense of the == predicate). Consequently, if x is mutable, it is
+shared among all elements of the array, and modifying x through one of the
+array entries will modify all other entries at the same time.
n < 0 or n > Sys.max_array_length.
+If the value of x is a floating-point number, then the maximum size is
+only Sys.max_array_length / 2.val init : int ‑> (int ‑> 'a) ‑> 'a tinit n f returns a persistent array of length n, with element
+i initialized to the result of f i.
n < 0 or n > Sys.max_array_length.
+If the value of x is a floating-point number, then the maximum size is
+only Sys.max_array_length / 2.val get : 'a t ‑> int ‑> 'aget a i returns the element with index i from the array a.
n is outside the
+range 0 to Array.length a - 1.set a i v sets the element index i from the array a to v.
n is outside the
+range 0 to Array.length a - 1.Apply the given function to all elements of the array, and return
+a persistent array initialized by the results of f. In the case of mapi,
+the function is also given the index of the element.
+It is equivalent to fun f t -> init (fun i -> f (get t i)).
val iter : ('a ‑> unit) ‑> 'a t ‑> unititer f t applies function f to all elements of the persistent array,
+in order from element 0 to element length t - 1.
val iteri : (int ‑> 'a ‑> unit) ‑> 'a t ‑> unititer f t applies function f to all elements of the persistent array,
+in order from element 0 to element length t - 1.
val fold_left : ('a ‑> 'b ‑> 'a) ‑> 'a ‑> 'b t ‑> 'aval of_list : 'a list ‑> 'a tof_list l returns a fresh persistent array containing the elements of l.
val of_rev_list : 'a list ‑> 'a tof_rev_list l is the same as of_list (List.rev l) but more efficient.
val hash : t ‑> intH : HashedTypeAdd the binding to the table, returning a new table. The old binding
+for this key, if it exists, is shadowed and will be restored upon
+remove tbl k.
Add the binding to the table, returning a new table. This erases
+the current binding for key, if any.
update tbl key f calls f None if key doesn't belong in tbl,
+f (Some v) if key -> v otherwise; If f returns None then
+key is removed, else it returns Some v' and key -> v' is added.
Fresh copy of the table; the underlying structure is not shared +anymore, so using both tables alternatively will be efficient.
val merge : f:(key ‑> [ `Left of 'a | `Right of 'b | `Both of 'a * 'b ] ‑> 'c option) ‑> 'a t ‑> 'b t ‑> 'c tMerge two tables together into a new table. The function's argument
+correspond to values associated with the key (if present); if the
+function returns None the key will not appear in the result.
Almost as efficient as the regular Hashtbl type, but with a persistent +interface (rewinding changes to get back in the past history). This is +mostly useful for backtracking-like uses, or forward uses (never using +old values).
This module is not thread-safe.
module type HashedType : sig ... endmodule type S : sig ... endval hash : t ‑> intAdd the binding to the table, returning a new table. The old binding
+for this key, if it exists, is shadowed and will be restored upon
+remove tbl k.
Add the binding to the table, returning a new table. This erases
+the current binding for key, if any.
update tbl key f calls f None if key doesn't belong in tbl,
+f (Some v) if key -> v otherwise; If f returns None then
+key is removed, else it returns Some v' and key -> v' is added.
Fresh copy of the table; the underlying structure is not shared +anymore, so using both tables alternatively will be efficient.
val merge : f:(key ‑> [ `Left of 'a | `Right of 'b | `Both of 'a * 'b ] ‑> 'c option) ‑> 'a t ‑> 'b t ‑> 'c tMerge two tables together into a new table. The function's argument
+correspond to values associated with the key (if present); if the
+function returns None the key will not appear in the result.
val (--^) : int ‑> int ‑> int ta --^ b is the integer range from a to b, where b is excluded.
This is an OCaml implementation of Okasaki's paper +"Purely Functional Random Access Lists". It defines a list-like data +structure with O(1) cons/tail operations, and O(log(n)) lookup/modification +operations.
This module used to be part of containers.misc
status: stable
Unsafe version of front.
val get_exn : 'a t ‑> int ‑> 'aUnsafe version of get.
i+1 elements.set l i v sets the i-th element of the list to v. O(log(n)).
i+1 elements.remove l i removes the i-th element of v.
i+1 elements.take_drop n l splits l into a, b such that length a = n
+if length l >= n, and such that append a b = l.
val iteri : f:(int ‑> 'a ‑> unit) ‑> 'a t ‑> unitval fold_rev : f:('b ‑> 'a ‑> 'b) ‑> x:'b ‑> 'a t ‑> 'bFold on the list's elements, in reverse order (starting from the tail).
val make : int ‑> 'a ‑> 'a tval to_list : 'a t ‑> 'a listval of_array : 'a array ‑> 'a tmodule Infix : sig ... endEfficient array version for the char type
val dummy : tMakes an array given an arbitrary element type
Elt : sig ... endThe abstract type for arrays
module type S : sig ... endAn efficient byte based ring buffer
val create : int ‑> tcreate size creates a new bounded buffer with given size.
+The underlying array is allocated immediately and no further (large)
+allocation will happen from now on.
< 1.blit_from buf from_buf o len copies the slice o, ... o + len - 1 from
+an input buffer from_buf to the end of the buffer.
+If the slice is too large for the buffer, only the last part of the array
+will be copied.
o,len is not a valid slice of s.blit_into buf to_buf o len copies at most len elements from buf
+into to_buf starting at offset o in s.
min len (length buf)).o,len is not a valid slice of s.append b ~into copies all data from b and adds it at the
+end of into. Erases data of into if there is not enough room.
val junk_front : t ‑> unitDrop the front element from t.
val skip : t ‑> int ‑> unitskip b len removes len elements from the front of b.
len > length b.get_front buf i returns the i-th element of buf from the front, i.e.
+the one returned by take_front buf after i-1 calls to junk_front buf.
length buf).get_back buf i returns the i-th element of buf from the back, i.e.
+the one returned by take_back buf after i-1 calls to junk_back buf.
length buf).Push value at the back of t.
+If t.bounded=false, the buffer will grow as needed,
+otherwise the oldest elements are replaced first.
Create a buffer from an initial array, but doesn't take ownership +of it (still allocates a new internal array).
The module type of Array for this ring buffer
val dummy : tBuffer using regular arrays
X : sig ... endval create : int ‑> tcreate size creates a new bounded buffer with given size.
+The underlying array is allocated immediately and no further (large)
+allocation will happen from now on.
< 1.blit_from buf from_buf o len copies the slice o, ... o + len - 1 from
+an input buffer from_buf to the end of the buffer.
+If the slice is too large for the buffer, only the last part of the array
+will be copied.
o,len is not a valid slice of s.blit_into buf to_buf o len copies at most len elements from buf
+into to_buf starting at offset o in s.
min len (length buf)).o,len is not a valid slice of s.append b ~into copies all data from b and adds it at the
+end of into. Erases data of into if there is not enough room.
val junk_front : t ‑> unitDrop the front element from t.
val skip : t ‑> int ‑> unitskip b len removes len elements from the front of b.
len > length b.get_front buf i returns the i-th element of buf from the front, i.e.
+the one returned by take_front buf after i-1 calls to junk_front buf.
length buf).get_back buf i returns the i-th element of buf from the back, i.e.
+the one returned by take_back buf after i-1 calls to junk_back buf.
length buf).Push value at the back of t.
+If t.bounded=false, the buffer will grow as needed,
+otherwise the oldest elements are replaced first.
Create a buffer from an initial array, but doesn't take ownership +of it (still allocates a new internal array).
Makes a ring buffer module with the given array type
val create : int ‑> tcreate size creates a new bounded buffer with given size.
+The underlying array is allocated immediately and no further (large)
+allocation will happen from now on.
< 1.blit_from buf from_buf o len copies the slice o, ... o + len - 1 from
+an input buffer from_buf to the end of the buffer.
+If the slice is too large for the buffer, only the last part of the array
+will be copied.
o,len is not a valid slice of s.blit_into buf to_buf o len copies at most len elements from buf
+into to_buf starting at offset o in s.
min len (length buf)).o,len is not a valid slice of s.append b ~into copies all data from b and adds it at the
+end of into. Erases data of into if there is not enough room.
val junk_front : t ‑> unitDrop the front element from t.
val skip : t ‑> int ‑> unitskip b len removes len elements from the front of b.
len > length b.get_front buf i returns the i-th element of buf from the front, i.e.
+the one returned by take_front buf after i-1 calls to junk_front buf.
length buf).get_back buf i returns the i-th element of buf from the back, i.e.
+the one returned by take_back buf after i-1 calls to junk_back buf.
length buf).Push value at the back of t.
+If t.bounded=false, the buffer will grow as needed,
+otherwise the oldest elements are replaced first.
Create a buffer from an initial array, but doesn't take ownership +of it (still allocates a new internal array).
Useful for IO, or as a bounded-size alternative to Queue when +batch operations are needed.
status: experimental
Change in the API to provide only a bounded buffer since 1.3
The module type of Array for this ring buffer
The abstract ring buffer type, made concrete by choice of
+ARRAY module implementation
val create : int ‑> tcreate size creates a new bounded buffer with given size.
+The underlying array is allocated immediately and no further (large)
+allocation will happen from now on.
< 1.blit_from buf from_buf o len copies the slice o, ... o + len - 1 from
+an input buffer from_buf to the end of the buffer.
+If the slice is too large for the buffer, only the last part of the array
+will be copied.
o,len is not a valid slice of s.blit_into buf to_buf o len copies at most len elements from buf
+into to_buf starting at offset o in s.
min len (length buf)).o,len is not a valid slice of s.append b ~into copies all data from b and adds it at the
+end of into. Erases data of into if there is not enough room.
val junk_front : t ‑> unitDrop the front element from t.
val skip : t ‑> int ‑> unitskip b len removes len elements from the front of b.
len > length b.get_front buf i returns the i-th element of buf from the front, i.e.
+the one returned by take_front buf after i-1 calls to junk_front buf.
length buf).get_back buf i returns the i-th element of buf from the back, i.e.
+the one returned by take_back buf after i-1 calls to junk_back buf.
length buf).Push value at the back of t.
+If t.bounded=false, the buffer will grow as needed,
+otherwise the oldest elements are replaced first.
Create a buffer from an initial array, but doesn't take ownership +of it (still allocates a new internal array).
Simple implementation of functional queues
val empty : 'a tval is_empty : 'a t ‑> boolSame as pop, but fails on empty queues.
Append two queues. Elements from the second one come +after elements of the first one. +Linear in the size of the second queue.
module Infix : sig ... endval fold : ('b ‑> 'a ‑> 'b) ‑> 'b ‑> 'a t ‑> 'bval iter : ('a ‑> unit) ‑> 'a t ‑> unitval to_list : 'a t ‑> 'a listval of_list : 'a list ‑> 'a tval empty : 'a tval is_empty : _ t ‑> boolSame as find but can fail.
longest_prefix k m finds the longest prefix of k that leads to
+at least one path in m (it does not mean that the prefix is bound to
+a value.
Example: if m has keys "abc0" and "abcd", then longest_prefix "abc2" m
+will return "abc".
Update the binding for the given key. The function is given
+None if the key is absent, or Some v if key is bound to v;
+if it returns None the key is removed, otherwise it
+returns Some y and key becomes bound to y.
Fold on key/value bindings. Will use WORD.of_list to rebuild keys.
Map values, giving both key and value. Will use WORD.of_list to rebuild keys.
val fold_values : ('b ‑> 'a ‑> 'b) ‑> 'b ‑> 'a t ‑> 'bMore efficient version of fold, that doesn't keep keys.
val iter_values : ('a ‑> unit) ‑> 'a t ‑> unitMerge two tries together. The function is used in +case of conflicts, when a key belongs to both tries.
val empty : 'a tval is_empty : _ t ‑> boolSame as find but can fail.
longest_prefix k m finds the longest prefix of k that leads to
+at least one path in m (it does not mean that the prefix is bound to
+a value.
Example: if m has keys "abc0" and "abcd", then longest_prefix "abc2" m
+will return "abc".
Update the binding for the given key. The function is given
+None if the key is absent, or Some v if key is bound to v;
+if it returns None the key is removed, otherwise it
+returns Some y and key becomes bound to y.
Fold on key/value bindings. Will use WORD.of_list to rebuild keys.
Map values, giving both key and value. Will use WORD.of_list to rebuild keys.
val fold_values : ('b ‑> 'a ‑> 'b) ‑> 'b ‑> 'a t ‑> 'bMore efficient version of fold, that doesn't keep keys.
val iter_values : ('a ‑> unit) ‑> 'a t ‑> unitMerge two tries together. The function is used in +case of conflicts, when a key belongs to both tries.
val empty : 'a tval is_empty : _ t ‑> boolSame as find but can fail.
longest_prefix k m finds the longest prefix of k that leads to
+at least one path in m (it does not mean that the prefix is bound to
+a value.
Example: if m has keys "abc0" and "abcd", then longest_prefix "abc2" m
+will return "abc".
Update the binding for the given key. The function is given
+None if the key is absent, or Some v if key is bound to v;
+if it returns None the key is removed, otherwise it
+returns Some y and key becomes bound to y.
Fold on key/value bindings. Will use WORD.of_list to rebuild keys.
Map values, giving both key and value. Will use WORD.of_list to rebuild keys.
val fold_values : ('b ‑> 'a ‑> 'b) ‑> 'b ‑> 'a t ‑> 'bMore efficient version of fold, that doesn't keep keys.
val iter_values : ('a ‑> unit) ‑> 'a t ‑> unitMerge two tries together. The function is used in +case of conflicts, when a key belongs to both tries.
val empty : 'a tval is_empty : _ t ‑> boolSame as find but can fail.
longest_prefix k m finds the longest prefix of k that leads to
+at least one path in m (it does not mean that the prefix is bound to
+a value.
Example: if m has keys "abc0" and "abcd", then longest_prefix "abc2" m
+will return "abc".
Update the binding for the given key. The function is given
+None if the key is absent, or Some v if key is bound to v;
+if it returns None the key is removed, otherwise it
+returns Some y and key becomes bound to y.
Fold on key/value bindings. Will use WORD.of_list to rebuild keys.
Map values, giving both key and value. Will use WORD.of_list to rebuild keys.
val fold_values : ('b ‑> 'a ‑> 'b) ‑> 'b ‑> 'a t ‑> 'bMore efficient version of fold, that doesn't keep keys.
val iter_values : ('a ‑> unit) ‑> 'a t ‑> unitMerge two tries together. The function is used in +case of conflicts, when a key belongs to both tries.
Words are made of characters, who belong to a total order
module type WORD : sig ... endmodule type S : sig ... endmodule type ORDERED : sig ... endval empty : 'a tval is_empty : _ t ‑> boolSame as find but can fail.
longest_prefix k m finds the longest prefix of k that leads to
+at least one path in m (it does not mean that the prefix is bound to
+a value.
Example: if m has keys "abc0" and "abcd", then longest_prefix "abc2" m
+will return "abc".
Update the binding for the given key. The function is given
+None if the key is absent, or Some v if key is bound to v;
+if it returns None the key is removed, otherwise it
+returns Some y and key becomes bound to y.
Fold on key/value bindings. Will use WORD.of_list to rebuild keys.
Map values, giving both key and value. Will use WORD.of_list to rebuild keys.
val fold_values : ('b ‑> 'a ‑> 'b) ‑> 'b ‑> 'a t ‑> 'bMore efficient version of fold, that doesn't keep keys.
val iter_values : ('a ‑> unit) ‑> 'a t ‑> unitMerge two tries together. The function is used in +case of conflicts, when a key belongs to both tries.
val empty : 'a tval is_empty : _ t ‑> boolget_rank k m looks for the rank of k in m, i.e. the index
+of k in the sorted list of bindings of m.
+let (`At n) = get_rank k m in nth_exn n m = get m k should hold.
update k f m calls f (Some v) if get k m = Some v, f None
+otherwise. Then, if f returns Some v' it binds k to v',
+if f returns None it removes k.
val cardinal : _ t ‑> intval weight : _ t ‑> intsplit k t returns l, o, r where l is the part of the map
+with keys smaller than k, r has keys bigger than k,
+and o = Some v if k, v belonged to the map.
extract_min m returns k, v, m' where k,v is the pair with the
+smallest key in m, and m' does not contain k.
extract_max m returns k, v, m' where k,v is the pair with the
+highest key in m, and m' does not contain k.
Randomly choose a (key,value) pair within the tree, using weights +as probability weights.
val weight : t ‑> intUse the custom X.weight function
val empty : 'a tval is_empty : _ t ‑> boolget_rank k m looks for the rank of k in m, i.e. the index
+of k in the sorted list of bindings of m.
+let (`At n) = get_rank k m in nth_exn n m = get m k should hold.
update k f m calls f (Some v) if get k m = Some v, f None
+otherwise. Then, if f returns Some v' it binds k to v',
+if f returns None it removes k.
val cardinal : _ t ‑> intval weight : _ t ‑> intsplit k t returns l, o, r where l is the part of the map
+with keys smaller than k, r has keys bigger than k,
+and o = Some v if k, v belonged to the map.
extract_min m returns k, v, m' where k,v is the pair with the
+smallest key in m, and m' does not contain k.
extract_max m returns k, v, m' where k,v is the pair with the
+highest key in m, and m' does not contain k.
Randomly choose a (key,value) pair within the tree, using weights +as probability weights.
status: experimental
module type ORD : sig ... endmodule type KEY : sig ... endmodule type S : sig ... endval weight : t ‑> intval empty : 'a tval is_empty : _ t ‑> boolget_rank k m looks for the rank of k in m, i.e. the index
+of k in the sorted list of bindings of m.
+let (`At n) = get_rank k m in nth_exn n m = get m k should hold.
update k f m calls f (Some v) if get k m = Some v, f None
+otherwise. Then, if f returns Some v' it binds k to v',
+if f returns None it removes k.
val cardinal : _ t ‑> intval weight : _ t ‑> intsplit k t returns l, o, r where l is the part of the map
+with keys smaller than k, r has keys bigger than k,
+and o = Some v if k, v belonged to the map.
extract_min m returns k, v, m' where k,v is the pair with the
+smallest key in m, and m' does not contain k.
extract_max m returns k, v, m' where k,v is the pair with the
+highest key in m, and m' does not contain k.
Randomly choose a (key,value) pair within the tree, using weights +as probability weights.
type 'a t = 'a list * 'a listThe pair l, r represents the list List.rev_append l r, but
+with the focus on r
val to_list : 'a t ‑> 'a listConvert the zipper back to a list.
+to_list (l,r) is List.rev_append l r.
val to_rev_list : 'a t ‑> 'a listConvert the zipper back to a reversed list.
+In other words, to_list (l,r) is List.rev_append r l.
Modify the current element, if any, by returning a new element, or
+returning None if the element is to be deleted.
Insert an element at the current position. If an element was focused,
+insert x l adds x just before it, and focuses on x.
val is_focused : _ t ‑> boolIs the zipper focused on some element? That is, will focused
+return a Some v?
val focused : 'a t ‑> 'a optionReturn the focused element, if any. focused zip = Some _ iff
+empty zip = false.
val focused_exn : 'a t ‑> 'aReturn the focused element, or
Drop every element on the "right" (calling right then will do nothing), +keeping the focused element, if any.
Drop every element on the "right" (calling right then will do nothing), +including the focused element if it is present.
+This library exposes the following toplevel modules:
.
\ No newline at end of file diff --git a/2.1/containers.data/page-index.odoc b/2.1/containers.data/page-index.odoc new file mode 100644 index 00000000..e4a4b413 Binary files /dev/null and b/2.1/containers.data/page-index.odoc differ diff --git a/2.1/containers.iter/CCKList.odoc b/2.1/containers.iter/CCKList.odoc new file mode 100644 index 00000000..d484b5e6 Binary files /dev/null and b/2.1/containers.iter/CCKList.odoc differ diff --git a/2.1/containers.iter/CCKList/.jbuilder-keep b/2.1/containers.iter/CCKList/.jbuilder-keep new file mode 100644 index 00000000..e69de29b diff --git a/2.1/containers.iter/CCKList/Infix/index.html b/2.1/containers.iter/CCKList/Infix/index.html new file mode 100644 index 00000000..45dfb5e1 --- /dev/null +++ b/2.1/containers.iter/CCKList/Infix/index.html @@ -0,0 +1,2 @@ + +val (--) : int ‑> int ‑> int tval (--^) : int ‑> int ‑> int tval return : 'a ‑> 'a tval nil : 'a tval empty : 'a tval singleton : 'a ‑> 'a tval repeat : ?n:int ‑> 'a ‑> 'a trepeat ~n x repeats xn times then stops. If n is omitted,
+then x is repeated forever.
val unfold : ('b ‑> ('a * 'b) option) ‑> 'b ‑> 'a tunfold f acc calls f acc and:
+
f acc = Some (x, acc'), yield x, continue with unfold f acc'.f acc = None, stops.val is_empty : 'a t ‑> boolUnsafe version of tail.
val iter : ('a ‑> unit) ‑> 'a t ‑> unitval length : _ t ‑> intNumber of elements in the list. +Will not terminate if the list if infinite: +use (for instance) take to make the list finite if necessary.
Fair product of two (possibly infinite) lists into a new list. Lazy. +The first parameter is used to combine each pair of elements.
Specialization of product_with producing tuples.
group eq l groups together consecutive elements that satisfy eq. Lazy.
+For instance group (=) [1;1;1;2;2;3;3;1] yields
+[1;1;1]; [2;2]; [3;3]; [1].
uniq eq l returns l but removes consecutive duplicates. Lazy.
+In other words, if several values that are equal follow one another,
+only the first of them is kept.
val range : int ‑> int ‑> int tval (--) : int ‑> int ‑> int ta -- b is the range of integers containing
+a and b (therefore, never empty).
val (--^) : int ‑> int ‑> int ta -- b is the integer range from a to b, where b is excluded.
Eager sort that removes duplicate values. Require the iterator to be
+finite. O(n ln(n)) time and space.
val return : 'a ‑> 'a tval pure : 'a ‑> 'a tmodule Infix : sig ... endval of_list : 'a list ‑> 'a tval return : 'a ‑> 'a ttype attribute = [ | `Color of string |
| `Shape of string |
| `Weight of int |
| `Style of string |
| `Label of string |
| `Id of string |
| `Other of string * string |
]Dot attributes for nodes
val mk_id : ('a, Buffer.t, unit, attribute) Pervasives.format4 ‑> 'aUsing a formatter string, build an ID.
val mk_label : ('a, Buffer.t, unit, attribute) Pervasives.format4 ‑> 'aUsing a formatter string, build a label.
val print_to_file : string ‑> graph ‑> unitprint_to_file filename g prints g into a file whose name
+is filename.
to_file filename trees makes a graph out of the trees, opens the
+file filename and prints the graph into the file.
Abstract Set structure
method add : 'a ‑> 'a pset+This structure can be used to represent trees and directed +graphs (as infinite trees) in a lazy fashion. Like CCKList, it +is a structural type.
val empty : 'a tval is_empty : _ t ‑> boolval fold : ('a ‑> 'b ‑> 'a) ‑> 'a ‑> 'b t ‑> 'aFold on values in no specified order. May not terminate if the +tree is infinite.
val iter : ('a ‑> unit) ‑> 'a t ‑> unitval set_of_cmp : cmp:('a ‑> 'a ‑> int) ‑> unit ‑> 'a psetBuild a set structure given a total ordering.
val force : 'a t ‑> [ `Nil | `Node of 'a * 'b list ] as bforce t evaluates t completely and returns a regular tree
+structure.
Example (tree of calls for naive Fibonacci function): +
let mk_fib n =
+ let rec fib' l r i =
+ if i=n then r else fib' r (l+r) (i+1)
+ in fib' 1 1 1;;
+
+ let rec fib n = match n with
+ | 0 | 1 -> CCKTree.singleton (`Cst n)
+ | _ -> CCKTree.node2 (`Plus (mk_fib n)) (fib (n-1)) (fib (n-2));;
+
+ let pp_node fmt = function
+ | `Cst n -> Format.fprintf fmt "%d" n
+ | `Plus n -> Format.fprintf fmt "%d" n;;
+
+ Format.printf "%a@." (CCKTree.pp pp_node) (fib 8);;A pretty-printer using S-expressions and boxes to render the tree. +Empty nodes are not rendered; sharing is ignored.
module Dot : sig ... endval length : _ t ‑> intlength l returns the number of elements in l, eagerly (linear time).
+Caution, will not terminate if l is infinite.
module Infix : sig ... endval of_list : 'a list ‑> 'a tval to_list : 'a t ‑> 'a listval to_list_rev : 'a t ‑> 'a list+This library exposes the following toplevel modules:
| CCKList | |
| CCKTree | |
| CCLazy_list |
.
\ No newline at end of file diff --git a/2.1/containers.iter/page-index.odoc b/2.1/containers.iter/page-index.odoc new file mode 100644 index 00000000..9e8e2cae Binary files /dev/null and b/2.1/containers.iter/page-index.odoc differ diff --git a/2.1/containers.monomorphic/CCMonomorphic.odoc b/2.1/containers.monomorphic/CCMonomorphic.odoc new file mode 100644 index 00000000..b97fa980 Binary files /dev/null and b/2.1/containers.monomorphic/CCMonomorphic.odoc differ diff --git a/2.1/containers.monomorphic/CCMonomorphic/.jbuilder-keep b/2.1/containers.monomorphic/CCMonomorphic/.jbuilder-keep new file mode 100644 index 00000000..e69de29b diff --git a/2.1/containers.monomorphic/CCMonomorphic/index.html b/2.1/containers.monomorphic/CCMonomorphic/index.html new file mode 100644 index 00000000..619da61c --- /dev/null +++ b/2.1/containers.monomorphic/CCMonomorphic/index.html @@ -0,0 +1,2 @@ + +val (==) : [ `Consider_using_CCEqual_physical ]val (!=) : [ `Consider_using_CCEqual_physical ]+This library exposes the following toplevel modules:
| CCMonomorphic |
.
\ No newline at end of file diff --git a/2.1/containers.monomorphic/page-index.odoc b/2.1/containers.monomorphic/page-index.odoc new file mode 100644 index 00000000..abc761f6 Binary files /dev/null and b/2.1/containers.monomorphic/page-index.odoc differ diff --git a/2.1/containers.sexp/CCSexp.odoc b/2.1/containers.sexp/CCSexp.odoc new file mode 100644 index 00000000..8b8e09ed Binary files /dev/null and b/2.1/containers.sexp/CCSexp.odoc differ diff --git a/2.1/containers.sexp/CCSexp/.jbuilder-keep b/2.1/containers.sexp/CCSexp/.jbuilder-keep new file mode 100644 index 00000000..e69de29b diff --git a/2.1/containers.sexp/CCSexp/Decoder/index.html b/2.1/containers.sexp/CCSexp/Decoder/index.html new file mode 100644 index 00000000..6a8a2937 --- /dev/null +++ b/2.1/containers.sexp/CCSexp/Decoder/index.html @@ -0,0 +1,3 @@ + +val of_lexbuf : Lexing.lexbuf ‑> tval next : t ‑> sexp parse_resultParse the next S-expression or return an error if the input isn't +long enough or isn't a proper S-expression.
val hash : t ‑> intval of_int : int ‑> tval of_bool : bool ‑> tval of_unit : tof_variant name args is used to encode algebraic variants
+into a S-expr. For instance of_variant "some" [of_int 1]
+represents the value Some 1.
val to_buf : Buffer.t ‑> t ‑> unitval to_string : t ‑> stringval to_file : string ‑> t ‑> unitval to_chan : Pervasives.out_channel ‑> t ‑> unitA parser of 'a can return Yield x when it parsed a value,
+or Fail e when a parse error was encountered, or
+End if the input was empty.
module Decoder : sig ... endParse a S-expression from the given channel. Can read more data than +necessary, so don't use this if you need finer-grained control (e.g. +to read something else after the S-exp).
val token : Lexing.lexbuf ‑> tokenval __ocaml_lex_token_rec : Lexing.lexbuf ‑> int ‑> token+This library exposes the following toplevel modules:
| CCSexp | |
| CCSexp_lex |
.
\ No newline at end of file diff --git a/2.1/containers.sexp/page-index.odoc b/2.1/containers.sexp/page-index.odoc new file mode 100644 index 00000000..e84cae87 Binary files /dev/null and b/2.1/containers.sexp/page-index.odoc differ diff --git a/2.1/containers.thread/CCBlockingQueue.odoc b/2.1/containers.thread/CCBlockingQueue.odoc new file mode 100644 index 00000000..5d19a967 Binary files /dev/null and b/2.1/containers.thread/CCBlockingQueue.odoc differ diff --git a/2.1/containers.thread/CCBlockingQueue/.jbuilder-keep b/2.1/containers.thread/CCBlockingQueue/.jbuilder-keep new file mode 100644 index 00000000..e69de29b diff --git a/2.1/containers.thread/CCBlockingQueue/index.html b/2.1/containers.thread/CCBlockingQueue/index.html new file mode 100644 index 00000000..f2d80da4 --- /dev/null +++ b/2.1/containers.thread/CCBlockingQueue/index.html @@ -0,0 +1,9 @@ + +This queue has a limited size. Pushing a value on the queue when it +is full will block.
val create : int ‑> 'a tCreate a new queue of size n. Using n=max_int amounts to using
+an infinite queue (2^61 items is a lot to fit in memory); using n=1
+amounts to using a box with 0 or 1 elements inside.
n < 1.val try_take : 'a t ‑> 'a optionTake the first element if the queue is not empty, return None
+otherwise.
val try_push : 'a t ‑> 'a ‑> booltry_push q x pushes x into q if q is not full, in which
+case it returns true.
+If it fails because q is full, it returns false.
val peek : 'a t ‑> 'a optionpeek q returns Some x if x is the first element of q,
+otherwise it returns None.
Type allowing to manipulate the lock as a reference.
val get : 'a t ‑> 'aval set : 'a t ‑> 'a ‑> unitval update : 'a t ‑> ('a ‑> 'a) ‑> unitA value wrapped into a Mutex, for more safety.
val with_lock : 'a t ‑> ('a ‑> 'b) ‑> 'bwith_lock l f runs f x where x is the value protected with
+the lock l, in a critical section. If f x fails, with_lock l f
+fails too but the lock is released.
val try_with_lock : 'a t ‑> ('a ‑> 'b) ‑> 'b optiontry_with_lock l f runs f x in a critical section if l is not
+locked. x is the value protected by the lock l. If f x
+fails, try_with_lock l f fails too but the lock is released.
with_lock_as_ref l f calls f with a reference-like object
+that allows to manipulate the value of l safely.
+The object passed to f must not escape the function call.
val update_map : 'a t ‑> ('a ‑> 'a * 'b) ‑> 'bupdate_map l f computes x', y = f (get l), then puts x' in l
+and returns y.
val get : 'a t ‑> 'aAtomically get the value in the lock. The value that is returned +isn't protected!
val get_then_incr : int t ‑> intget_then_incr x increments x, and returns its previous value.
val get_then_decr : int t ‑> intget_then_decr x decrements x, and returns its previous value.
val get_then_set : bool t ‑> boolget_then_set b sets b to true, and returns the old value.
val get_then_clear : bool t ‑> boolget_then_clear b sets b to false, and returns the old value.
The futures are registration points for callbacks, storing a state, +that are executed in the pool using run.
val make : (unit ‑> 'a) ‑> 'a tCreate a future, representing a value that will be computed by +the function. If the function raises, the future will fail.
val make1 : ('a ‑> 'b) ‑> 'a ‑> 'b tval make2 : ('a ‑> 'b ‑> 'c) ‑> 'a ‑> 'b ‑> 'c tval get : 'a t ‑> 'aBlocking get: wait for the future to be evaluated, and get the value, +or the exception that failed the future is returned. +Raise e if the future failed with e.
val on_success : 'a t ‑> ('a ‑> unit) ‑> unitAttach a handler to be called upon success. +The handler should not call functions on the future. +Might be evaluated now if the future is already done.
val on_failure : _ t ‑> (exn ‑> unit) ‑> unitAttach a handler to be called upon failure. +The handler should not call any function on the future. +Might be evaluated now if the future is already done.
Attach a handler to be called when the future is evaluated. +The handler should not call functions on the future. +Might be evaluated now if the future is already done.
Future that waits for all previous futures to terminate. If any future
+in the array fails, sequence_a l fails too.
map_a f a maps f on every element of a, and will return
+the array of every result if all calls succeed, or an error otherwise.
Future that waits for all previous futures to terminate. If any future
+in the list fails, sequence_l l fails too.
map_l f l maps f on every element of l, and will return
+the list of every result if all calls succeed, or an error otherwise.
Choose among those futures (the first to terminate). Behaves like +the first future that terminates, by failing if the future fails.
Choose among those futures (the first to terminate). Behaves like +the first future that terminates, by failing if the future fails.
app_async f x applies the result of f to the result of x, in
+a separated job scheduled in the pool.
val sleep : float ‑> unit tFuture that returns with success in the given amount of seconds. Blocks +the thread! If you need to wait on many events, consider +using CCTimer.
module Infix : sig ... endval stop : unit ‑> unitAfter calling stop (), most functions will raise Stopped.
+This has the effect of preventing new tasks from being executed.
Renamed and heavily updated from CCFuture.
module type PARAM : sig ... endval create : int ‑> tcreate n creates a semaphore with initial value n.
n <= 0.val acquire : int ‑> t ‑> unitacquire n s blocks until get s >= n, then atomically
+sets s := !s - n.
val with_acquire : n:int ‑> t ‑> f:(unit ‑> 'a) ‑> 'awith_acquire ~n s ~f first acquires s with n units,
+calls f (), and then releases s with n units.
+Safely release the semaphore even if f () fails.
val wait_until_at_least : n:int ‑> t ‑> f:(unit ‑> 'a) ‑> 'await_until_at_least ~n s ~f waits until get s >= n, then calls f ()
+and returns its result. Doesn't modify the semaphore.
val spawn : int ‑> (int ‑> 'a) ‑> t arrayArr.spawn n f creates an array res of length n, such that
+res.(i) = spawn (fun () -> f i).
val wait : t ‑> unitwait b waits for barrier b to be activated by activate b.
+All threads calling this wait until activate b is called.
+If b is already activated, wait b does nothing.
val activated : t ‑> boolactivated b returns true iff activate b was called, and reset b
+was not called since. In other words, activated b = true means
+wait b will not block.
status: unstable
val spawn2 : ('a ‑> 'b ‑> _) ‑> 'a ‑> 'b ‑> tspawn2 f x y is like spawn (fun () -> f x y).
module Barrier : sig ... endUsed to be part of CCFuture.
val set_exn_handler : t ‑> (exn ‑> unit) ‑> unitset_exn_handler timer f registers f so that any exception
+raised by a task scheduled in timer is given to f.
val after : t ‑> float ‑> f:(unit ‑> _) ‑> unitCall the callback f after the given number of seconds.
val at : t ‑> float ‑> f:(unit ‑> _) ‑> unitCreate a future that evaluates to () at the given Unix timestamp.
val every : ?delay:float ‑> t ‑> float ‑> f:(unit ‑> _) ‑> unitevery timer n ~f calls f () every n seconds.
+f() can raise ExitEvery to stop the cycle.
f () is delayed by
+that many seconds.val stop : t ‑> unitStop the given timer, cancelling pending tasks. Idempotent. +From now on, calling most other operations on the timer will raise Stopped.
+This library exposes the following toplevel modules:
| CCBlockingQueue | |
| CCLock | |
| CCPool | |
| CCSemaphore | |
| CCThread | |
| CCTimer |
.
\ No newline at end of file diff --git a/2.1/containers.thread/page-index.odoc b/2.1/containers.thread/page-index.odoc new file mode 100644 index 00000000..e18b4909 Binary files /dev/null and b/2.1/containers.thread/page-index.odoc differ diff --git a/2.1/containers.top/Containers_top/.jbuilder-keep b/2.1/containers.top/Containers_top/.jbuilder-keep new file mode 100644 index 00000000..e69de29b diff --git a/2.1/containers.top/Containers_top/index.html b/2.1/containers.top/Containers_top/index.html new file mode 100644 index 00000000..e6c24d1b --- /dev/null +++ b/2.1/containers.top/Containers_top/index.html @@ -0,0 +1,2 @@ + ++This library exposes the following toplevel modules:
| Containers_top |
.
\ No newline at end of file diff --git a/2.1/containers.top/page-index.odoc b/2.1/containers.top/page-index.odoc new file mode 100644 index 00000000..9084745b Binary files /dev/null and b/2.1/containers.top/page-index.odoc differ diff --git a/2.1/containers.unix/CCUnix.odoc b/2.1/containers.unix/CCUnix.odoc new file mode 100644 index 00000000..37cd1362 Binary files /dev/null and b/2.1/containers.unix/CCUnix.odoc differ diff --git a/2.1/containers.unix/CCUnix/.jbuilder-keep b/2.1/containers.unix/CCUnix/.jbuilder-keep new file mode 100644 index 00000000..e69de29b diff --git a/2.1/containers.unix/CCUnix/Infix/index.html b/2.1/containers.unix/CCUnix/Infix/index.html new file mode 100644 index 00000000..f990dc03 --- /dev/null +++ b/2.1/containers.unix/CCUnix/Infix/index.html @@ -0,0 +1,2 @@ + +val (?|) : ('a, Buffer.t, unit, call_result) Pervasives.format4 ‑> 'aInfix version of call.
val (?|&) : ('a, Buffer.t, unit, async_call_result) Pervasives.format4 ‑> 'aInfix version of async_call.
Some useful functions built on top of Unix.
status: unstable
type call_result = < stdout : string; stderr : string; status : Unix.process_status; errcode : int; >val call_full : ?bufsize:int ‑> ?stdin:[ `Gen of string gen | `Str of string ] ‑> ?env:string array ‑> ('a, Buffer.t, unit, call_result) Pervasives.format4 ‑> 'acall_full cmd wraps the result of Unix.open_process_full cmd into an
+object. It reads the full stdout and stderr of the subprocess before
+returning.
val call : ?bufsize:int ‑> ?stdin:[ `Gen of string gen | `Str of string ] ‑> ?env:string array ‑> ('a, Buffer.t, unit, string * string * int) Pervasives.format4 ‑> 'acall cmd is similar to call_full cmd but returns
+a tuple stdout, stderr, errcode instead of an object.
val call_stdout : ?bufsize:int ‑> ?stdin:[ `Gen of string gen | `Str of string ] ‑> ?env:string array ‑> ('a, Buffer.t, unit, string) Pervasives.format4 ‑> 'atype async_call_result = < stdout : line gen; stderr : line gen; stdin : line ‑> unit; close_in : unit; close_err : unit; close_out : unit; close_all : unit; wait : Unix.process_status; wait_errcode : int; >A subprocess for interactive usage (read/write channels line by line)
val async_call : ?env:string array ‑> ('a, Buffer.t, unit, async_call_result) Pervasives.format4 ‑> 'aSpawns a subprocess, like call, but the subprocess's channels are
+line generators and line sinks (for stdin).
+If p is async_call "cmd", then p#wait waits for the subprocess
+to die. Channels can be closed independently.
val with_in : ?mode:int ‑> ?flags:Unix.open_flag list ‑> string ‑> f:(Pervasives.in_channel ‑> 'a) ‑> 'aOpen 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.
Unix.O_RDONLY is used in any cases.val with_out : ?mode:int ‑> ?flags:Unix.open_flag list ‑> string ‑> f:(Pervasives.out_channel ‑> 'a) ‑> 'aSame as with_in but for an output channel.
[Unix.O_CREAT; Unix.O_TRUNC])
+Unix.O_WRONLY is used in any cases.val with_process_in : string ‑> f:(Pervasives.in_channel ‑> 'a) ‑> 'aOpen a subprocess and obtain a handle to its stdout. +
CCUnix.with_process_in "ls /tmp" ~f:CCIO.read_lines_l;;val with_process_out : string ‑> f:(Pervasives.out_channel ‑> 'a) ‑> 'aOpen a subprocess and obtain a handle to its stdin.
type process_full = < stdin : Pervasives.out_channel; stdout : Pervasives.in_channel; stderr : Pervasives.in_channel; close : Unix.process_status; >Handle to a subprocess.
val with_process_full : ?env:string array ‑> string ‑> f:(process_full ‑> 'a) ‑> 'aOpen a subprocess and obtain a handle to its channels.
val with_connection : Unix.sockaddr ‑> f:(Pervasives.in_channel ‑> Pervasives.out_channel ‑> 'a) ‑> 'aWrap Unix.open_connection with a handler.
val establish_server : Unix.sockaddr ‑> f:(Pervasives.in_channel ‑> Pervasives.out_channel ‑> _) ‑> unitListen on the address and calls the handler in a blocking fashion. +Using Thread is recommended if handlers might take time. +The callback should raise ExitServer to stop the loop.
val with_file_lock : kind:[ `Read | `Write ] ‑> string ‑> (unit ‑> 'a) ‑> 'awith_file_lock ~kind filename f puts a lock on the offset 0
+of the file named filename, calls f and returns its result after
+the file is unlocked. If f () raises an exception the exception is
+re-raised after the file is unlocked.
module Infix : sig ... endinclude module type of Infixval (?|) : ('a, Buffer.t, unit, call_result) Pervasives.format4 ‑> 'aInfix version of call.
val (?|&) : ('a, Buffer.t, unit, async_call_result) Pervasives.format4 ‑> 'aInfix version of async_call.
+This library exposes the following toplevel modules:
| CCUnix |
.
\ No newline at end of file diff --git a/2.1/containers.unix/page-index.odoc b/2.1/containers.unix/page-index.odoc new file mode 100644 index 00000000..f267064f Binary files /dev/null and b/2.1/containers.unix/page-index.odoc differ diff --git a/2.1/containers/CCArray.odoc b/2.1/containers/CCArray.odoc new file mode 100644 index 00000000..56f3f332 Binary files /dev/null and b/2.1/containers/CCArray.odoc differ diff --git a/2.1/containers/CCArray/.jbuilder-keep b/2.1/containers/CCArray/.jbuilder-keep new file mode 100644 index 00000000..e69de29b diff --git a/2.1/containers/CCArray/index.html b/2.1/containers/CCArray/index.html new file mode 100644 index 00000000..fa4be80e --- /dev/null +++ b/2.1/containers/CCArray/index.html @@ -0,0 +1,53 @@ + +Hoist an equality test for elements to arrays. +Arrays are only equal if their lengths are the same and +corresponding elements test equal.
val get : 'a t ‑> int ‑> 'aget 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 optionget_safe a i returns Some a.(i) if i is a valid index.
val set : 'a t ‑> int ‑> 'a ‑> unitset 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 fold : ('a ‑> 'b ‑> 'a) ‑> 'a ‑> 'b t ‑> 'afold 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 fold_while : ('a ‑> 'b ‑> 'a * [ `Stop | `Continue ]) ‑> 'a ‑> 'b t ‑> 'aFold left on array until a stop condition via ('a, `Stop) is
+indicated by the accumulator.
fold_map f acc a is a fold_left-like function, but it also maps the
+array to another array.
val iter : ('a ‑> unit) ‑> 'a t ‑> unititer 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 ‑> unitLike Array.iter, but the function is applied to the index of the +element as first argument, and the element itself as second argument.
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 sorted : ('a ‑> 'a ‑> int) ‑> 'a t ‑> 'a arraysorted cmp a makes a copy of a and sorts it with cmp.
val sort_indices : ('a ‑> 'a ‑> int) ‑> 'a t ‑> int arraysort_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.
val sort_ranking : ('a ‑> 'a ‑> int) ‑> 'a t ‑> int arraysort_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).
val find_map : ('a ‑> 'b option) ‑> 'a t ‑> 'b optionfind_map f a returns Some y if there is an element x such
+that f x = Some y, else it returns None.
val find_map_i : (int ‑> 'a ‑> 'b option) ‑> 'a t ‑> 'b optionLike find_map, but also pass the index to the predicate function.
val findi : (int ‑> 'a ‑> 'b option) ‑> 'a t ‑> 'b optionAlias to find_map_i.
val find_idx : ('a ‑> bool) ‑> 'a t ‑> (int * 'a) optionfind_idx p x returns Some (i,x) where x is the i-th element of l,
+and p x holds. Otherwise returns None.
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).
None if the key is not present, or
+Some i (i the index of the key) otherwise.Like lookup, but
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.cmp.val for_all : ('a ‑> bool) ‑> 'a t ‑> boolfor_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).
Forall on pairs of arrays.
val exists : ('a ‑> bool) ‑> 'a t ‑> boolexists 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).
Exists on pairs of arrays.
val random_choose : 'a t ‑> 'a random_genChoose an element randomly.
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.
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) |].
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)|].
val except_idx : 'a t ‑> int ‑> 'a listRemove given index, obtaining the list of the other elements.
val random : 'a random_gen ‑> 'a t random_genval random_non_empty : 'a random_gen ‑> 'a t random_genval random_len : int ‑> 'a random_gen ‑> 'a t random_genmodule type MONO_ARRAY : sig ... endval sort_generic : (module MONO_ARRAY with type elt = 'elt and type t = 'arr) ‑> cmp:('elt ‑> 'elt ‑> int) ‑> 'arr ‑> unitSort the array, without allocating (eats stack space though). Performance +might be lower than Array.sort.
val length : t ‑> intHoist an equality test for elements to arrays. +Arrays are only equal if their lengths are the same and +corresponding elements test equal.
val get : 'a t ‑> int ‑> 'aget 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 optionget_safe a i returns Some a.(i) if i is a valid index.
val set : 'a t ‑> int ‑> 'a ‑> unitset 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 fold : f:('a ‑> 'b ‑> 'a) ‑> init:'a ‑> 'b t ‑> 'afold 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 fold_while : f:('a ‑> 'b ‑> 'a * [ `Stop | `Continue ]) ‑> init:'a ‑> 'b t ‑> 'aFold left on array until a stop condition via ('a, `Stop) is
+indicated by the accumulator.
fold_map f acc a is a fold_left-like function, but it also maps the
+array to another array.
val iter : f:('a ‑> unit) ‑> 'a t ‑> unititer 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 ‑> unitLike Array.iter, but the function is applied to the index of the +element as first argument, and the element itself as second argument.
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 sorted : f:('a ‑> 'a ‑> int) ‑> 'a t ‑> 'a arraysorted cmp a makes a copy of a and sorts it with cmp.
val sort_indices : f:('a ‑> 'a ‑> int) ‑> 'a t ‑> int arraysort_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.
val sort_ranking : f:('a ‑> 'a ‑> int) ‑> 'a t ‑> int arraysort_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).
val find_map : f:('a ‑> 'b option) ‑> 'a t ‑> 'b optionfind_map f a returns Some y if there is an element x such
+that f x = Some y, else it returns None.
val find : f:('a ‑> 'b option) ‑> 'a t ‑> 'b optionfind f a returns Some y if there is an element x such
+that f x = Some y, else it returns None.
val find_map_i : f:(int ‑> 'a ‑> 'b option) ‑> 'a t ‑> 'b optionLike find_map, but also pass the index to the predicate function.
val findi : f:(int ‑> 'a ‑> 'b option) ‑> 'a t ‑> 'b optionLike find, but also pass the index to the predicate function.
val find_idx : f:('a ‑> bool) ‑> 'a t ‑> (int * 'a) optionfind_idx p x returns Some (i,x) where x is the i-th element of l,
+and p x holds. Otherwise returns None.
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).
None if the key is not present, or
+Some i (i the index of the key) otherwise.Like lookup, but
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.cmp.val for_all : f:('a ‑> bool) ‑> 'a t ‑> boolfor_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).
Forall on pairs of arrays.
val exists : f:('a ‑> bool) ‑> 'a t ‑> boolexists 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).
Exists on pairs of arrays.
val random_choose : 'a t ‑> 'a random_genChoose an element randomly.
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) |].
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)|].
val except_idx : 'a t ‑> int ‑> 'a listRemove given index, obtaining the list of the other elements.
val random : 'a random_gen ‑> 'a t random_genval random_non_empty : 'a random_gen ‑> 'a t random_genval random_len : int ‑> 'a random_gen ‑> 'a t random_genmodule type MONO_ARRAY : sig ... endval sort_generic : (module MONO_ARRAY with type elt = 'elt and type t = 'arr) ‑> cmp:('elt ‑> 'elt ‑> int) ‑> 'arr ‑> unitSort the array, without allocating (eats stack space though). Performance +might be lower than Array.sort.
val length : t ‑> intval get : 'a t ‑> int ‑> 'aget 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 optionget_safe a i returns Some a.(i) if i is a valid index.
val make : 'a array ‑> int ‑> len:int ‑> 'a tCreate a slice from given offset and length.
val of_slice : ('a array * int * int) ‑> 'a tMake 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.
val to_slice : 'a t ‑> 'a array * int * intConvert into a triple (arr, i, len) where len is the length of
+the sub-array of arr starting at offset i.
val underlying : 'a t ‑> 'a arrayUnderlying array (shared). Modifying this array will modify the slice.
val set : 'a t ‑> int ‑> 'a ‑> unitset 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 fold : ('a ‑> 'b ‑> 'a) ‑> 'a ‑> 'b t ‑> 'afold 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 fold_while : ('a ‑> 'b ‑> 'a * [ `Stop | `Continue ]) ‑> 'a ‑> 'b t ‑> 'aFold left on array until a stop condition via ('a, `Stop) is
+indicated by the accumulator.
val iter : ('a ‑> unit) ‑> 'a t ‑> unititer 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 ‑> unitLike Array.iter, but the +function is applied with the index of the element as first argument, +and the element itself as second argument.
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 sorted : ('a ‑> 'a ‑> int) ‑> 'a t ‑> 'a arraysorted cmp a makes a copy of a and sorts it with cmp.
val sort_indices : ('a ‑> 'a ‑> int) ‑> 'a t ‑> int arraysort_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.
val sort_ranking : ('a ‑> 'a ‑> int) ‑> 'a t ‑> int arraysort_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).
val find : ('a ‑> 'b option) ‑> 'a t ‑> 'b optionfind 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 optionLike find, but also pass the index to the predicate function.
val find_idx : ('a ‑> bool) ‑> 'a t ‑> (int * 'a) optionfind_idx p x returns Some (i,x) where x is the i-th element of l,
+and p x holds. Otherwise returns None.
Lookup the index of some value in a sorted array.
None if the key is not present, or
+Some i (i the index of the key) otherwise.Like lookup, but
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.cmp.val for_all : ('a ‑> bool) ‑> 'a t ‑> boolfor_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).
Forall on pairs of arrays.
val exists : ('a ‑> bool) ‑> 'a t ‑> boolexists 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).
Exists on pairs of arrays.
val random_choose : 'a t ‑> 'a random_genChoose an element randomly.
include module type of sig ... endThe 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.
Convert the given character to its equivalent lowercase character, +using the US-ASCII character set.
Convert the given character to its equivalent uppercase character, +using the US-ASCII character set.
val of_int_exn : int ‑> tAlias to Char.chr. +Return the character with the given ASCII code.
0,...,255.val int : int tval string : string tval bool : bool tval float : float tval unit : unit tmap 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 ... endval epsilon : tThe smallest positive float x such that 1.0 +. x <> 1.0.
+Equal to Pervasives.epsilon_float.
val hash : t ‑> intval random : t ‑> t random_genval random_small : t random_genval random_range : t ‑> t ‑> t random_genval sign_exn : t ‑> intsign_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.
val to_string : t ‑> stringval of_string_exn : string ‑> tAlias to float_of_string.
val of_string : string ‑> tAlias to float_of_string.
Return the class of the given floating-point number: +normal, subnormal, zero, infinite or nan (not a number).
module Infix : sig ... endinclude module type of Infixval unit : unit tval int : int tval string : string tval bool : bool tval float : float tval char : char tval int32 : int32 tval int64 : int64 tval nativeint : nativeint tinclude module type of sig ... endval pp_open_box : formatter ‑> int ‑> unitval pp_close_box : formatter ‑> unit ‑> unitval pp_open_hbox : formatter ‑> unit ‑> unitval pp_open_vbox : formatter ‑> int ‑> unitval pp_open_hvbox : formatter ‑> int ‑> unitval pp_open_hovbox : formatter ‑> int ‑> unitval pp_print_string : formatter ‑> string ‑> unitval pp_print_as : formatter ‑> int ‑> string ‑> unitval pp_print_int : formatter ‑> int ‑> unitval pp_print_float : formatter ‑> float ‑> unitval pp_print_char : formatter ‑> char ‑> unitval pp_print_bool : formatter ‑> bool ‑> unitval pp_print_space : formatter ‑> unit ‑> unitval pp_print_cut : formatter ‑> unit ‑> unitval pp_print_break : formatter ‑> int ‑> int ‑> unitval pp_force_newline : formatter ‑> unit ‑> unitval pp_print_if_newline : formatter ‑> unit ‑> unitval pp_print_flush : formatter ‑> unit ‑> unitval pp_print_newline : formatter ‑> unit ‑> unitval pp_set_margin : formatter ‑> int ‑> unitval pp_get_margin : formatter ‑> unit ‑> intval pp_set_max_indent : formatter ‑> int ‑> unitval pp_get_max_indent : formatter ‑> unit ‑> intval pp_set_max_boxes : formatter ‑> int ‑> unitval pp_get_max_boxes : formatter ‑> unit ‑> intval pp_over_max_boxes : formatter ‑> unit ‑> boolval pp_open_tbox : formatter ‑> unit ‑> unitval pp_close_tbox : formatter ‑> unit ‑> unitval pp_set_tab : formatter ‑> unit ‑> unitval pp_print_tab : formatter ‑> unit ‑> unitval pp_print_tbreak : formatter ‑> int ‑> int ‑> unitval pp_set_ellipsis_text : formatter ‑> string ‑> unitval pp_get_ellipsis_text : formatter ‑> unit ‑> stringval pp_open_tag : formatter ‑> string ‑> unitval open_tag : tag ‑> unitval pp_close_tag : formatter ‑> unit ‑> unitval pp_set_tags : formatter ‑> bool ‑> unitval pp_set_print_tags : formatter ‑> bool ‑> unitval pp_set_mark_tags : formatter ‑> bool ‑> unitval pp_get_print_tags : formatter ‑> unit ‑> boolval pp_get_mark_tags : formatter ‑> unit ‑> boolval pp_set_formatter_out_channel : formatter ‑> Pervasives.out_channel ‑> unitval pp_set_formatter_output_functions : formatter ‑> (string ‑> int ‑> int ‑> unit) ‑> (unit ‑> unit) ‑> unitval pp_get_formatter_output_functions : formatter ‑> unit ‑> (string ‑> int ‑> int ‑> unit) * (unit ‑> unit)val pp_set_formatter_out_functions : formatter ‑> formatter_out_functions ‑> unitval set_formatter_out_functions : formatter_out_functions ‑> unitval pp_get_formatter_out_functions : formatter ‑> unit ‑> formatter_out_functionsval get_formatter_out_functions : unit ‑> formatter_out_functionsval pp_set_formatter_tag_functions : formatter ‑> formatter_tag_functions ‑> unitval set_formatter_tag_functions : formatter_tag_functions ‑> unitval pp_get_formatter_tag_functions : formatter ‑> unit ‑> formatter_tag_functionsval get_formatter_tag_functions : unit ‑> formatter_tag_functionsval formatter_of_out_channel : Pervasives.out_channel ‑> formatterval std_formatter : formatterval err_formatter : formatterval formatter_of_buffer : Buffer.t ‑> formatterval str_formatter : formatterval make_formatter : (string ‑> int ‑> int ‑> unit) ‑> (unit ‑> unit) ‑> formatterval formatter_of_out_functions : formatter_out_functions ‑> formatterval make_symbolic_output_buffer : unit ‑> symbolic_output_bufferval clear_symbolic_output_buffer : symbolic_output_buffer ‑> unitval get_symbolic_output_buffer : symbolic_output_buffer ‑> symbolic_output_item listval flush_symbolic_output_buffer : symbolic_output_buffer ‑> symbolic_output_item listval add_symbolic_output_item : symbolic_output_buffer ‑> symbolic_output_item ‑> unitval formatter_of_symbolic_output_buffer : symbolic_output_buffer ‑> formatterval pp_print_text : formatter ‑> string ‑> unitval printf : ('a, formatter, unit) Pervasives.format ‑> 'aval eprintf : ('a, formatter, unit) Pervasives.format ‑> 'aval asprintf : ('a, formatter, unit, string) Pervasives.format4 ‑> 'aval kasprintf : (string ‑> 'a) ‑> ('b, formatter, unit, 'a) Pervasives.format4 ‑> 'bval bprintf : Buffer.t ‑> ('a, formatter, unit) Pervasives.format ‑> 'aval kprintf : (string ‑> 'a) ‑> ('b, unit, string, 'a) Pervasives.format4 ‑> 'bval set_all_formatter_output_functions : out:(string ‑> int ‑> int ‑> unit) ‑> flush:(unit ‑> unit) ‑> newline:(unit ‑> unit) ‑> spaces:(int ‑> unit) ‑> unitval 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) ‑> unitval pp_get_all_formatter_output_functions : formatter ‑> unit ‑> (string ‑> int ‑> int ‑> unit) * (unit ‑> unit) * (unit ‑> unit) * (int ‑> unit)val int : int printerval string : string printerval bool : bool printerval float3 : float printerval float : float printerval substring : (string * int * int) printerPrint the substring (s,i,len), where i is the offset
+in s and len the number of bytes in the substring.
(s,i,len) does not
+describe a proper substring.val text : string printerPrint string, but replacing spaces with breaks and newlines
+with newline.
+See pp_print_text on recent versions of OCaml.
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.
within a b p wraps p inside the strings a and b. Convenient,
+for instances, for brackets, parenthesis, quotes, etc.
Wrap the printer in a vertical box.
Wrap the printer in a horizontal/vertical box.
Wrap the printer in a horizontal or vertical box.
val return : ('a, _, _, 'a) Pervasives.format4 ‑> unit printerreturn "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@]"val of_to_string : ('a ‑> string) ‑> 'a printerof_to_string f converts its input to a string using f,
+then prints the string.
some pp will print options as follows:
+
Some x is printed using pp on xNone is not printed at alllazy_or ?default pp out x prints default if x is not
+evaluated yet, or uses pp otherwise.
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;;
+
+ Format.printf
+ "what is your @{<White>favorite color@}? @{<blue>blue@}! No, @{<red>red@}! Ahhhhhhh@.";;status: unstable
val set_color_tag_handling : t ‑> unitAdd functions to support color tags to the given formatter.
val set_color_default : bool ‑> unitset_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.
with_color "Blue" pp behaves like the printer pp, but with the given
+style.
status: unstable
with_colorf "Blue" out "%s %d" "yolo" 42 will behave like Format.fprintf,
+but wrapping the content with the given style.
status: unstable
val with_color_sf : string ‑> ('a, t, unit, string) Pervasives.format4 ‑> 'awith_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
val with_color_ksf : f:(string ‑> 'b) ‑> string ‑> ('a, t, unit, 'b) Pervasives.format4 ‑> 'awith_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];;val to_string : 'a printer ‑> 'a ‑> stringval with_out_chan : Pervasives.out_channel ‑> (t ‑> 'a) ‑> 'awith_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.
val stdout : tval stderr : tval sprintf : ('a, t, unit, string) Pervasives.format4 ‑> 'aPrint into a string any format string that would usually be compatible +with fprintf. Like Format.asprintf.
val sprintf_no_color : ('a, t, unit, string) Pervasives.format4 ‑> 'aLike sprintf but never prints colors.
val sprintf_dyn_color : colors:bool ‑> ('a, t, unit, string) Pervasives.format4 ‑> 'aLike 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;;Like fprintf but enable/disable colors depending on colors.
val ksprintf : ?margin:int ‑> f:(string ‑> 'b) ‑> ('a, Format.formatter, unit, 'b) Pervasives.format4 ‑> 'aksprintf fmt ~f formats using fmt, in a way similar to sprintf,
+and then calls f on the resulting string.
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] |];;module Dump : sig ... endX : sig ... endval compose_binop : ('a ‑> 'b) ‑> ('b ‑> 'b ‑> 'c) ‑> 'a ‑> 'a ‑> 'ccompose_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].
val const : 'a ‑> 'b ‑> 'aProduce a function that just returns its first argument.
+const x y = x for any y.
val curry : (('a * 'b) ‑> 'c) ‑> 'a ‑> 'b ‑> 'cConvert 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) ‑> 'cConvert 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 ‑> 'atap 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.compareval lexicographic : ('a ‑> 'a ‑> int) ‑> ('a ‑> 'a ‑> int) ‑> 'a ‑> 'a ‑> intLexicographic combination of comparison functions.
val finally : h:(unit ‑> _) ‑> f:(unit ‑> 'a) ‑> 'afinally 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 ‑> 'bfinally1 ~h f x is the same as f x, but after the computation,
+h () is called whether f x rose an exception or not.
val finally2 : h:(unit ‑> _) ‑> ('a ‑> 'b ‑> 'c) ‑> 'a ‑> 'b ‑> 'cfinally2 ~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.
val opaque_identity : 'a ‑> 'aopaque_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).
val iterate : int ‑> ('a ‑> 'a) ‑> 'a ‑> 'aiterate 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.
Functions with a fixed domain are monads in their codomain.
\ No newline at end of file diff --git a/2.1/containers/CCHash.odoc b/2.1/containers/CCHash.odoc new file mode 100644 index 00000000..d9dad901 Binary files /dev/null and b/2.1/containers/CCHash.odoc differ diff --git a/2.1/containers/CCHash/.jbuilder-keep b/2.1/containers/CCHash/.jbuilder-keep new file mode 100644 index 00000000..e69de29b diff --git a/2.1/containers/CCHash/index.html b/2.1/containers/CCHash/index.html new file mode 100644 index 00000000..149af87c --- /dev/null +++ b/2.1/containers/CCHash/index.html @@ -0,0 +1,8 @@ + +val const0 : _ tAlways 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).
val int : int tval bool : bool tval char : char tval int32 : int32 tval int64 : int64 tval nativeint : nativeint tval slice : string ‑> int ‑> int tslice s i len state hashes the slice i, ... i+len-1 of s
+into state.
val string : string tCommutative version of list. Lists that are equal up to permutation +will have the same hash.
Commutative version of array. Arrays that are equal up to permutation +will have the same hash.
val get_or : ('a, 'b) Hashtbl.t ‑> 'a ‑> default:'b ‑> 'bget_or tbl k ~default returns the value associated to k if present,
+and returns default otherwise (if k doesn't belong in tbl).
val keys_list : ('a, 'b) Hashtbl.t ‑> 'a listkeys_list t is the list of keys in t.
+If the key is in the Hashtable multiple times, all occurrences will be returned.
val map_list : ('a ‑> 'b ‑> 'c) ‑> ('a, 'b) Hashtbl.t ‑> 'c listMap on a hashtable's items, collect into a list.
val incr : ?by:int ‑> ('a, int) Hashtbl.t ‑> 'a ‑> unitincr ?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).
by rather than 1.val decr : ?by:int ‑> ('a, int) Hashtbl.t ‑> 'a ‑> unitLike 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.
val add_list : ('a, 'b list) Hashtbl.t ‑> 'a ‑> 'b ‑> unitadd_list tbl x y adds y to the list x is bound to. If x is
+not bound, it becomes bound to y.
val add_seq : ('a, 'b) Hashtbl.t ‑> ('a * 'b) sequence ‑> unitAdd the corresponding pairs to the table, using Hashtbl.add.
val add_seq_count : ('a, int) Hashtbl.t ‑> 'a sequence ‑> unitadd_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.
val of_seq_count : 'a sequence ‑> ('a, int) Hashtbl.tLike add_seq_count, but allocates a new table and returns it.
val of_list : ('a * 'b) list ‑> ('a, 'b) Hashtbl.tBuild 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 ‑> unitupdate 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.
val get_or_add : ('a, 'b) Hashtbl.t ‑> f:('a ‑> 'b) ‑> k:'a ‑> 'bget_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.
This sub-module contains the extension of the standard polymorphic Hashtbl.
module Poly : sig ... endinclude module type of Polyval get_or : ('a, 'b) Hashtbl.t ‑> 'a ‑> default:'b ‑> 'bget_or tbl k ~default returns the value associated to k if present,
+and returns default otherwise (if k doesn't belong in tbl).
val keys_list : ('a, 'b) Hashtbl.t ‑> 'a listkeys_list t is the list of keys in t.
+If the key is in the Hashtable multiple times, all occurrences will be returned.
val map_list : ('a ‑> 'b ‑> 'c) ‑> ('a, 'b) Hashtbl.t ‑> 'c listMap on a hashtable's items, collect into a list.
val incr : ?by:int ‑> ('a, int) Hashtbl.t ‑> 'a ‑> unitincr ?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).
by rather than 1.val decr : ?by:int ‑> ('a, int) Hashtbl.t ‑> 'a ‑> unitLike 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.
val add_list : ('a, 'b list) Hashtbl.t ‑> 'a ‑> 'b ‑> unitadd_list tbl x y adds y to the list x is bound to. If x is
+not bound, it becomes bound to y.
val add_seq : ('a, 'b) Hashtbl.t ‑> ('a * 'b) sequence ‑> unitAdd the corresponding pairs to the table, using Hashtbl.add.
val add_seq_count : ('a, int) Hashtbl.t ‑> 'a sequence ‑> unitadd_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.
val of_seq_count : 'a sequence ‑> ('a, int) Hashtbl.tLike add_seq_count, but allocates a new table and returns it.
val of_list : ('a * 'b) list ‑> ('a, 'b) Hashtbl.tBuild 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 ‑> unitupdate 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.
module type S : sig ... endget_or tbl k ~default returns the value associated to k if present,
+and returns default otherwise (if k doesn't belong in tbl).
add_list tbl x y adds y to the list x is bound to. If x is
+not bound, it becomes bound to y.
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).
by rather than 1.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.
keys_list t is the list of keys in t.
+If the key is in the Hashtable multiple times, all occurrences will be returned.
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.
Like add_seq_count, but allocates a new table and returns it.
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.
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.
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.
E : PARTIAL_ORDExtract and return the minimum element, and the new heap (without
+this element), or None if the heap is empty.
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.
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.
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).
Add the elements of the list to the heap. An element occurring several +times will be added that many times to the heap.
following Okasaki
module type PARTIAL_ORD : sig ... endmodule type S : sig ... endExtract and return the minimum element, and the new heap (without
+this element), or None if the heap is empty.
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.
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.
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).
Add the elements of the list to the heap. An element occurring several +times will be added that many times to the heap.
type t = stringA file should be represented by its absolute path, but currently +this is not enforced.
val to_string : t ‑> stringval exists : t ‑> boolval is_directory : t ‑> boolval remove_exn : t ‑> unitremove_exn path tries to remove the file at path from the
+file system.
path or access rights are wrong.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).
false), sub-directories are also
+explored.val read_exn : t ‑> stringRead the content of the given file, or raises some exception.
val append_exn : t ‑> string ‑> unitAppend the given string into the given file, possibly raising.
val write_exn : t ‑> string ‑> unitWrite the given string into the given file, possibly raising.
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.)
Like walk but returns a list (therefore it's eager and might +take some time on large directories).
val show_walk_item : walk_item ‑> stringval with_temp : ?temp_dir:string ‑> prefix:string ‑> suffix:string ‑> (string ‑> 'a) ‑> 'awith_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.
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
+ )
+ )
+ ) ;;val with_in : ?mode:int ‑> ?flags:Pervasives.open_flag list ‑> string ‑> (Pervasives.in_channel ‑> 'a) ‑> 'aOpen 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.
[Open_text]). Open_rdonly is used in any cases.val read_chunks : ?size:int ‑> Pervasives.in_channel ‑> string genRead the channel's content into chunks of size size.
val read_line : Pervasives.in_channel ‑> string optionRead 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 genRead all lines. The generator should be traversed only once.
val read_all : ?size:int ‑> Pervasives.in_channel ‑> stringRead the whole channel into a buffer, then converted into a string.
val read_all_bytes : ?size:int ‑> Pervasives.in_channel ‑> Bytes.tRead the whole channel into a mutable byte array.
val with_out : ?mode:int ‑> ?flags:Pervasives.open_flag list ‑> string ‑> (Pervasives.out_channel ‑> 'a) ‑> 'aLike with_in but for an output channel.
[Open_creat; Open_trunc; Open_text]).Open_wronly is used in any cases.val with_out_a : ?mode:int ‑> ?flags:Pervasives.open_flag list ‑> string ‑> (Pervasives.out_channel ‑> 'a) ‑> 'aLike with_out but with the [Open_append; Open_creat; Open_wronly]
+flags activated, to append to the file.
val write_line : Pervasives.out_channel ‑> string ‑> unitWrite the given string on the channel, followed by "\n".
val write_gen : ?sep:string ‑> Pervasives.out_channel ‑> string gen ‑> unitWrite 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 ‑> unitWrite every string on the output, followed by "\n".
val with_in_out : ?mode:int ‑> ?flags:Pervasives.open_flag list ‑> string ‑> (Pervasives.in_channel ‑> Pervasives.out_channel ‑> 'a) ‑> 'atee funs gen behaves like gen, but each element is given to
+every function f in funs at the time the element is produced.
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 ... endval hash : t ‑> intpow 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.
floor_div a n is integer division rounding towards negative infinity.
+It satisfies a = m * floor_div a n + rem a n.
val random : int ‑> t random_genval random_small : t random_genval random_range : int ‑> int ‑> t random_genval to_string : t ‑> stringReturn the string representation of its argument, in signed decimal.
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.
step=0.range i j iterates on integers from i to j included . It works
+both for decreasing and increasing ranges.
Like range but the second bound is excluded.
+For instance range' 0 5 = Sequence.of_list [0;1;2;3;4].
module Infix : sig ... endinclude module type of InfixHelpers 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.
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.(/).
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.
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.
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.
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 ... endval to_int : t ‑> intConvert 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_float : float ‑> tAlias 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 of_string_exn : string ‑> tAlias 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 optionSafe version of of_string_exn.
+Like of_string_exn, but return None instead of raising.
Infix operators
Helpers for 64-bit integers
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.(/).
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.
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.
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.
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 to_int : t ‑> intConvert 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 ‑> tAlias to Int64.of_int. +NOTE: used to return an option, but the function actually never fails.
val to_int32 : t ‑> int32Convert 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 ‑> tAlias to Int64.of_int32. +NOTE: use to return an option, but the function actually never fails.
val to_nativeint : t ‑> nativeintConvert 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 ‑> tAlias to Int64.of_nativeint. +NOTE: use to return an option, but the function actually never fails.
val of_float : float ‑> tAlias 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_string_exn : string ‑> tAlias 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.
val get_exn : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> ('a, 'b) t ‑> 'bLike get, but unsafe.
val mem : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> ('a, _) t ‑> boolmem x l returns true iff x is a key in l.
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'.
val push : 'a t ‑> 'a ‑> unitval pop : 'a t ‑> 'a optionval push_list : 'a t ‑> 'a list ‑> unitAdd 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.
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).
include module type of ListSafe 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 ‑> 'bSafe 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 ‑> 'aFold until a stop condition via ('a, `Stop) is
+indicated by the accumulator.
val fold_map : ('acc ‑> 'a ‑> 'acc * 'b) ‑> 'acc ‑> 'a list ‑> 'acc * 'b listfold_map f acc l is a fold_left-like function, but it also maps the
+list to another list.
val scan_left : ('acc ‑> 'a ‑> 'acc) ‑> 'acc ‑> 'a list ‑> 'acc listscan_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.
val fold_map2 : ('acc ‑> 'a ‑> 'b ‑> 'acc * 'c) ‑> 'acc ‑> 'a list ‑> 'b list ‑> 'acc * 'c listfold_map2 is to fold_map what List.map2 is to List.map.
val fold_filter_map : ('acc ‑> 'a ‑> 'acc * 'b option) ‑> 'acc ‑> 'a list ‑> 'acc * 'b listfold_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.
val fold_flat_map : ('acc ‑> 'a ‑> 'acc * 'b list) ‑> 'acc ‑> 'a list ‑> 'acc * 'b listfold_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.
val count : ('a ‑> bool) ‑> 'a list ‑> intcount f l counts how much elements of l comply with the function f.
val init : int ‑> (int ‑> 'a) ‑> 'a tinit len f is f 0; f 1; ...; f (len-1).
val combine : 'a list ‑> 'b list ‑> ('a * 'b) listLike 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)].
val combine_gen : 'a list ‑> 'b list ‑> ('a * 'b) genA 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]).
Equivalent to compare (length l1) (length l2) but more efficient.
+Compare the lengths of two lists.
val compare_length_with : 'a t ‑> int ‑> intEquivalent to compare (length l) x but more efficient.
+Compare the length of a list to an integer.
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.
val map_product_l : ('a ‑> 'b list) ‑> 'a list ‑> 'b list listmap_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.
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 listpartition_map f l maps f on l and gather results in lists:
+
f x = `Left y, adds y to the first list.f x = `Right z, adds z to the second list.f x = `Drop, ignores x.val sublists_of_len : ?last:('a list ‑> 'a list option) ‑> ?offset:int ‑> int ‑> 'a list ‑> 'a list listsublists_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]].n. If offset < n, the sub-lists
+will overlap; if offset > n, some elements will not appear at all.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.offset <= 0 or n <= 0.val intersperse : 'a ‑> 'a list ‑> 'a listInsert the first argument between every element of the list
val interleave : 'a list ‑> 'a list ‑> 'a listinterleave [x1…xn] [y1…ym] is x1,y1,x2,y2,… and finishes with
+the suffix of the longest list
val find_pred : ('a ‑> bool) ‑> 'a t ‑> 'a optionfind_pred p l finds the first element of l that satisfies p,
+or returns None if no element satisfies p.
val find_pred_exn : ('a ‑> bool) ‑> 'a t ‑> 'aUnsafe version of find_pred.
val find_map : ('a ‑> 'b option) ‑> 'a t ‑> 'b optionfind_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.
val find_mapi : (int ‑> 'a ‑> 'b option) ‑> 'a t ‑> 'b optionLike find_map, but also pass the index to the predicate function.
val find_idx : ('a ‑> bool) ‑> 'a t ‑> (int * 'a) optionfind_idx p x returns Some (i,x) where x is the i-th element of l,
+and p x holds. Otherwise returns None.
remove ~x l removes every instance of x from l. Tail-recursive.
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.
all_some l returns Some l' if all elements of l are of the form Some x,
+or None otherwise.
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).
val sorted_merge : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a list ‑> 'a listMerge elements from both sorted list.
val sort_uniq : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a listSort the list and remove duplicate elements.
val sorted_merge_uniq : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a list ‑> 'a listsorted_merge_uniq l1 l2 merges the sorted lists l1 and l2 and
+removes duplicates.
val is_sorted : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> boolis_sorted l returns true iff l is sorted (according to given order).
Pervasives.compare).val sorted_insert : cmp:('a ‑> 'a ‑> int) ‑> ?uniq:bool ‑> 'a ‑> 'a list ‑> 'a listsorted_insert x l inserts x into l such that, if l was sorted,
+then sorted_insert x l is sorted too.
x is already in sorted position in l, then
+x is not duplicated. Default false (x will be inserted in any case).val uniq_succ : eq:('a ‑> 'a ‑> bool) ‑> 'a list ‑> 'a listuniq_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].
val group_succ : eq:('a ‑> 'a ‑> bool) ‑> 'a list ‑> 'a list listgroup_succ ~eq l groups together consecutive elements that are equal
+according to eq.
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 ‑> unitLike 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 : ('b ‑> int ‑> 'a ‑> 'b) ‑> 'b ‑> 'a t ‑> 'bLike fold but it also passes in the index of each element to the folded function. Tail-recursive.
Fold on two lists, with index.
val get_at_idx : int ‑> 'a t ‑> 'a optionGet 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 optionSafe version of nth.
val get_at_idx_exn : int ‑> 'a t ‑> 'aGet the i-th element, or
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.
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.
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.
Those operations maintain the invariant that the list does not +contain duplicates (if it already satisfies it).
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 range_by : step:int ‑> int ‑> int ‑> int trange_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.
step=0.val range : int ‑> int ‑> int trange i j iterates on integers from i to j included. It works
+both for decreasing and increasing ranges.
val range' : int ‑> int ‑> int tLike range but the second bound is excluded.
+For instance range' 0 5 = [0;1;2;3;4].
module Assoc : sig ... endmodule Ref : sig ... endval random : 'a random_gen ‑> 'a t random_genval random_non_empty : 'a random_gen ‑> 'a t random_genval random_len : int ‑> 'a random_gen ‑> 'a t random_genval random_choose : 'a t ‑> 'a random_genRandomly choose an element in the list.
val random_sequence : 'a random_gen t ‑> 'a t random_genBuild a list from a given sequence.
+In the result, elements appear in the same order as they did in the source sequence.
Build a list from a given gen.
+In the result, elements appear in the same order as they did in the source gen.
Build a list from a given klist.
+In the result, elements appear in the same order as they did in the source klist.
+It is convenient to open CCList.Infix to access the infix operators +without cluttering the scope too much.
module Infix : sig ... endval get_exn : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> ('a, 'b) t ‑> 'bLike get, but unsafe.
val mem : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> ('a, _) t ‑> boolmem x l returns true iff x is a key in l.
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'.
val push : 'a t ‑> 'a ‑> unitval pop : 'a t ‑> 'a optionval push_list : 'a t ‑> 'a list ‑> unitAdd 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.
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).
include module type of ListLabelsSafe 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 ‑> 'bSafe 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 ‑> 'aFold until a stop condition via ('a, `Stop) is
+indicated by the accumulator.
val fold_map : f:('acc ‑> 'a ‑> 'acc * 'b) ‑> init:'acc ‑> 'a list ‑> 'acc * 'b listfold_map ~f ~init l is a fold_left-like function, but it also maps the
+list to another list.
val fold_map2 : f:('acc ‑> 'a ‑> 'b ‑> 'acc * 'c) ‑> init:'acc ‑> 'a list ‑> 'b list ‑> 'acc * 'c listfold_map2 is to fold_map what List.map2 is to List.map.
val fold_filter_map : f:('acc ‑> 'a ‑> 'acc * 'b option) ‑> init:'acc ‑> 'a list ‑> 'acc * 'b listfold_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.
val fold_flat_map : f:('acc ‑> 'a ‑> 'acc * 'b list) ‑> init:'acc ‑> 'a list ‑> 'acc * 'b listfold_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.
val init : int ‑> f:(int ‑> 'a) ‑> 'a tinit len ~f is f 0; f 1; ...; f (len-1).
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 listpartition_map ~f l maps f on l and gather results in lists:
+
f x = `Left y, adds y to the first list.f x = `Right z, adds z to the second list.f x = `Drop, ignores x.val sublists_of_len : ?last:('a list ‑> 'a list option) ‑> ?offset:int ‑> len:int ‑> 'a list ‑> 'a list listsublists_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.
val find_pred : f:('a ‑> bool) ‑> 'a t ‑> 'a optionfind_pred p l finds the first element of l that satisfies p,
+or returns None if no element satisfies p.
val find_pred_exn : f:('a ‑> bool) ‑> 'a t ‑> 'aUnsafe version of find_pred.
val find_map : f:('a ‑> 'b option) ‑> 'a t ‑> 'b optionfind_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.
val find_mapi : f:(int ‑> 'a ‑> 'b option) ‑> 'a t ‑> 'b optionLike find_map, but also pass the index to the predicate function.
val find_idx : f:('a ‑> bool) ‑> 'a t ‑> (int * 'a) optionfind_idx p x returns Some (i,x) where x is the i-th element of l,
+and p x holds. Otherwise returns None.
remove ~key l removes every instance of key from l. Tail-recursive.
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 listMerges elements from both sorted list.
val sort_uniq : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a listSort the list and remove duplicate elements.
val sorted_merge_uniq : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a list ‑> 'a listsorted_merge_uniq l1 l2 merges the sorted lists l1 and l2 and
+removes duplicates.
val is_sorted : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> boolis_sorted l returns true iff l is sorted (according to given order).
Pervasives.compare).val sorted_insert : cmp:('a ‑> 'a ‑> int) ‑> ?uniq:bool ‑> 'a ‑> 'a list ‑> 'a listsorted_insert x l inserts x into l such that, if l was sorted,
+then sorted_insert x l is sorted too.
x is already in sorted position in l, then
+x is not duplicated. Default false (x will be inserted in any case).val uniq_succ : eq:('a ‑> 'a ‑> bool) ‑> 'a list ‑> 'a listuniq_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].
val group_succ : eq:('a ‑> 'a ‑> bool) ‑> 'a list ‑> 'a list listgroup_succ ~eq l groups together consecutive elements that are equal
+according to eq.
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 ‑> unitLike 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 ‑> 'bLike 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 optionGet 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 ‑> 'aGet the i-th element, or
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.
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.
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.
Those operations maintain the invariant that the list does not +contain duplicates (if it already satisfies it).
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 range_by : step:int ‑> int ‑> int ‑> int trange_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.
step=0.val range : int ‑> int ‑> int trange i j iterates on integers from i to j included. It works
+both for decreasing and increasing ranges.
val range' : int ‑> int ‑> int tLike range but the second bound is excluded.
+For instance range' 0 5 = [0;1;2;3;4].
module Assoc : sig ... endmodule Ref : sig ... endval random : 'a random_gen ‑> 'a t random_genval random_non_empty : 'a random_gen ‑> 'a t random_genval random_len : int ‑> 'a random_gen ‑> 'a t random_genval random_choose : 'a t ‑> 'a random_genRandomly choose an element in the list.
val random_sequence : 'a random_gen t ‑> 'a t random_gen+It is convenient to open CCList.Infix to access the infix operators +without cluttering the scope too much.
module Infix : sig ... endProvide useful functions and iterators on Map.S
module type S : sig ... endget_or k m ~default returns the value associated to k if present,
+and returns default otherwise (if k doesn't belong in m).
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.
Safe version of find_first.
val merge_safe : f:(key ‑> [ `Left of 'a | `Right of 'b | `Both of 'a * 'b ] ‑> 'c option) ‑> 'a t ‑> 'b t ‑> 'c tmerge_safe ~f a b merges the maps a and b together.
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.
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.
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.(/).
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.
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.
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.
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 ... endval to_int : t ‑> intConvert the given native integer (type nativeint) to an
+integer (type int). The high-order bit is lost
+during the conversion.
val of_int : int ‑> tAlias to Nativeint.of_int.
+Convert the given integer (type int) to a native integer (type nativeint).
val of_float : float ‑> tAlias 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 of_string_exn : string ‑> tAlias 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 optionSafe version of of_string_exn.
+Like of_string_exn, but return None instead of raising.
val map_or : default:'b ‑> ('a ‑> 'b) ‑> 'a t ‑> 'bmap_or ~default f o is f x if o = Some x, default otherwise.
val map_lazy : (unit ‑> 'b) ‑> ('a ‑> 'b) ‑> 'a t ‑> 'bmap_lazy default_fn f o if f o if o = Some x, default_fn () otherwise.
Compare two options, using custom comparators for the value.
+None is always assumed to be less than Some _.
val exists : ('a ‑> bool) ‑> 'a t ‑> boolReturn true iff there exists an element for which the provided function evaluates to true.
val for_all : ('a ‑> bool) ‑> 'a t ‑> boolReturn true iff the provided function evaluates to true for all elements.
val get_or : default:'a ‑> 'a t ‑> 'aget_or ~default o extracts the value from o, or
+returns default if o = None.
val get_exn : 'a t ‑> 'aOpen the option, possibly failing if it is None.
None.val get_lazy : (unit ‑> 'a) ‑> 'a t ‑> 'aget_lazy default_fn x unwraps x, but if x = None it returns default_fn () instead.
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 optionwrap 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.
true if the
+exception is to be caught.val wrap2 : ?handler:(exn ‑> bool) ‑> ('a ‑> 'b ‑> 'c) ‑> 'a ‑> 'b ‑> 'c optionwrap2 f x y is similar to wrap but for binary functions.
module Infix : sig ... endval to_list : 'a t ‑> 'a listval random : 'a random_gen ‑> 'a t random_genchoice_seq s is similar to choice, but works on sequences.
+It returns the first Some x occurring in s, or None otherwise.
val (<?>) : int ‑> ('a t * 'a * 'a) ‑> intc1 <?> (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 int : int tval string : string tval bool : bool tval float : float tval (<?>) : int ‑> ('a t * 'a * 'a) ‑> intc1 <?> (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
+ <?> (string, "a", "b")
+ <?> (bool, true, false))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.
module Infix : sig ... endval map : ('a ‑> 'c) ‑> ('b ‑> 'd) ‑> ('a * 'b) ‑> 'c * 'dSynonym to ( *** ). Map on both sides of a tuple.
val map_same : ('a ‑> 'b) ‑> ('a * 'a) ‑> 'b * 'bLike map but specialized for pairs with elements of the same type.
val (&&&) : ('a ‑> 'b) ‑> ('a ‑> 'c) ‑> 'a ‑> 'b * 'cf &&& g is fun x -> f x, g x. It splits the computations into
+two parts.
val dup_map : ('a ‑> 'b) ‑> 'a ‑> 'a * 'bdup_map f x = (x, f x). Duplicates the value and applies the function
+to the second copy.
Monadic bind.
+p >>= f results in a new parser which behaves as p then,
+in case of success, applies f to the result.
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".
list p parses a list of p, with the OCaml conventions for
+start token "", stop token "" and separator ";".
+Whitespace between items are skipped.
val triple : ?start:string ‑> ?stop:string ‑> ?sep:string ‑> 'a t ‑> 'b t ‑> 'c t ‑> ('a * 'b * 'c) tParse a triple using OCaml whitespace conventions. +The default is "(a, b, c)".
open CCParse;;
+
+ type tree = L of int | N of tree * tree;;
+
+ 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) )
+ ;;
+
+ parse_string_exn ptree "(1 (2 3))" ;;
+ parse_string_exn ptree "((1 2) (3 (4 5)))" ;;
+ open Containers.Parse;;
+ let p = U.list ~sep:"," U.word;;
+ parse_string_exn p "[abc , de, hello ,world ]";;+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' = CCParse.parse_string_exn p l_printed;;
+
+ assert (l=l');;val string_of_branch : parse_branch ‑> stringval state_of_string : string ‑> stateTakes the input and two continuations: +
ok to call with the result when it's doneerr to call when the parser met an errorMonadic bind.
+p >>= f results in a new parser which behaves as p then,
+in case of success, applies f to the result.
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".
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.
Those functions have a label ~p on the parser, since 0.14.
module Infix : sig ... endThis is useful to parse OCaml-like values in a simple way.
module U : sig ... endval return : 'a ‑> 'a treturn x is the generator that always returns x.
+Example: let random_int = return 4 (* fair dice roll *).
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)
+ )Like choose but without option.
val choose_return : 'a list ‑> 'a tChoose among the list.
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.
n <= 0.val pick_list : 'a list ‑> 'a tPick an element at random from the list.
val pick_array : 'a array ‑> 'a tPick an element at random from the array.
val float_range : float ‑> float ‑> float tInclusive range. float_range a b assumes a < b.
val split : int ‑> (int * int) option tSplit a positive value n into n1,n2 where n = n1 + n2.
None if the value is too small.val split_list : int ‑> len:int ‑> int list option tSplit 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.
len <= 1.None if the value is too small.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.
10.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.
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 tRecursion combinators, for building recursive values.
+The integer generator is used to provide fuel. The sub_ generators
+should use their arguments only once!
val pure : 'a ‑> 'a tval incr_then_get : int t ‑> intincr_then_get r increments r and returns its new value, think ++ r.
val get_then_incr : int t ‑> intget_then_incr r increments r and returns its old value, think r++.
val to_list : 'a t ‑> 'a lista <*> 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.
Uses the new "result" type from OCaml 4.03.
val of_exn_trace : exn ‑> ('a, string) tof_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 ‑> 'afail_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 ‑> 'afail_fprintf format uses format to obtain an error message
+and then returns Error msg.
add_ctx msg leaves Ok x untouched, but transforms
+Error s into Error s' where s' contains the additional
+context given by msg.
val add_ctxf : ('a, Format.formatter, unit, ('b, string) t ‑> ('b, string) t) Pervasives.format4 ‑> 'aadd_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)"Like map, but also with a function that can transform +the error message in case of failure.
val get_exn : ('a, _) t ‑> 'aExtract the value x from Ok x, fails otherwise.
+You should be careful with this function, and favor other combinators
+whenever possible.
val get_or : ('a, _) t ‑> default:'a ‑> 'aget_or e ~default returns x if e = Ok x, default otherwise.
val map_or : ('a ‑> 'b) ‑> ('a, 'c) t ‑> default:'b ‑> 'bmap_or f e ~default returns f x if e = Ok x, default otherwise.
val catch : ('a, 'err) t ‑> ok:('a ‑> 'b) ‑> err:('err ‑> 'b) ‑> 'bcatch e ~ok ~err calls either ok or err depending on
+the value of e.
val fold : ok:('a ‑> 'b) ‑> error:('err ‑> 'b) ‑> ('a, 'err) t ‑> 'bfold ~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 ‑> 'afold_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.
val guard : (unit ‑> 'a) ‑> ('a, exn) tguard 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_trace : (unit ‑> 'a) ‑> ('a, string) tLike guard_str but uses of_exn_trace instead of of_exn so +that the stack trace is printed.
val wrap2 : ('a ‑> 'b ‑> 'c) ‑> 'a ‑> 'b ‑> ('c, exn) tLike guard but gives the function two arguments.
val wrap3 : ('a ‑> 'b ‑> 'c ‑> 'd) ‑> 'a ‑> 'b ‑> 'c ‑> ('d, exn) tLike guard but gives the function three arguments.
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.
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.
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.
module Infix : sig ... endchoose l selects a member of l that is a Ok _ value,
+or returns Error l otherwise, where l is the list of errors.
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 S : sig ... endval compile : string ‑> [ `Direct ] patternval rcompile : string ‑> [ `Reverse ] patternval find : ?start:int ‑> pattern:[ `Direct ] pattern ‑> string ‑> intSearch for pattern in the string, left-to-right.
val rfind : ?start:int ‑> pattern:[ `Reverse ] pattern ‑> string ‑> intSearch for pattern in the string, right-to-left.
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.
val list_ : ?drop:drop_if_empty ‑> by:string ‑> string ‑> (string * int * int) listSplit the given string along the given separator by. Should only
+be used with very small separators, otherwise
+use Containers_string.KMP.
(s,index,length) that are
+separated by by. String.sub can then be used to actually extract
+a string from the slice.by = "".val gen : ?drop:drop_if_empty ‑> by:string ‑> string ‑> (string * int * int) genval seq : ?drop:drop_if_empty ‑> by:string ‑> string ‑> (string * int * int) sequenceval klist : ?drop:drop_if_empty ‑> by:string ‑> string ‑> (string * int * int) klistThose 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 listval gen_cpy : ?drop:drop_if_empty ‑> by:string ‑> string ‑> string genval seq_cpy : ?drop:drop_if_empty ‑> by:string ‑> string ‑> string sequenceval klist_cpy : ?drop:drop_if_empty ‑> by:string ‑> string ‑> string klistval left : by:string ‑> string ‑> (string * string) optionSplit on the first occurrence of by from the leftmost part of
+the string.
val left_exn : by:string ‑> string ‑> string * stringSplit on the first occurrence of by from the leftmost part of the string.
by is not part of the string.val right : by:string ‑> string ‑> (string * string) optionSplit on the first occurrence of by from the rightmost part of
+the string.
val right_exn : by:string ‑> string ‑> string * stringSplit on the first occurrence of by from the rightmost part of the string.
by is not part of the string.val make : string ‑> int ‑> len:int ‑> tval underlying : t ‑> stringval get : t ‑> int ‑> charget s i gets the i-th element, or fails.
0 ... length - 1.Consider using Containers_string.KMP for pattern search, or Regex +libraries.
module type S : sig ... endinclude module type of sig ... endval is_empty : string ‑> boolis_empty s returns true iff s is empty (i.e. its length is 0).
val pad : ?side:[ `Left | `Right ] ‑> ?c:char ‑> int ‑> string ‑> stringpad 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.
`Left).val find : ?start:int ‑> sub:string ‑> string ‑> intFind sub in string, returns its first index or -1.
val find_all : ?start:int ‑> sub:string ‑> string ‑> int genfind_all ~sub s finds all occurrences of sub in s, even overlapping
+instances.
s.val find_all_l : ?start:int ‑> sub:string ‑> string ‑> int listfind_all_l ~sub s finds all occurrences of sub in s and returns
+them in a list.
s.val mem : ?start:int ‑> sub:string ‑> string ‑> boolmem ~sub s is true iff sub is a substring of s.
val rfind : sub:string ‑> string ‑> intFind sub in string from the right, returns its first index or -1.
+Should only be used with very small sub.
val replace : ?which:[ `Left | `Right | `All ] ‑> sub:string ‑> by:string ‑> string ‑> stringreplace ~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)sub = "".val is_sub : sub:string ‑> int ‑> string ‑> int ‑> len:int ‑> boolis_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 suffix : suf:string ‑> string ‑> boolsuffix ~suf s returns true iff suf is a suffix of s.
val chop_prefix : pre:string ‑> string ‑> string optionchop_prefix ~pre s removes pre from s if pre really is a prefix
+of s, returns None otherwise.
val chop_suffix : suf:string ‑> string ‑> string optionchop_suffix ~suf s removes suf from s if suf really is a suffix
+of s, returns None otherwise.
val lines : string ‑> string listlines s returns a list of the lines of s (splits along '\n').
val lines_gen : string ‑> string genlines_gen s returns a generator of the lines of s (splits along '\n').
val concat_gen : sep:string ‑> string gen ‑> stringconcat_gen ~sep g concatenates all strings of g, separated with sep.
val unlines : string list ‑> stringunlines l concatenates all strings of l, separated with '\n'.
val unlines_gen : string gen ‑> stringunlines_gen g concatenates all strings of g, separated with '\n'.
val set : string ‑> int ‑> char ‑> stringset s i c creates a new string which is a copy of s, except
+for index i, which becomes c.
i is an invalid index.val filter_map : (char ‑> char option) ‑> string ‑> stringfilter_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).
val filter : (char ‑> bool) ‑> string ‑> stringfilter f s discards characters not satisfying f.
val flat_map : ?sep:string ‑> (char ‑> string) ‑> string ‑> stringMap each chars to a string, then concatenates them all.
val map2 : (char ‑> char ‑> char) ‑> string ‑> string ‑> stringMap pairs of chars.
val iter2 : (char ‑> char ‑> unit) ‑> string ‑> string ‑> unitIterate on pairs of chars.
val iteri2 : (int ‑> char ‑> char ‑> unit) ‑> string ‑> string ‑> unitIterate on pairs of chars with their index.
val fold2 : ('a ‑> char ‑> char ‑> 'a) ‑> 'a ‑> string ‑> string ‑> 'aFold on pairs of chars.
val for_all2 : (char ‑> char ‑> bool) ‑> string ‑> string ‑> boolAll pairs of chars respect the predicate?
val exists2 : (char ‑> char ‑> bool) ‑> string ‑> string ‑> boolExists a pair of chars?
Those functions are deprecated in String since 4.03, so we provide +a stable alias for them even in older versions.
val equal_caseless : string ‑> string ‑> boolComparison without respect to ascii lowercase.
A relatively efficient algorithm for finding sub-strings.
module Find : sig ... endmodule Split : sig ... endval compare_versions : string ‑> string ‑> intcompare_versions a b compares version stringsa and b,
+considering that numbers are above text.
val compare_natural : string ‑> string ‑> intNatural Sort Order, comparing chunks of digits as natural numbers. +https://en.wikipedia.org/wiki/Natural_sort_order
val edit_distance : string ‑> string ‑> intEdition 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.
A contiguous part of a string
module Sub : sig ... endval blit : t ‑> int ‑> Bytes.t ‑> int ‑> int ‑> unitLike String.blit.
+Compatible with the -safe-string option.
val hash : t ‑> intval pp : Format.formatter ‑> t ‑> unitval of_string_exn : string ‑> tValidate string by checking it is valid UTF8.
val unsafe_of_string : string ‑> tConversion from a string without validating. +Upon iteration, if an invalid substring is met, Malformed will be raised.
Mutability is rw (read-write) or ro (read-only).
Create a new vector, using the given value as a filler.
Hint to the vector that it should have at least the given capacity.
capacity v = 0, used as a filler
+element for the underlying array (see create_with).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.
Shrink to the given size (remove elements above this size). +Does nothing if the parameter is bigger than the current size.
Sort the vector, returning a copy of it that is sorted +w.r.t the given ordering. The vector itself is unchanged.
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 exists : ('a ‑> bool) ‑> ('a, _) t ‑> boolExistential test (is there an element that satisfies the predicate?).
val for_all : ('a ‑> bool) ‑> ('a, _) t ‑> boolUniversal test (do all the elements satisfy the predicate?).
val find_exn : ('a ‑> bool) ‑> ('a, _) t ‑> 'aFind an element that satisfies the predicate, or
val find_map : ('a ‑> 'b option) ‑> ('a, _) t ‑> 'b optionfind_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.
Like flat_map, but using list for +intermediate collections.
val get : ('a, _) t ‑> int ‑> 'aAccess element by its index, or
Remove the n-th element of the vector. Does NOT preserve the order
+of the elements (might swap with the last element).
val rev_iter : ('a ‑> unit) ‑> ('a, _) t ‑> unitrev_iter f a is the same as iter f (rev a), only more efficient.
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) tRange 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) tRange of integers, either ascending or descending, but excluding right.
+Example: 1 --^ 10 returns the vector [1;2;3;4;5;6;7;8;9].
val of_array : 'a array ‑> ('a, 'mut) tof_array a returns a vector corresponding to the array a. Operates in O(n) time.
val of_list : 'a list ‑> ('a, 'mut) tto_seq_rev v returns the sequence of elements of v in reverse order,
+that is, the last elements of v are iterated on first.
val create : int ‑> 'a tval clear : 'a t ‑> unitval reset : 'a t ‑> unitval length : 'a t ‑> intval stats : 'a t ‑> Hashtbl.statisticsval hash : int ‑> t ‑> intval create : ?random:bool ‑> int ‑> 'a tval clear : 'a t ‑> unitval reset : 'a t ‑> unitval length : 'a t ‑> intval stats : 'a t ‑> statisticsinclude 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.tval create : ?random:bool ‑> int ‑> ('a, 'b) tval clear : ('a, 'b) t ‑> unitval reset : ('a, 'b) t ‑> unitval add : ('a, 'b) t ‑> 'a ‑> 'b ‑> unitval find : ('a, 'b) t ‑> 'a ‑> 'bval find_opt : ('a, 'b) t ‑> 'a ‑> 'b optionval find_all : ('a, 'b) t ‑> 'a ‑> 'b listval mem : ('a, 'b) t ‑> 'a ‑> boolval remove : ('a, 'b) t ‑> 'a ‑> unitval replace : ('a, 'b) t ‑> 'a ‑> 'b ‑> unitval iter : ('a ‑> 'b ‑> unit) ‑> ('a, 'b) t ‑> unitval filter_map_inplace : ('a ‑> 'b ‑> 'b option) ‑> ('a, 'b) t ‑> unitval fold : ('a ‑> 'b ‑> 'c ‑> 'c) ‑> ('a, 'b) t ‑> 'c ‑> 'cval length : ('a, 'b) t ‑> intval stats : ('a, 'b) t ‑> statisticsmodule type HashedType : sig ... endmodule type S : sig ... endmodule type SeededHashedType : sig ... endmodule type SeededS : sig ... endmodule MakeSeeded : functor (H : SeededHashedType) -> sig ... endinclude CCHashtbl.Polyval get_or : ('a, 'b) Hashtbl.t ‑> 'a ‑> default:'b ‑> 'bget_or tbl k ~default returns the value associated to k if present,
+and returns default otherwise (if k doesn't belong in tbl).
val keys : ('a, 'b) Hashtbl.t ‑> 'a CCHashtbl.sequenceIterate on keys (similar order as Hashtbl.iter).
val keys_list : ('a, 'b) Hashtbl.t ‑> 'a listkeys_list t is the list of keys in t.
+If the key is in the Hashtable multiple times, all occurrences will be returned.
val map_list : ('a ‑> 'b ‑> 'c) ‑> ('a, 'b) Hashtbl.t ‑> 'c listMap on a hashtable's items, collect into a list.
val incr : ?by:int ‑> ('a, int) Hashtbl.t ‑> 'a ‑> unitincr ?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).
by rather than 1.val decr : ?by:int ‑> ('a, int) Hashtbl.t ‑> 'a ‑> unitLike 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.
val add_list : ('a, 'b list) Hashtbl.t ‑> 'a ‑> 'b ‑> unitadd_list tbl x y adds y to the list x is bound to. If x is
+not bound, it becomes bound to y.
val add_seq : ('a, 'b) Hashtbl.t ‑> ('a * 'b) CCHashtbl.sequence ‑> unitAdd the corresponding pairs to the table, using Hashtbl.add.
val of_seq : ('a * 'b) CCHashtbl.sequence ‑> ('a, 'b) Hashtbl.tFrom the given bindings, added in order.
val add_seq_count : ('a, int) Hashtbl.t ‑> 'a CCHashtbl.sequence ‑> unitadd_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.
val of_seq_count : 'a CCHashtbl.sequence ‑> ('a, int) Hashtbl.tLike add_seq_count, but allocates a new table and returns it.
val of_list : ('a * 'b) list ‑> ('a, 'b) Hashtbl.tBuild 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 ‑> unitupdate 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.
val get_or_add : ('a, 'b) Hashtbl.t ‑> f:('a ‑> 'b) ‑> k:'a ‑> 'bget_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.
val pp : 'a CCHashtbl.printer ‑> 'b CCHashtbl.printer ‑> ('a, 'b) Hashtbl.t CCHashtbl.printermodule type S' = CCHashtbl.Smodule Make' = CCHashtbl.Makeval hash : t ‑> intget_or tbl k ~default returns the value associated to k if present,
+and returns default otherwise (if k doesn't belong in tbl).
add_list tbl x y adds y to the list x is bound to. If x is
+not bound, it becomes bound to y.
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).
by rather than 1.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.
keys_list t is the list of keys in t.
+If the key is in the Hashtable multiple times, all occurrences will be returned.
val add_seq : 'a t ‑> (key * 'a) CCHashtbl.sequence ‑> unitAdd the corresponding pairs to the table, using Hashtbl.add.
val add_seq_count : int t ‑> key CCHashtbl.sequence ‑> unitadd_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.
val of_seq_count : key CCHashtbl.sequence ‑> int tLike add_seq_count, but allocates a new table and returns it.
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.
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.
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.
val pp : key CCHashtbl.printer ‑> 'a CCHashtbl.printer ‑> 'a t CCHashtbl.printerval create : int ‑> 'a tval clear : 'a t ‑> unitval reset : 'a t ‑> unitval length : 'a t ‑> intval stats : 'a t ‑> statisticsval hash : int ‑> t ‑> intval create : ?random:bool ‑> int ‑> 'a tval clear : 'a t ‑> unitval reset : 'a t ‑> unitval length : 'a t ‑> intval stats : 'a t ‑> statisticsmodule Array = CCArraymodule ArrayLabels = CCArrayLabelsmodule Array_slice = CCArray_slicemodule Bool = CCBoolmodule Equal = CCEqualmodule Float = CCFloatmodule Format = CCFormatmodule Fun = CCFunmodule Hash = CCHashmodule Hashtbl : sig ... endmodule Heap = CCHeapmodule Int = CCIntmodule Int32 = CCInt32module Int64 = CCInt64module IO = CCIOmodule List = CCListmodule ListLabels = CCListLabelsmodule Map = CCMapmodule Nativeint = CCNativeintmodule Option = CCOptmodule Ord = CCOrdmodule Pair = CCPairmodule Parse = CCParsemodule Random = CCRandommodule Ref = CCRefmodule Result = CCResultmodule Set = CCSetmodule String = CCStringmodule Vector = CCVectormodule Utf8_string = CCUtf8_stringinclude Monomorphic+This library exposes the following toplevel modules:
.
\ No newline at end of file diff --git a/2.1/containers/page-index.odoc b/2.1/containers/page-index.odoc new file mode 100644 index 00000000..9b8426d2 Binary files /dev/null and b/2.1/containers/page-index.odoc differ diff --git a/2.1/index.html b/2.1/index.html new file mode 100644 index 00000000..86e83d8a --- /dev/null +++ b/2.1/index.html @@ -0,0 +1,23 @@ + + + +BREAKING CHANGES since 1.2: +size is now stored along with the bitvector. Some functions have +a new signature.
The size of the bitvector used to be rounded up to the multiple of 30 or 62. +In other words some functions such as iter would iterate on more +bits than what was originally asked for. This is not the case anymore.
val length : t ‑> intSize of underlying bitvector. +This is not related to the underlying implementation. +Changed at 1.2
val resize : t ‑> int ‑> unitResize the BV so that it has the specified length. This can grow or shrink +the underlying bitvector.
val to_sorted_list : t ‑> int listSame as to_list, but also guarantees the list is sorted in +increasing order.
val of_list : int list ‑> tFrom a list of true bits.
The bits are interpreted as indices into the returned bitvector, so the final
+bitvector will have length t equal to 1 more than max of list indices.
val filter : t ‑> (int ‑> bool) ‑> unitfilter bv p only keeps the true bits of bv whose index
+satisfies p index.
union_into ~into bv sets into to the union of itself and bv.
+Also updates the length of into to be at least length bv.
inter_into ~into bv sets into to the intersection of itself and bv.
+Also updates the length of into to be at most length bv.
val select : t ‑> 'a array ‑> 'a listselect arr bv selects the elements of arr whose index
+corresponds to a true bit in bv. If bv is too short, elements of arr
+with too high an index cannot be selected and are therefore not
+selected.
val selecti : t ‑> 'a array ‑> ('a * int) listSame as select, but selected elements are paired with their indexes.
R : OrderedTypeL : OrderedTypeval empty : tval is_empty : t ‑> boolAdd left and right correspondence to bijection such that
+left and right are unique in their respective sets and only
+correspond to each other.
+Represents 1-to-1 mappings between two types. Each element from the "left" +is mapped to one "right" value, and conversely.
module type OrderedType : sig ... endmodule type S : sig ... endmodule Make : functor (L : OrderedType) -> functor (R : OrderedType) -> S with type left = L.t and type right = R.tval empty : tval is_empty : t ‑> boolAdd left and right correspondence to bijection such that
+left and right are unique in their respective sets and only
+correspond to each other.
Create a new bitfield type
X : sig ... endtype t = private intGenerative type of bitfields. Each instantiation of the functor +should create a new, incompatible type
val freeze : unit ‑> unitPrevent new fields from being added. From now on, creating +a field will raise Frozen.
This module defines efficient bitfields +up to 30 or 62 bits (depending on the architecture) in +a relatively type-safe way.
module B = CCBitField.Make(struct end);;
+
+ let x = B.mk_field ()
+ let y = B.mk_field ()
+ let z = B.mk_field ()
+
+ let f = B.empty |> B.set x true |> B.set y true;;
+
+ assert (not (B.get z f)) ;;
+
+ assert (f |> B.set z true |> B.get z);;
+
\ No newline at end of file
diff --git a/dev/containers.data/CCBitField/module-type-S/index.html b/dev/containers.data/CCBitField/module-type-S/index.html
new file mode 100644
index 00000000..b9fe76af
--- /dev/null
+++ b/dev/containers.data/CCBitField/module-type-S/index.html
@@ -0,0 +1,4 @@
+
+type t = private intGenerative type of bitfields. Each instantiation of the functor +should create a new, incompatible type
val freeze : unit ‑> unitPrevent new fields from being added. From now on, creating +a field will raise Frozen.
Particularly useful for memoization. See with_cache and with_cache_rec +for more details.
Typical use case: one wants to memoize a function f : 'a -> 'b. Code sample:
+
let f x =
+ print_endline "call f";
+ x + 1;;
+
+ let f' = with_cache (lru 256) f;;
+ f' 0;; (* prints *)
+ f' 1;; (* prints *)
+ f' 0;; (* doesn't print, returns cached value *)type ('a, 'b) callback = in_cache:bool ‑> 'a ‑> 'b ‑> unitType of the callback that is called once a cached value is found +or not. +Should never raise.
true if the value was in cache, false
+if the value was just produced.with_cache c f behaves like f, but caches calls to f in the
+cache c. It always returns the same value as
+f x, if f x returns, or raise the same exception.
+However, f may not be called if x is in the cache.
with_cache_rec c f is a function that first, applies f to
+some f' = fix f, such that recursive calls to f' are cached in c.
+It is similar to with_cache but with a function that takes as
+first argument its own recursive version.
+Example (memoized Fibonacci function):
+
let fib = with_cache_rec (lru 256)
+ (fun fib' n -> match n with
+ | 1 | 2 -> 1
+ | _ -> fib' (n-1) + fib' (n-2)
+ );;
+
+ fib 70;;val size : (_, _) t ‑> intSize of the cache (number of entries). At most linear in the number +of entries.
val iter : ('a, 'b) t ‑> ('a ‑> 'b ‑> unit) ‑> unitIterate on cached values. Should yield size cache pairs.
val add : ('a, 'b) t ‑> 'a ‑> 'b ‑> boolManually add a cached value. Return true if the value has successfully
+been added, and false if the value was already bound.
Linear cache with the given size. It stores key/value pairs in +an array and does linear search at every call, so it should only be used +with small size.
Replacing cache of the given size. Equality and hash functions can be +parametrized. It's a hash table that handles collisions by replacing +the old value with the new (so a cache entry is evicted when another +entry with the same hash (modulo size) is added). +Never grows wider than the given size.
LRU cache of the given size ("Least Recently Used": keys that have not been +used recently are deleted first). Never grows wider than the given size.
Unbounded cache, backed by a Hash table. Will grow forever +unless clear is called manually.
This structure provides fast access to its front and back elements, +with O(1) operations.
equal a b checks whether a and b contain the same sequence of
+elements.
compare a b compares lexicographically a and b
Create a deque from the sequence.
+Optional argument deque disappears, use add_seq_back instead since
+0.13
add_seq_front q seq adds elements of seq into the front of q,
+in reverse order.
+O(n) in time, where n is the number of elements to add.
add_seq_back q seq adds elements of seq into the back of q,
+in order.
+O(n) in time, where n is the number of elements to add.
val to_list : 'a t ‑> 'a listList of elements, in order. Less efficient than to_rev_list.
val empty : 'a tval is_empty : 'a t ‑> boolval singleton : 'a ‑> 'a tval doubleton : 'a ‑> 'a ‑> 'a tSame as take_front, but fails on empty queues.
take_front_l n q takes at most n elements from the front
+of q, and returns them wrapped in a list.
Same as take_back, but fails on empty queues.
take_back_l n q removes and returns the last n elements of q. The
+elements are in the order of the queue, that is, the head of the returned
+list is the first element to appear via take_front.
+take_back_l 2 (of_list [1;2;3;4]) = of_list [1;2], [3;4].
val last_exn : 'a t ‑> 'aAppend two queues. Elements from the second one come +after elements of the first one. +Linear in the size of the second queue.
val fold : ('b ‑> 'a ‑> 'b) ‑> 'b ‑> 'a t ‑> 'bval iter : ('a ‑> unit) ‑> 'a t ‑> unitval of_list : 'a list ‑> 'a tval to_list : 'a t ‑> 'a listval (--^) : int ‑> int ‑> int ta -- b is the integer range from a to b, where b is excluded.
Tree with a large branching factor for logarithmic operations with +a low multiplicative factor.
status: experimental. DO NOT USE (yet)
val empty : 'a tval is_empty : _ t ‑> boolval return : 'a ‑> 'a tval length : _ t ‑> intval get : int ‑> 'a t ‑> 'a optionval iter : f:('a ‑> unit) ‑> 'a t ‑> unitval iteri : f:(int ‑> 'a ‑> unit) ‑> 'a t ‑> unitIterate on elements with their index, in increasing order.
val iteri_rev : f:(int ‑> 'a ‑> unit) ‑> 'a t ‑> unitIterate on elements with their index, but starting from the end.
val fold : f:('b ‑> 'a ‑> 'b) ‑> x:'b ‑> 'a t ‑> 'bval foldi : f:('b ‑> int ‑> 'a ‑> 'b) ‑> x:'b ‑> 'a t ‑> 'bval choose : 'a t ‑> 'a optionval to_list : 'a t ‑> 'a listval of_list : 'a list ‑> 'a ttype attribute = [ | `Color of string |
| `Shape of string |
| `Weight of int |
| `Style of string |
| `Label of string |
| `Other of string * string |
]Dot attribute
val pp : tbl:('v, vertex_state) table ‑> eq:('v ‑> 'v ‑> bool) ‑> ?attrs_v:('v ‑> attribute list) ‑> ?attrs_e:('e ‑> attribute list) ‑> ?name:string ‑> graph:('v, 'e) t ‑> Format.formatter ‑> 'v ‑> unitPrint the graph, starting from given vertex, on the formatter.
val fold_v : ('acc ‑> 'v ‑> 'acc) ‑> 'acc ‑> ('v, _) t ‑> 'accval empty : 'a tRemove the vertex and all its outgoing edges. +Edges that point to the vertex are NOT removed, they must be +manually removed with remove_edge.
val return : 'a ‑> 'a sequenceval iter : ('a ‑> unit) ‑> 'a t ‑> unitval fold : ('b ‑> 'a ‑> 'b) ‑> 'b ‑> 'a t ‑> 'bval to_list : 'a t ‑> 'a listtype ('v, 'e) t = [ | `Enter of 'v * int * ('v, 'e) path |
| `Exit of 'v |
| `Edge of 'v * 'e * 'v * edge_kind |
]A traversal is a sequence of such events
val get_vertex : ('v, 'e) t ‑> ('v * [ `Enter | `Exit ]) optionval get_enter : ('v, 'e) t ‑> 'v optionval get_exit : ('v, 'e) t ‑> 'v optionval get_edge : ('v, 'e) t ‑> ('v * 'e * 'v) optionval dfs : tbl:'v set ‑> eq:('v ‑> 'v ‑> bool) ‑> graph:('v, 'e) graph ‑> 'v sequence ‑> ('v, 'e) t sequence_onceFull version of DFS.
val dfs_tag : eq:('v ‑> 'v ‑> bool) ‑> tags:'v tag_set ‑> graph:('v, 'e) graph ‑> 'v sequence ‑> ('v, 'e) t sequence_onceFull version of DFS using integer tags.
val generic : tbl:'v set ‑> bag:'v bag ‑> graph:('v, 'e) t ‑> 'v sequence ‑> 'v sequence_onceTraversal of the given graph, starting from a sequence +of vertices, using the given bag to choose the next vertex to +explore. Each vertex is visited at most once.
val generic_tag : tags:'v tag_set ‑> bag:'v bag ‑> graph:('v, 'e) t ‑> 'v sequence ‑> 'v sequence_onceOne-shot traversal of the graph using a tag set and the given bag.
val dfs : tbl:'v set ‑> graph:('v, 'e) t ‑> 'v sequence ‑> 'v sequence_onceval dfs_tag : tags:'v tag_set ‑> graph:('v, 'e) t ‑> 'v sequence ‑> 'v sequence_onceval bfs : tbl:'v set ‑> graph:('v, 'e) t ‑> 'v sequence ‑> 'v sequence_onceval bfs_tag : tags:'v tag_set ‑> graph:('v, 'e) t ‑> 'v sequence ‑> 'v sequence_onceval dijkstra : tbl:'v set ‑> ?dist:('e ‑> int) ‑> graph:('v, 'e) t ‑> 'v sequence ‑> ('v * int * ('v, 'e) path) sequence_onceDijkstra algorithm, traverses a graph in increasing distance order. +Yields each vertex paired with its distance to the set of initial vertices +(the smallest distance needed to reach the node from the initial vertices).
val dijkstra_tag : ?dist:('e ‑> int) ‑> tags:'v tag_set ‑> graph:('v, 'e) t ‑> 'v sequence ‑> ('v * int * ('v, 'e) path) sequence_onceA collections of algorithms on (mostly read-only) graph structures.
+The user provides her own graph structure as a ('v, 'e) CCGraph.t,
+where 'v is the type of vertices and 'e the type of edges
+(for instance, 'e = ('v * 'v) is perfectly fine in many cases).
Such a ('v, 'e) CCGraph.t structure is a record containing
+three functions: two relate edges to their origin and destination,
+and one maps vertices to their outgoing edges.
+This abstract notion of graph makes it possible to run the algorithms
+on any user-specific type that happens to have a graph structure.
Many graph algorithms here take a sequence of vertices as input.
+If the user only has a single vertex (e.g., for a topological sort
+from a given vertex), she can use Seq.return x to build a sequence
+of one element.
status: unstable
module Seq : sig ... endThis interface is designed for oriented graphs with labels on edges
type ('k, 'a) table = {mem : 'k ‑> bool; | |
find : 'k ‑> 'a; | (**
*) |
add : 'k ‑> 'a ‑> unit; | (** Erases previous binding *) |
}Mutable table with keys 'k and values 'a
val mk_table : eq:('k ‑> 'k ‑> bool) ‑> ?hash:('k ‑> int) ‑> int ‑> ('k, 'a) tableDefault implementation for table: a Hashtbl.t.
type 'a bag = {push : 'a ‑> unit; | |
is_empty : unit ‑> bool; | |
pop : unit ‑> 'a; | (** raises some exception is empty *) |
}Bag of elements of type 'a
val mk_queue : unit ‑> 'a bagval mk_stack : unit ‑> 'a bagval mk_heap : leq:('a ‑> 'a ‑> bool) ‑> 'a bagmk_heap ~leq makes a priority queue where leq x y = true means that
+x is smaller than y and should be prioritary.
module Traverse : sig ... endval topo_sort : eq:('v ‑> 'v ‑> bool) ‑> ?rev:bool ‑> tbl:'v set ‑> graph:('v, 'e) t ‑> 'v sequence ‑> 'v listtopo_sort ~graph seq returns a list of vertices l where each
+element of l is reachable from seq.
+The list is sorted in a way such that if v -> v' in the graph, then
+v comes before v' in the list (i.e. has a smaller index).
+Basically v -> v' means that v is smaller than v'.
+See wikipedia.
(=)).v -> v' means
+v' occurs before v).val topo_sort_tag : eq:('v ‑> 'v ‑> bool) ‑> ?rev:bool ‑> tags:'v tag_set ‑> graph:('v, 'e) t ‑> 'v sequence ‑> 'v listSame as topo_sort but uses an explicit tag set.
module Lazy_tree : sig ... endval spanning_tree : tbl:'v set ‑> graph:('v, 'e) t ‑> 'v ‑> ('v, 'e) Lazy_tree.tspanning_tree ~graph v computes a lazy spanning tree that has v
+as a root. The table tbl is used for the memoization part.
val spanning_tree_tag : tags:'v tag_set ‑> graph:('v, 'e) t ‑> 'v ‑> ('v, 'e) Lazy_tree.tval scc : tbl:('v, 'v scc_state) table ‑> graph:('v, 'e) t ‑> 'v sequence ‑> 'v list sequence_onceStrongly connected components reachable from the given vertices. +Each component is a list of vertices that are all mutually reachable +in the graph. +The components are explored in a topological order (if C1 and C2 are +components, and C1 points to C2, then C2 will be yielded before C1). +Uses Tarjan's algorithm.
Example (print divisors from 42):
let open CCGraph in
+ let open Dot in
+ with_out "/tmp/truc.dot"
+ (fun out ->
+ pp ~attrs_v:(fun i -> [`Label (string_of_int i)]) ~graph:divisors_graph out 42
+ )module Dot : sig ... endtype ('v, 'e) mut_graph = {graph : ('v, 'e) t; |
add_edge : 'v ‑> 'e ‑> 'v ‑> unit; |
remove : 'v ‑> unit; |
}val mk_mut_tbl : eq:('v ‑> 'v ‑> bool) ‑> ?hash:('v ‑> int) ‑> int ‑> ('v, 'a) mut_graphMake a new mutable graph from a Hashtbl. Edges are labelled with type 'a.
A classic implementation of a graph structure on totally ordered vertices, +with unlabelled edges. The graph allows to add and remove edges and vertices, +and to iterate on edges and vertices.
module type MAP : sig ... endval of_list : eq:('v ‑> 'v ‑> bool) ‑> ('v * 'v) list ‑> ('v, unit) tof_list l makes a graph from a list of pairs of vertices.
+Each pair (a,b) is an edge from a to b.
val of_hashtbl : ('v, 'v list) Hashtbl.t ‑> ('v, unit) tof_hashtbl tbl makes a graph from a hashtable that maps vertices
+to lists of children.
val of_fun : ('v ‑> 'v list) ‑> ('v, unit) tof_fun f makes a graph out of a function that maps a vertex to
+the list of its children. The function is assumed to be deterministic.
val empty : 'a tRemove the vertex and all its outgoing edges. +Edges that point to the vertex are NOT removed, they must be +manually removed with remove_edge.
status: unstable
module type S : sig ... endmodule type ELEMENT : sig ... endval hash : t ‑> intval empty : 'a tval is_empty : _ t ‑> boolupdate k ~f m calls f (Some v) if get k m = Some v, f None
+otherwise. Then, if f returns Some v' it binds k to v',
+if f returns None it removes k.
val add_mut : id:Transient.t ‑> key ‑> 'a ‑> 'a t ‑> 'a tadd_mut ~id k v m behaves like add k v m, except it will mutate
+in place whenever possible. Changes done with an id might affect all
+versions of the structure obtained with the same id (but not
+other versions).
id is frozen.val remove_mut : id:Transient.t ‑> key ‑> 'a t ‑> 'a tSame as remove, but modifies in place whenever possible.
id is frozen.val update_mut : id:Transient.t ‑> key ‑> f:('a option ‑> 'a option) ‑> 'a t ‑> 'a tSame as update but with mutability.
id is frozen.val cardinal : _ t ‑> intval add_list_mut : id:Transient.t ‑> 'a t ‑> (key * 'a) list ‑> 'a tval add_seq_mut : id:Transient.t ‑> 'a t ‑> (key * 'a) sequence ‑> 'a tval add_gen_mut : id:Transient.t ‑> 'a t ‑> (key * 'a) gen ‑> 'a tFor debugging purpose: explore the structure of the tree,
+with `L (h,l) being a leaf (with shared hash h)
+and `N an inner node.
type tIdentifiers for transient modifications. A transient modification
+is uniquely identified by a Transient.t. Once Transient.freeze r
+is called, r cannot be used to modify the structure again.
val frozen : t ‑> boolfrozen i returns true if freeze i was called before. In this case,
+the ID cannot be used for modifications again.
val freeze : t ‑> unitfreeze i makes i unusable for new modifications. The values
+created with i will now be immutable.
val with_ : (t ‑> 'a) ‑> 'awith_ f creates a transient ID i, calls f i,
+freezes the ID i and returns the result of f i.
Trie indexed by the hash of the keys, where the branching factor is fixed. +The goal is to have a quite efficient functional structure with fast +update and access if the hash function is good. +The trie is not binary, to improve cache locality and decrease depth.
Preliminary benchmarks (see the "tbl" section of benchmarks) tend to show +that this type is quite efficient for small data sets.
status: unstable
val hash : t ‑> intval empty : 'a tval is_empty : _ t ‑> boolupdate k ~f m calls f (Some v) if get k m = Some v, f None
+otherwise. Then, if f returns Some v' it binds k to v',
+if f returns None it removes k.
val add_mut : id:Transient.t ‑> key ‑> 'a ‑> 'a t ‑> 'a tadd_mut ~id k v m behaves like add k v m, except it will mutate
+in place whenever possible. Changes done with an id might affect all
+versions of the structure obtained with the same id (but not
+other versions).
id is frozen.val remove_mut : id:Transient.t ‑> key ‑> 'a t ‑> 'a tSame as remove, but modifies in place whenever possible.
id is frozen.val update_mut : id:Transient.t ‑> key ‑> f:('a option ‑> 'a option) ‑> 'a t ‑> 'a tSame as update but with mutability.
id is frozen.val cardinal : _ t ‑> intval add_list_mut : id:Transient.t ‑> 'a t ‑> (key * 'a) list ‑> 'a tval add_seq_mut : id:Transient.t ‑> 'a t ‑> (key * 'a) sequence ‑> 'a tval add_gen_mut : id:Transient.t ‑> 'a t ‑> (key * 'a) gen ‑> 'a tFor debugging purpose: explore the structure of the tree,
+with `L (h,l) being a leaf (with shared hash h)
+and `N an inner node.
val create : unit ‑> 'a tval empty : tval length : t ‑> intval cardinal : t ‑> intval create : ?size:int ‑> unit ‑> tval length : t ‑> intThis is similar to CCMixtbl, but the injection is directly used as +a key.
module Key : sig ... endPurely functional use of arrays. Update is costly, but reads are very fast. +Sadly, it is not possible to make this type covariant without using black +magic.
type 'a tArray of values of type 'a. The underlying type really is +an array, but it will never be modified.
It should be covariant but OCaml will not accept it.
val empty : 'a tval length : _ t ‑> intval singleton : 'a ‑> 'a tval doubleton : 'a ‑> 'a ‑> 'a tval init : int ‑> (int ‑> 'a) ‑> 'a tinit n f makes the array [| f 0; f 1; ... ; f (n-1) |].
n < 0.sub a start len returns a fresh array of length len, containing the elements
+from start to pstart + len - 1 of array a.
Raises Invalid_argument "Array.sub" if start and len do not designate a
+valid subarray of a; that is, if start < 0, or len < 0, or start + len > Array.length a.
val iter : ('a ‑> unit) ‑> 'a t ‑> unitval iteri : (int ‑> 'a ‑> unit) ‑> 'a t ‑> unitval foldi : ('a ‑> int ‑> 'b ‑> 'a) ‑> 'a ‑> 'b t ‑> 'aval fold : ('a ‑> 'b ‑> 'a) ‑> 'a ‑> 'b t ‑> 'aval for_all : ('a ‑> bool) ‑> 'a t ‑> boolval exists : ('a ‑> bool) ‑> 'a t ‑> boolval of_list : 'a list ‑> 'a tval to_list : 'a t ‑> 'a listval of_array_unsafe : 'a array ‑> 'a tTake ownership of the given array. Careful, the array must NOT +be modified afterwards!
status: stable
val empty : 'a tval singleton : int ‑> 'a ‑> 'a tval doubleton : int ‑> 'a ‑> int ‑> 'a ‑> 'a tval mem : int ‑> _ t ‑> boolval find : int ‑> 'a t ‑> 'a optionequal ~eq a b checks whether a and b have the same set of pairs
+(key, value), comparing values with eq.
val iter : (int ‑> 'a ‑> unit) ‑> 'a t ‑> unitval fold : (int ‑> 'a ‑> 'b ‑> 'b) ‑> 'a t ‑> 'b ‑> 'bval choose : 'a t ‑> (int * 'a) optionval of_list : (int * 'a) list ‑> 'a tval to_list : 'a t ‑> (int * 'a) listHelpers
\ No newline at end of file diff --git a/dev/containers.data/CCMixmap.odoc b/dev/containers.data/CCMixmap.odoc new file mode 100644 index 00000000..fc627234 Binary files /dev/null and b/dev/containers.data/CCMixmap.odoc differ diff --git a/dev/containers.data/CCMixmap/.jbuilder-keep b/dev/containers.data/CCMixmap/.jbuilder-keep new file mode 100644 index 00000000..e69de29b diff --git a/dev/containers.data/CCMixmap/Make/argument-1-X/index.html b/dev/containers.data/CCMixmap/Make/argument-1-X/index.html new file mode 100644 index 00000000..7c387271 --- /dev/null +++ b/dev/containers.data/CCMixmap/Make/argument-1-X/index.html @@ -0,0 +1,2 @@ + +Find the value for the given key, which must be of the right type.
status: experimental
module M = CCMixmap.Make(CCInt)
+
+ let inj_int = CCMixmap.create_inj()
+ let inj_str = CCMixmap.create_inj()
+ let inj_list_int = CCMixmap.create_inj()
+
+ let m =
+ M.empty
+ |> M.add ~inj:inj_int 1 1
+ |> M.add ~inj:inj_str 2 "2"
+ |> M.add ~inj:inj_list_int 3 [3;3;3]
+
+ assert (M.get ~inj:inj_int 1 m = Some 1)
+ assert (M.get ~inj:inj_str 1 m = None)
+ assert (M.get ~inj:inj_str 2 m = Some "2")
+ assert (M.get ~inj:inj_int 2 m = None)
+ assert (M.get ~inj:inj_list_int 3 m = Some [3;3;3])
+ assert (M.get ~inj:inj_str 3 m = None)change of API, the map is last argument to make piping with |> easier since 0.16.
type 'a injectionAn accessor for values of type 'a in any map. Values put +in the map using a key can only be retrieved using this +very same key.
val create_inj : unit ‑> 'a injectionReturn a value that works for a given type of values. This function is +normally called once for each type of value. Several keys may be +created for the same type, but a value set with a given setter can only be +retrieved with the matching getter. The same key can be reused +across multiple maps (although not in a thread-safe way).
module type S : sig ... endmodule type ORD : sig ... endFind the value for the given key, which must be of the right type.
let k1 : int key = newkey () in
+ let k2 : int key = newkey () in
+ let k3 : string key = newkey () in
+ let set =
+ empty
+ |> set ~key:k1 1
+ |> set ~key:k2 2
+ |> set ~key:k3 "3"
+ in
+ assert (get ~key:k1 set = Some 1);
+ assert (get ~key:k2 set = Some 2);
+ assert (get ~key:k3 set = Some "3");
+ ()val newkey : unit ‑> 'a keynewkey () creates a new unique key that can be used to access
+a 'a value in a set. Each key created with newkey is distinct
+from any other key, even if they have the same type.
Not thread-safe.
set ~key v set maps key to v in set. It means that
+for every set, get ~key (set ~key v set) = Some v.
Same as get, but can fail.
From https://github.com/mjambon/mixtbl (thanks to him). +Example:
let inj_int = CCMixtbl.create_inj () ;;
+
+ let tbl = CCMixtbl.create 10 ;;
+
+ OUnit.assert_equal None (CCMixtbl.get ~inj:inj_int tbl "a");;
+
+ CCMixtbl.set inj_int tbl "a" 1;;
+
+ OUnit.assert_equal (Some 1) (CCMixtbl.get ~inj:inj_int tbl "a");;
+
+ let inj_string = CCMixtbl.create_inj () ;;
+
+ CCMixtbl.set inj_string tbl "b" "Hello";
+
+ OUnit.assert_equal (Some "Hello") (CCMixtbl.get inj_string tbl "b");;
+ OUnit.assert_equal None (CCMixtbl.get inj_string tbl "a");;
+ OUnit.assert_equal (Some 1) (CCMixtbl.get inj_int tbl "a");;
+ CCMixtbl.set inj_string tbl "a" "Bye";;
+
+ OUnit.assert_equal None (CCMixtbl.get inj_int tbl "a");;
+ OUnit.assert_equal (Some "Bye") (CCMixtbl.get inj_string tbl "a");;type 'a tA hash table containing values of different types.
+The type parameter 'a represents the type of the keys.
type 'b injectionAn accessor for values of type 'b in any table. Values put +in the table using a key can only be retrieved using this +very same key.
val create_inj : unit ‑> 'b injectionReturn a value that works for a given type of values. This function is +normally called once for each type of value. Several keys may be +created for the same type, but a value set with a given setter can only be +retrieved with the matching getter. The same key can be reused +across multiple tables (although not in a thread-safe way).
Find the value for the given key, which must be of the right type.
V : OrderedTypeK : OrderedTypeR : OrderedTypeL : OrderedTypeval empty : tval is_empty : t ‑> boolmodule type S : sig ... endmodule type OrderedType : sig ... endmodule Make : functor (K : OrderedType) -> functor (V : OrderedType) -> S with type key = K.t and type value = V.t+Represents n-to-n mappings between two types. Each element from the "left" +is mapped to several right values, and conversely.
module type BIDIR : sig ... endmodule MakeBidir : functor (L : OrderedType) -> functor (R : OrderedType) -> BIDIR with type left = L.t and type right = R.tval empty : tval is_empty : t ‑> boolval empty : tval is_empty : t ‑> boolremove_mult set x n removes at most n occurrences of x from set.
n < 0.update set x f calls f n where n is the current multiplicity
+of x in set (0 to indicate its absence); the result of f n
+is the new multiplicity of x.
f n < 0.module type S : sig ... endval empty : tval is_empty : t ‑> boolremove_mult set x n removes at most n occurrences of x from set.
n < 0.update set x f calls f n where n is the current multiplicity
+of x in set (0 to indicate its absence); the result of f n
+is the new multiplicity of x.
f n < 0.From the paper by Jean-Christophe Filliâtre, +"A persistent Union-Find data structure", see +the ps version
val make : int ‑> 'a ‑> 'a tmake n x returns a persistent array of length n, with x. All the
+elements of this new array are initially physically equal to x
+(in the sense of the == predicate). Consequently, if x is mutable, it is
+shared among all elements of the array, and modifying x through one of the
+array entries will modify all other entries at the same time.
n < 0 or n > Sys.max_array_length.
+If the value of x is a floating-point number, then the maximum size is
+only Sys.max_array_length / 2.val init : int ‑> (int ‑> 'a) ‑> 'a tinit n f returns a persistent array of length n, with element
+i initialized to the result of f i.
n < 0 or n > Sys.max_array_length.
+If the value of x is a floating-point number, then the maximum size is
+only Sys.max_array_length / 2.val get : 'a t ‑> int ‑> 'aget a i returns the element with index i from the array a.
n is outside the
+range 0 to Array.length a - 1.set a i v sets the element index i from the array a to v.
n is outside the
+range 0 to Array.length a - 1.Apply the given function to all elements of the array, and return
+a persistent array initialized by the results of f. In the case of mapi,
+the function is also given the index of the element.
+It is equivalent to fun f t -> init (fun i -> f (get t i)).
val iter : ('a ‑> unit) ‑> 'a t ‑> unititer f t applies function f to all elements of the persistent array,
+in order from element 0 to element length t - 1.
val iteri : (int ‑> 'a ‑> unit) ‑> 'a t ‑> unititer f t applies function f to all elements of the persistent array,
+in order from element 0 to element length t - 1.
val fold_left : ('a ‑> 'b ‑> 'a) ‑> 'a ‑> 'b t ‑> 'aval of_list : 'a list ‑> 'a tof_list l returns a fresh persistent array containing the elements of l.
val of_rev_list : 'a list ‑> 'a tof_rev_list l is the same as of_list (List.rev l) but more efficient.
val hash : t ‑> intH : HashedTypeAdd the binding to the table, returning a new table. The old binding
+for this key, if it exists, is shadowed and will be restored upon
+remove tbl k.
Add the binding to the table, returning a new table. This erases
+the current binding for key, if any.
update tbl key f calls f None if key doesn't belong in tbl,
+f (Some v) if key -> v otherwise; If f returns None then
+key is removed, else it returns Some v' and key -> v' is added.
Fresh copy of the table; the underlying structure is not shared +anymore, so using both tables alternatively will be efficient.
val merge : f:(key ‑> [ `Left of 'a | `Right of 'b | `Both of 'a * 'b ] ‑> 'c option) ‑> 'a t ‑> 'b t ‑> 'c tMerge two tables together into a new table. The function's argument
+correspond to values associated with the key (if present); if the
+function returns None the key will not appear in the result.
Almost as efficient as the regular Hashtbl type, but with a persistent +interface (rewinding changes to get back in the past history). This is +mostly useful for backtracking-like uses, or forward uses (never using +old values).
This module is not thread-safe.
module type HashedType : sig ... endmodule type S : sig ... endval hash : t ‑> intAdd the binding to the table, returning a new table. The old binding
+for this key, if it exists, is shadowed and will be restored upon
+remove tbl k.
Add the binding to the table, returning a new table. This erases
+the current binding for key, if any.
update tbl key f calls f None if key doesn't belong in tbl,
+f (Some v) if key -> v otherwise; If f returns None then
+key is removed, else it returns Some v' and key -> v' is added.
Fresh copy of the table; the underlying structure is not shared +anymore, so using both tables alternatively will be efficient.
val merge : f:(key ‑> [ `Left of 'a | `Right of 'b | `Both of 'a * 'b ] ‑> 'c option) ‑> 'a t ‑> 'b t ‑> 'c tMerge two tables together into a new table. The function's argument
+correspond to values associated with the key (if present); if the
+function returns None the key will not appear in the result.
val (--^) : int ‑> int ‑> int ta --^ b is the integer range from a to b, where b is excluded.
This is an OCaml implementation of Okasaki's paper +"Purely Functional Random Access Lists". It defines a list-like data +structure with O(1) cons/tail operations, and O(log(n)) lookup/modification +operations.
This module used to be part of containers.misc
status: stable
Unsafe version of front.
val get_exn : 'a t ‑> int ‑> 'aUnsafe version of get.
i+1 elements.set l i v sets the i-th element of the list to v. O(log(n)).
i+1 elements.remove l i removes the i-th element of v.
i+1 elements.take_drop n l splits l into a, b such that length a = n
+if length l >= n, and such that append a b = l.
val iteri : f:(int ‑> 'a ‑> unit) ‑> 'a t ‑> unitval fold_rev : f:('b ‑> 'a ‑> 'b) ‑> x:'b ‑> 'a t ‑> 'bFold on the list's elements, in reverse order (starting from the tail).
val make : int ‑> 'a ‑> 'a tval to_list : 'a t ‑> 'a listval of_array : 'a array ‑> 'a tmodule Infix : sig ... endEfficient array version for the char type
val dummy : tMakes an array given an arbitrary element type
Elt : sig ... endThe abstract type for arrays
module type S : sig ... endAn efficient byte based ring buffer
val create : int ‑> tcreate size creates a new bounded buffer with given size.
+The underlying array is allocated immediately and no further (large)
+allocation will happen from now on.
< 1.blit_from buf from_buf o len copies the slice o, ... o + len - 1 from
+an input buffer from_buf to the end of the buffer.
+If the slice is too large for the buffer, only the last part of the array
+will be copied.
o,len is not a valid slice of s.blit_into buf to_buf o len copies at most len elements from buf
+into to_buf starting at offset o in s.
min len (length buf)).o,len is not a valid slice of s.append b ~into copies all data from b and adds it at the
+end of into. Erases data of into if there is not enough room.
val junk_front : t ‑> unitDrop the front element from t.
val skip : t ‑> int ‑> unitskip b len removes len elements from the front of b.
len > length b.get_front buf i returns the i-th element of buf from the front, i.e.
+the one returned by take_front buf after i-1 calls to junk_front buf.
length buf).get_back buf i returns the i-th element of buf from the back, i.e.
+the one returned by take_back buf after i-1 calls to junk_back buf.
length buf).Push value at the back of t.
+If t.bounded=false, the buffer will grow as needed,
+otherwise the oldest elements are replaced first.
Create a buffer from an initial array, but doesn't take ownership +of it (still allocates a new internal array).
The module type of Array for this ring buffer
val dummy : tBuffer using regular arrays
X : sig ... endval create : int ‑> tcreate size creates a new bounded buffer with given size.
+The underlying array is allocated immediately and no further (large)
+allocation will happen from now on.
< 1.blit_from buf from_buf o len copies the slice o, ... o + len - 1 from
+an input buffer from_buf to the end of the buffer.
+If the slice is too large for the buffer, only the last part of the array
+will be copied.
o,len is not a valid slice of s.blit_into buf to_buf o len copies at most len elements from buf
+into to_buf starting at offset o in s.
min len (length buf)).o,len is not a valid slice of s.append b ~into copies all data from b and adds it at the
+end of into. Erases data of into if there is not enough room.
val junk_front : t ‑> unitDrop the front element from t.
val skip : t ‑> int ‑> unitskip b len removes len elements from the front of b.
len > length b.get_front buf i returns the i-th element of buf from the front, i.e.
+the one returned by take_front buf after i-1 calls to junk_front buf.
length buf).get_back buf i returns the i-th element of buf from the back, i.e.
+the one returned by take_back buf after i-1 calls to junk_back buf.
length buf).Push value at the back of t.
+If t.bounded=false, the buffer will grow as needed,
+otherwise the oldest elements are replaced first.
Create a buffer from an initial array, but doesn't take ownership +of it (still allocates a new internal array).
Makes a ring buffer module with the given array type
val create : int ‑> tcreate size creates a new bounded buffer with given size.
+The underlying array is allocated immediately and no further (large)
+allocation will happen from now on.
< 1.blit_from buf from_buf o len copies the slice o, ... o + len - 1 from
+an input buffer from_buf to the end of the buffer.
+If the slice is too large for the buffer, only the last part of the array
+will be copied.
o,len is not a valid slice of s.blit_into buf to_buf o len copies at most len elements from buf
+into to_buf starting at offset o in s.
min len (length buf)).o,len is not a valid slice of s.append b ~into copies all data from b and adds it at the
+end of into. Erases data of into if there is not enough room.
val junk_front : t ‑> unitDrop the front element from t.
val skip : t ‑> int ‑> unitskip b len removes len elements from the front of b.
len > length b.get_front buf i returns the i-th element of buf from the front, i.e.
+the one returned by take_front buf after i-1 calls to junk_front buf.
length buf).get_back buf i returns the i-th element of buf from the back, i.e.
+the one returned by take_back buf after i-1 calls to junk_back buf.
length buf).Push value at the back of t.
+If t.bounded=false, the buffer will grow as needed,
+otherwise the oldest elements are replaced first.
Create a buffer from an initial array, but doesn't take ownership +of it (still allocates a new internal array).
Useful for IO, or as a bounded-size alternative to Queue when +batch operations are needed.
status: experimental
Change in the API to provide only a bounded buffer since 1.3
The module type of Array for this ring buffer
The abstract ring buffer type, made concrete by choice of
+ARRAY module implementation
val create : int ‑> tcreate size creates a new bounded buffer with given size.
+The underlying array is allocated immediately and no further (large)
+allocation will happen from now on.
< 1.blit_from buf from_buf o len copies the slice o, ... o + len - 1 from
+an input buffer from_buf to the end of the buffer.
+If the slice is too large for the buffer, only the last part of the array
+will be copied.
o,len is not a valid slice of s.blit_into buf to_buf o len copies at most len elements from buf
+into to_buf starting at offset o in s.
min len (length buf)).o,len is not a valid slice of s.append b ~into copies all data from b and adds it at the
+end of into. Erases data of into if there is not enough room.
val junk_front : t ‑> unitDrop the front element from t.
val skip : t ‑> int ‑> unitskip b len removes len elements from the front of b.
len > length b.get_front buf i returns the i-th element of buf from the front, i.e.
+the one returned by take_front buf after i-1 calls to junk_front buf.
length buf).get_back buf i returns the i-th element of buf from the back, i.e.
+the one returned by take_back buf after i-1 calls to junk_back buf.
length buf).Push value at the back of t.
+If t.bounded=false, the buffer will grow as needed,
+otherwise the oldest elements are replaced first.
Create a buffer from an initial array, but doesn't take ownership +of it (still allocates a new internal array).
Simple implementation of functional queues
val empty : 'a tval is_empty : 'a t ‑> boolSame as pop, but fails on empty queues.
Append two queues. Elements from the second one come +after elements of the first one. +Linear in the size of the second queue.
module Infix : sig ... endval fold : ('b ‑> 'a ‑> 'b) ‑> 'b ‑> 'a t ‑> 'bval iter : ('a ‑> unit) ‑> 'a t ‑> unitval to_list : 'a t ‑> 'a listval of_list : 'a list ‑> 'a tval empty : 'a tval is_empty : _ t ‑> boolSame as find but can fail.
longest_prefix k m finds the longest prefix of k that leads to
+at least one path in m (it does not mean that the prefix is bound to
+a value.
Example: if m has keys "abc0" and "abcd", then longest_prefix "abc2" m
+will return "abc".
Update the binding for the given key. The function is given
+None if the key is absent, or Some v if key is bound to v;
+if it returns None the key is removed, otherwise it
+returns Some y and key becomes bound to y.
Fold on key/value bindings. Will use WORD.of_list to rebuild keys.
Map values, giving both key and value. Will use WORD.of_list to rebuild keys.
val fold_values : ('b ‑> 'a ‑> 'b) ‑> 'b ‑> 'a t ‑> 'bMore efficient version of fold, that doesn't keep keys.
val iter_values : ('a ‑> unit) ‑> 'a t ‑> unitMerge two tries together. The function is used in +case of conflicts, when a key belongs to both tries.
val empty : 'a tval is_empty : _ t ‑> boolSame as find but can fail.
longest_prefix k m finds the longest prefix of k that leads to
+at least one path in m (it does not mean that the prefix is bound to
+a value.
Example: if m has keys "abc0" and "abcd", then longest_prefix "abc2" m
+will return "abc".
Update the binding for the given key. The function is given
+None if the key is absent, or Some v if key is bound to v;
+if it returns None the key is removed, otherwise it
+returns Some y and key becomes bound to y.
Fold on key/value bindings. Will use WORD.of_list to rebuild keys.
Map values, giving both key and value. Will use WORD.of_list to rebuild keys.
val fold_values : ('b ‑> 'a ‑> 'b) ‑> 'b ‑> 'a t ‑> 'bMore efficient version of fold, that doesn't keep keys.
val iter_values : ('a ‑> unit) ‑> 'a t ‑> unitMerge two tries together. The function is used in +case of conflicts, when a key belongs to both tries.
val empty : 'a tval is_empty : _ t ‑> boolSame as find but can fail.
longest_prefix k m finds the longest prefix of k that leads to
+at least one path in m (it does not mean that the prefix is bound to
+a value.
Example: if m has keys "abc0" and "abcd", then longest_prefix "abc2" m
+will return "abc".
Update the binding for the given key. The function is given
+None if the key is absent, or Some v if key is bound to v;
+if it returns None the key is removed, otherwise it
+returns Some y and key becomes bound to y.
Fold on key/value bindings. Will use WORD.of_list to rebuild keys.
Map values, giving both key and value. Will use WORD.of_list to rebuild keys.
val fold_values : ('b ‑> 'a ‑> 'b) ‑> 'b ‑> 'a t ‑> 'bMore efficient version of fold, that doesn't keep keys.
val iter_values : ('a ‑> unit) ‑> 'a t ‑> unitMerge two tries together. The function is used in +case of conflicts, when a key belongs to both tries.
val empty : 'a tval is_empty : _ t ‑> boolSame as find but can fail.
longest_prefix k m finds the longest prefix of k that leads to
+at least one path in m (it does not mean that the prefix is bound to
+a value.
Example: if m has keys "abc0" and "abcd", then longest_prefix "abc2" m
+will return "abc".
Update the binding for the given key. The function is given
+None if the key is absent, or Some v if key is bound to v;
+if it returns None the key is removed, otherwise it
+returns Some y and key becomes bound to y.
Fold on key/value bindings. Will use WORD.of_list to rebuild keys.
Map values, giving both key and value. Will use WORD.of_list to rebuild keys.
val fold_values : ('b ‑> 'a ‑> 'b) ‑> 'b ‑> 'a t ‑> 'bMore efficient version of fold, that doesn't keep keys.
val iter_values : ('a ‑> unit) ‑> 'a t ‑> unitMerge two tries together. The function is used in +case of conflicts, when a key belongs to both tries.
Words are made of characters, who belong to a total order
module type WORD : sig ... endmodule type S : sig ... endmodule type ORDERED : sig ... endval empty : 'a tval is_empty : _ t ‑> boolSame as find but can fail.
longest_prefix k m finds the longest prefix of k that leads to
+at least one path in m (it does not mean that the prefix is bound to
+a value.
Example: if m has keys "abc0" and "abcd", then longest_prefix "abc2" m
+will return "abc".
Update the binding for the given key. The function is given
+None if the key is absent, or Some v if key is bound to v;
+if it returns None the key is removed, otherwise it
+returns Some y and key becomes bound to y.
Fold on key/value bindings. Will use WORD.of_list to rebuild keys.
Map values, giving both key and value. Will use WORD.of_list to rebuild keys.
val fold_values : ('b ‑> 'a ‑> 'b) ‑> 'b ‑> 'a t ‑> 'bMore efficient version of fold, that doesn't keep keys.
val iter_values : ('a ‑> unit) ‑> 'a t ‑> unitMerge two tries together. The function is used in +case of conflicts, when a key belongs to both tries.
val empty : 'a tval is_empty : _ t ‑> boolget_rank k m looks for the rank of k in m, i.e. the index
+of k in the sorted list of bindings of m.
+let (`At n) = get_rank k m in nth_exn n m = get m k should hold.
update k f m calls f (Some v) if get k m = Some v, f None
+otherwise. Then, if f returns Some v' it binds k to v',
+if f returns None it removes k.
val cardinal : _ t ‑> intval weight : _ t ‑> intsplit k t returns l, o, r where l is the part of the map
+with keys smaller than k, r has keys bigger than k,
+and o = Some v if k, v belonged to the map.
extract_min m returns k, v, m' where k,v is the pair with the
+smallest key in m, and m' does not contain k.
extract_max m returns k, v, m' where k,v is the pair with the
+highest key in m, and m' does not contain k.
Randomly choose a (key,value) pair within the tree, using weights +as probability weights.
val weight : t ‑> intUse the custom X.weight function
val empty : 'a tval is_empty : _ t ‑> boolget_rank k m looks for the rank of k in m, i.e. the index
+of k in the sorted list of bindings of m.
+let (`At n) = get_rank k m in nth_exn n m = get m k should hold.
update k f m calls f (Some v) if get k m = Some v, f None
+otherwise. Then, if f returns Some v' it binds k to v',
+if f returns None it removes k.
val cardinal : _ t ‑> intval weight : _ t ‑> intsplit k t returns l, o, r where l is the part of the map
+with keys smaller than k, r has keys bigger than k,
+and o = Some v if k, v belonged to the map.
extract_min m returns k, v, m' where k,v is the pair with the
+smallest key in m, and m' does not contain k.
extract_max m returns k, v, m' where k,v is the pair with the
+highest key in m, and m' does not contain k.
Randomly choose a (key,value) pair within the tree, using weights +as probability weights.
status: experimental
module type ORD : sig ... endmodule type KEY : sig ... endmodule type S : sig ... endval weight : t ‑> intval empty : 'a tval is_empty : _ t ‑> boolget_rank k m looks for the rank of k in m, i.e. the index
+of k in the sorted list of bindings of m.
+let (`At n) = get_rank k m in nth_exn n m = get m k should hold.
update k f m calls f (Some v) if get k m = Some v, f None
+otherwise. Then, if f returns Some v' it binds k to v',
+if f returns None it removes k.
val cardinal : _ t ‑> intval weight : _ t ‑> intsplit k t returns l, o, r where l is the part of the map
+with keys smaller than k, r has keys bigger than k,
+and o = Some v if k, v belonged to the map.
extract_min m returns k, v, m' where k,v is the pair with the
+smallest key in m, and m' does not contain k.
extract_max m returns k, v, m' where k,v is the pair with the
+highest key in m, and m' does not contain k.
Randomly choose a (key,value) pair within the tree, using weights +as probability weights.
type 'a t = 'a list * 'a listThe pair l, r represents the list List.rev_append l r, but
+with the focus on r
val to_list : 'a t ‑> 'a listConvert the zipper back to a list.
+to_list (l,r) is List.rev_append l r.
val to_rev_list : 'a t ‑> 'a listConvert the zipper back to a reversed list.
+In other words, to_list (l,r) is List.rev_append r l.
Modify the current element, if any, by returning a new element, or
+returning None if the element is to be deleted.
Insert an element at the current position. If an element was focused,
+insert x l adds x just before it, and focuses on x.
val is_focused : _ t ‑> boolIs the zipper focused on some element? That is, will focused
+return a Some v?
val focused : 'a t ‑> 'a optionReturn the focused element, if any. focused zip = Some _ iff
+empty zip = false.
val focused_exn : 'a t ‑> 'aReturn the focused element, or
Drop every element on the "right" (calling right then will do nothing), +keeping the focused element, if any.
Drop every element on the "right" (calling right then will do nothing), +including the focused element if it is present.
+This library exposes the following toplevel modules:
.
\ No newline at end of file diff --git a/dev/containers.data/page-index.odoc b/dev/containers.data/page-index.odoc new file mode 100644 index 00000000..e4a4b413 Binary files /dev/null and b/dev/containers.data/page-index.odoc differ diff --git a/dev/containers.iter/CCKList.odoc b/dev/containers.iter/CCKList.odoc new file mode 100644 index 00000000..d484b5e6 Binary files /dev/null and b/dev/containers.iter/CCKList.odoc differ diff --git a/dev/containers.iter/CCKList/.jbuilder-keep b/dev/containers.iter/CCKList/.jbuilder-keep new file mode 100644 index 00000000..e69de29b diff --git a/dev/containers.iter/CCKList/Infix/index.html b/dev/containers.iter/CCKList/Infix/index.html new file mode 100644 index 00000000..45dfb5e1 --- /dev/null +++ b/dev/containers.iter/CCKList/Infix/index.html @@ -0,0 +1,2 @@ + +val (--) : int ‑> int ‑> int tval (--^) : int ‑> int ‑> int tval return : 'a ‑> 'a tval nil : 'a tval empty : 'a tval singleton : 'a ‑> 'a tval repeat : ?n:int ‑> 'a ‑> 'a trepeat ~n x repeats xn times then stops. If n is omitted,
+then x is repeated forever.
val unfold : ('b ‑> ('a * 'b) option) ‑> 'b ‑> 'a tunfold f acc calls f acc and:
+
f acc = Some (x, acc'), yield x, continue with unfold f acc'.f acc = None, stops.val is_empty : 'a t ‑> boolUnsafe version of tail.
val iter : ('a ‑> unit) ‑> 'a t ‑> unitval length : _ t ‑> intNumber of elements in the list. +Will not terminate if the list if infinite: +use (for instance) take to make the list finite if necessary.
Fair product of two (possibly infinite) lists into a new list. Lazy. +The first parameter is used to combine each pair of elements.
Specialization of product_with producing tuples.
group eq l groups together consecutive elements that satisfy eq. Lazy.
+For instance group (=) [1;1;1;2;2;3;3;1] yields
+[1;1;1]; [2;2]; [3;3]; [1].
uniq eq l returns l but removes consecutive duplicates. Lazy.
+In other words, if several values that are equal follow one another,
+only the first of them is kept.
val range : int ‑> int ‑> int tval (--) : int ‑> int ‑> int ta -- b is the range of integers containing
+a and b (therefore, never empty).
val (--^) : int ‑> int ‑> int ta -- b is the integer range from a to b, where b is excluded.
Eager sort that removes duplicate values. Require the iterator to be
+finite. O(n ln(n)) time and space.
val return : 'a ‑> 'a tval pure : 'a ‑> 'a tmodule Infix : sig ... endval of_list : 'a list ‑> 'a tval return : 'a ‑> 'a ttype attribute = [ | `Color of string |
| `Shape of string |
| `Weight of int |
| `Style of string |
| `Label of string |
| `Id of string |
| `Other of string * string |
]Dot attributes for nodes
val mk_id : ('a, Buffer.t, unit, attribute) Pervasives.format4 ‑> 'aUsing a formatter string, build an ID.
val mk_label : ('a, Buffer.t, unit, attribute) Pervasives.format4 ‑> 'aUsing a formatter string, build a label.
val print_to_file : string ‑> graph ‑> unitprint_to_file filename g prints g into a file whose name
+is filename.
to_file filename trees makes a graph out of the trees, opens the
+file filename and prints the graph into the file.
Abstract Set structure
method add : 'a ‑> 'a pset+This structure can be used to represent trees and directed +graphs (as infinite trees) in a lazy fashion. Like CCKList, it +is a structural type.
val empty : 'a tval is_empty : _ t ‑> boolval fold : ('a ‑> 'b ‑> 'a) ‑> 'a ‑> 'b t ‑> 'aFold on values in no specified order. May not terminate if the +tree is infinite.
val iter : ('a ‑> unit) ‑> 'a t ‑> unitval set_of_cmp : cmp:('a ‑> 'a ‑> int) ‑> unit ‑> 'a psetBuild a set structure given a total ordering.
val force : 'a t ‑> [ `Nil | `Node of 'a * 'b list ] as bforce t evaluates t completely and returns a regular tree
+structure.
Example (tree of calls for naive Fibonacci function): +
let mk_fib n =
+ let rec fib' l r i =
+ if i=n then r else fib' r (l+r) (i+1)
+ in fib' 1 1 1;;
+
+ let rec fib n = match n with
+ | 0 | 1 -> CCKTree.singleton (`Cst n)
+ | _ -> CCKTree.node2 (`Plus (mk_fib n)) (fib (n-1)) (fib (n-2));;
+
+ let pp_node fmt = function
+ | `Cst n -> Format.fprintf fmt "%d" n
+ | `Plus n -> Format.fprintf fmt "%d" n;;
+
+ Format.printf "%a@." (CCKTree.pp pp_node) (fib 8);;A pretty-printer using S-expressions and boxes to render the tree. +Empty nodes are not rendered; sharing is ignored.
module Dot : sig ... endval length : _ t ‑> intlength l returns the number of elements in l, eagerly (linear time).
+Caution, will not terminate if l is infinite.
module Infix : sig ... endval of_list : 'a list ‑> 'a tval to_list : 'a t ‑> 'a listval to_list_rev : 'a t ‑> 'a list+This library exposes the following toplevel modules:
| CCKList | |
| CCKTree | |
| CCLazy_list |
.
\ No newline at end of file diff --git a/dev/containers.iter/page-index.odoc b/dev/containers.iter/page-index.odoc new file mode 100644 index 00000000..9e8e2cae Binary files /dev/null and b/dev/containers.iter/page-index.odoc differ diff --git a/dev/containers.monomorphic/CCMonomorphic.odoc b/dev/containers.monomorphic/CCMonomorphic.odoc new file mode 100644 index 00000000..b97fa980 Binary files /dev/null and b/dev/containers.monomorphic/CCMonomorphic.odoc differ diff --git a/dev/containers.monomorphic/CCMonomorphic/.jbuilder-keep b/dev/containers.monomorphic/CCMonomorphic/.jbuilder-keep new file mode 100644 index 00000000..e69de29b diff --git a/dev/containers.monomorphic/CCMonomorphic/index.html b/dev/containers.monomorphic/CCMonomorphic/index.html new file mode 100644 index 00000000..619da61c --- /dev/null +++ b/dev/containers.monomorphic/CCMonomorphic/index.html @@ -0,0 +1,2 @@ + +val (==) : [ `Consider_using_CCEqual_physical ]val (!=) : [ `Consider_using_CCEqual_physical ]+This library exposes the following toplevel modules:
| CCMonomorphic |
.
\ No newline at end of file diff --git a/dev/containers.monomorphic/page-index.odoc b/dev/containers.monomorphic/page-index.odoc new file mode 100644 index 00000000..abc761f6 Binary files /dev/null and b/dev/containers.monomorphic/page-index.odoc differ diff --git a/dev/containers.sexp/CCSexp.odoc b/dev/containers.sexp/CCSexp.odoc new file mode 100644 index 00000000..8b8e09ed Binary files /dev/null and b/dev/containers.sexp/CCSexp.odoc differ diff --git a/dev/containers.sexp/CCSexp/.jbuilder-keep b/dev/containers.sexp/CCSexp/.jbuilder-keep new file mode 100644 index 00000000..e69de29b diff --git a/dev/containers.sexp/CCSexp/Decoder/index.html b/dev/containers.sexp/CCSexp/Decoder/index.html new file mode 100644 index 00000000..6a8a2937 --- /dev/null +++ b/dev/containers.sexp/CCSexp/Decoder/index.html @@ -0,0 +1,3 @@ + +val of_lexbuf : Lexing.lexbuf ‑> tval next : t ‑> sexp parse_resultParse the next S-expression or return an error if the input isn't +long enough or isn't a proper S-expression.
val hash : t ‑> intval of_int : int ‑> tval of_bool : bool ‑> tval of_unit : tof_variant name args is used to encode algebraic variants
+into a S-expr. For instance of_variant "some" [of_int 1]
+represents the value Some 1.
val to_buf : Buffer.t ‑> t ‑> unitval to_string : t ‑> stringval to_file : string ‑> t ‑> unitval to_chan : Pervasives.out_channel ‑> t ‑> unitA parser of 'a can return Yield x when it parsed a value,
+or Fail e when a parse error was encountered, or
+End if the input was empty.
module Decoder : sig ... endParse a S-expression from the given channel. Can read more data than +necessary, so don't use this if you need finer-grained control (e.g. +to read something else after the S-exp).
val token : Lexing.lexbuf ‑> tokenval __ocaml_lex_token_rec : Lexing.lexbuf ‑> int ‑> token+This library exposes the following toplevel modules:
| CCSexp | |
| CCSexp_lex |
.
\ No newline at end of file diff --git a/dev/containers.sexp/page-index.odoc b/dev/containers.sexp/page-index.odoc new file mode 100644 index 00000000..e84cae87 Binary files /dev/null and b/dev/containers.sexp/page-index.odoc differ diff --git a/dev/containers.thread/CCBlockingQueue.odoc b/dev/containers.thread/CCBlockingQueue.odoc new file mode 100644 index 00000000..5d19a967 Binary files /dev/null and b/dev/containers.thread/CCBlockingQueue.odoc differ diff --git a/dev/containers.thread/CCBlockingQueue/.jbuilder-keep b/dev/containers.thread/CCBlockingQueue/.jbuilder-keep new file mode 100644 index 00000000..e69de29b diff --git a/dev/containers.thread/CCBlockingQueue/index.html b/dev/containers.thread/CCBlockingQueue/index.html new file mode 100644 index 00000000..f2d80da4 --- /dev/null +++ b/dev/containers.thread/CCBlockingQueue/index.html @@ -0,0 +1,9 @@ + +This queue has a limited size. Pushing a value on the queue when it +is full will block.
val create : int ‑> 'a tCreate a new queue of size n. Using n=max_int amounts to using
+an infinite queue (2^61 items is a lot to fit in memory); using n=1
+amounts to using a box with 0 or 1 elements inside.
n < 1.val try_take : 'a t ‑> 'a optionTake the first element if the queue is not empty, return None
+otherwise.
val try_push : 'a t ‑> 'a ‑> booltry_push q x pushes x into q if q is not full, in which
+case it returns true.
+If it fails because q is full, it returns false.
val peek : 'a t ‑> 'a optionpeek q returns Some x if x is the first element of q,
+otherwise it returns None.
Type allowing to manipulate the lock as a reference.
val get : 'a t ‑> 'aval set : 'a t ‑> 'a ‑> unitval update : 'a t ‑> ('a ‑> 'a) ‑> unitA value wrapped into a Mutex, for more safety.
val with_lock : 'a t ‑> ('a ‑> 'b) ‑> 'bwith_lock l f runs f x where x is the value protected with
+the lock l, in a critical section. If f x fails, with_lock l f
+fails too but the lock is released.
val try_with_lock : 'a t ‑> ('a ‑> 'b) ‑> 'b optiontry_with_lock l f runs f x in a critical section if l is not
+locked. x is the value protected by the lock l. If f x
+fails, try_with_lock l f fails too but the lock is released.
with_lock_as_ref l f calls f with a reference-like object
+that allows to manipulate the value of l safely.
+The object passed to f must not escape the function call.
val update_map : 'a t ‑> ('a ‑> 'a * 'b) ‑> 'bupdate_map l f computes x', y = f (get l), then puts x' in l
+and returns y.
val get : 'a t ‑> 'aAtomically get the value in the lock. The value that is returned +isn't protected!
val get_then_incr : int t ‑> intget_then_incr x increments x, and returns its previous value.
val get_then_decr : int t ‑> intget_then_decr x decrements x, and returns its previous value.
val get_then_set : bool t ‑> boolget_then_set b sets b to true, and returns the old value.
val get_then_clear : bool t ‑> boolget_then_clear b sets b to false, and returns the old value.
The futures are registration points for callbacks, storing a state, +that are executed in the pool using run.
val make : (unit ‑> 'a) ‑> 'a tCreate a future, representing a value that will be computed by +the function. If the function raises, the future will fail.
val make1 : ('a ‑> 'b) ‑> 'a ‑> 'b tval make2 : ('a ‑> 'b ‑> 'c) ‑> 'a ‑> 'b ‑> 'c tval get : 'a t ‑> 'aBlocking get: wait for the future to be evaluated, and get the value, +or the exception that failed the future is returned. +Raise e if the future failed with e.
val on_success : 'a t ‑> ('a ‑> unit) ‑> unitAttach a handler to be called upon success. +The handler should not call functions on the future. +Might be evaluated now if the future is already done.
val on_failure : _ t ‑> (exn ‑> unit) ‑> unitAttach a handler to be called upon failure. +The handler should not call any function on the future. +Might be evaluated now if the future is already done.
Attach a handler to be called when the future is evaluated. +The handler should not call functions on the future. +Might be evaluated now if the future is already done.
Future that waits for all previous futures to terminate. If any future
+in the array fails, sequence_a l fails too.
map_a f a maps f on every element of a, and will return
+the array of every result if all calls succeed, or an error otherwise.
Future that waits for all previous futures to terminate. If any future
+in the list fails, sequence_l l fails too.
map_l f l maps f on every element of l, and will return
+the list of every result if all calls succeed, or an error otherwise.
Choose among those futures (the first to terminate). Behaves like +the first future that terminates, by failing if the future fails.
Choose among those futures (the first to terminate). Behaves like +the first future that terminates, by failing if the future fails.
app_async f x applies the result of f to the result of x, in
+a separated job scheduled in the pool.
val sleep : float ‑> unit tFuture that returns with success in the given amount of seconds. Blocks +the thread! If you need to wait on many events, consider +using CCTimer.
module Infix : sig ... endval stop : unit ‑> unitAfter calling stop (), most functions will raise Stopped.
+This has the effect of preventing new tasks from being executed.
Renamed and heavily updated from CCFuture.
module type PARAM : sig ... endval create : int ‑> tcreate n creates a semaphore with initial value n.
n <= 0.val acquire : int ‑> t ‑> unitacquire n s blocks until get s >= n, then atomically
+sets s := !s - n.
val with_acquire : n:int ‑> t ‑> f:(unit ‑> 'a) ‑> 'awith_acquire ~n s ~f first acquires s with n units,
+calls f (), and then releases s with n units.
+Safely release the semaphore even if f () fails.
val wait_until_at_least : n:int ‑> t ‑> f:(unit ‑> 'a) ‑> 'await_until_at_least ~n s ~f waits until get s >= n, then calls f ()
+and returns its result. Doesn't modify the semaphore.
val spawn : int ‑> (int ‑> 'a) ‑> t arrayArr.spawn n f creates an array res of length n, such that
+res.(i) = spawn (fun () -> f i).
val wait : t ‑> unitwait b waits for barrier b to be activated by activate b.
+All threads calling this wait until activate b is called.
+If b is already activated, wait b does nothing.
val activated : t ‑> boolactivated b returns true iff activate b was called, and reset b
+was not called since. In other words, activated b = true means
+wait b will not block.
status: unstable
val spawn2 : ('a ‑> 'b ‑> _) ‑> 'a ‑> 'b ‑> tspawn2 f x y is like spawn (fun () -> f x y).
module Barrier : sig ... endUsed to be part of CCFuture.
val set_exn_handler : t ‑> (exn ‑> unit) ‑> unitset_exn_handler timer f registers f so that any exception
+raised by a task scheduled in timer is given to f.
val after : t ‑> float ‑> f:(unit ‑> _) ‑> unitCall the callback f after the given number of seconds.
val at : t ‑> float ‑> f:(unit ‑> _) ‑> unitCreate a future that evaluates to () at the given Unix timestamp.
val every : ?delay:float ‑> t ‑> float ‑> f:(unit ‑> _) ‑> unitevery timer n ~f calls f () every n seconds.
+f() can raise ExitEvery to stop the cycle.
f () is delayed by
+that many seconds.val stop : t ‑> unitStop the given timer, cancelling pending tasks. Idempotent. +From now on, calling most other operations on the timer will raise Stopped.
+This library exposes the following toplevel modules:
| CCBlockingQueue | |
| CCLock | |
| CCPool | |
| CCSemaphore | |
| CCThread | |
| CCTimer |
.
\ No newline at end of file diff --git a/dev/containers.thread/page-index.odoc b/dev/containers.thread/page-index.odoc new file mode 100644 index 00000000..e18b4909 Binary files /dev/null and b/dev/containers.thread/page-index.odoc differ diff --git a/dev/containers.top/Containers_top/.jbuilder-keep b/dev/containers.top/Containers_top/.jbuilder-keep new file mode 100644 index 00000000..e69de29b diff --git a/dev/containers.top/Containers_top/index.html b/dev/containers.top/Containers_top/index.html new file mode 100644 index 00000000..e6c24d1b --- /dev/null +++ b/dev/containers.top/Containers_top/index.html @@ -0,0 +1,2 @@ + ++This library exposes the following toplevel modules:
| Containers_top |
.
\ No newline at end of file diff --git a/dev/containers.top/page-index.odoc b/dev/containers.top/page-index.odoc new file mode 100644 index 00000000..9084745b Binary files /dev/null and b/dev/containers.top/page-index.odoc differ diff --git a/dev/containers.unix/CCUnix.odoc b/dev/containers.unix/CCUnix.odoc new file mode 100644 index 00000000..37cd1362 Binary files /dev/null and b/dev/containers.unix/CCUnix.odoc differ diff --git a/dev/containers.unix/CCUnix/.jbuilder-keep b/dev/containers.unix/CCUnix/.jbuilder-keep new file mode 100644 index 00000000..e69de29b diff --git a/dev/containers.unix/CCUnix/Infix/index.html b/dev/containers.unix/CCUnix/Infix/index.html new file mode 100644 index 00000000..f990dc03 --- /dev/null +++ b/dev/containers.unix/CCUnix/Infix/index.html @@ -0,0 +1,2 @@ + +val (?|) : ('a, Buffer.t, unit, call_result) Pervasives.format4 ‑> 'aInfix version of call.
val (?|&) : ('a, Buffer.t, unit, async_call_result) Pervasives.format4 ‑> 'aInfix version of async_call.
Some useful functions built on top of Unix.
status: unstable
type call_result = < stdout : string; stderr : string; status : Unix.process_status; errcode : int; >val call_full : ?bufsize:int ‑> ?stdin:[ `Gen of string gen | `Str of string ] ‑> ?env:string array ‑> ('a, Buffer.t, unit, call_result) Pervasives.format4 ‑> 'acall_full cmd wraps the result of Unix.open_process_full cmd into an
+object. It reads the full stdout and stderr of the subprocess before
+returning.
val call : ?bufsize:int ‑> ?stdin:[ `Gen of string gen | `Str of string ] ‑> ?env:string array ‑> ('a, Buffer.t, unit, string * string * int) Pervasives.format4 ‑> 'acall cmd is similar to call_full cmd but returns
+a tuple stdout, stderr, errcode instead of an object.
val call_stdout : ?bufsize:int ‑> ?stdin:[ `Gen of string gen | `Str of string ] ‑> ?env:string array ‑> ('a, Buffer.t, unit, string) Pervasives.format4 ‑> 'atype async_call_result = < stdout : line gen; stderr : line gen; stdin : line ‑> unit; close_in : unit; close_err : unit; close_out : unit; close_all : unit; wait : Unix.process_status; wait_errcode : int; >A subprocess for interactive usage (read/write channels line by line)
val async_call : ?env:string array ‑> ('a, Buffer.t, unit, async_call_result) Pervasives.format4 ‑> 'aSpawns a subprocess, like call, but the subprocess's channels are
+line generators and line sinks (for stdin).
+If p is async_call "cmd", then p#wait waits for the subprocess
+to die. Channels can be closed independently.
val with_in : ?mode:int ‑> ?flags:Unix.open_flag list ‑> string ‑> f:(Pervasives.in_channel ‑> 'a) ‑> 'aOpen 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.
Unix.O_RDONLY is used in any cases.val with_out : ?mode:int ‑> ?flags:Unix.open_flag list ‑> string ‑> f:(Pervasives.out_channel ‑> 'a) ‑> 'aSame as with_in but for an output channel.
[Unix.O_CREAT; Unix.O_TRUNC])
+Unix.O_WRONLY is used in any cases.val with_process_in : string ‑> f:(Pervasives.in_channel ‑> 'a) ‑> 'aOpen a subprocess and obtain a handle to its stdout. +
CCUnix.with_process_in "ls /tmp" ~f:CCIO.read_lines_l;;val with_process_out : string ‑> f:(Pervasives.out_channel ‑> 'a) ‑> 'aOpen a subprocess and obtain a handle to its stdin.
type process_full = < stdin : Pervasives.out_channel; stdout : Pervasives.in_channel; stderr : Pervasives.in_channel; close : Unix.process_status; >Handle to a subprocess.
val with_process_full : ?env:string array ‑> string ‑> f:(process_full ‑> 'a) ‑> 'aOpen a subprocess and obtain a handle to its channels.
val with_connection : Unix.sockaddr ‑> f:(Pervasives.in_channel ‑> Pervasives.out_channel ‑> 'a) ‑> 'aWrap Unix.open_connection with a handler.
val establish_server : Unix.sockaddr ‑> f:(Pervasives.in_channel ‑> Pervasives.out_channel ‑> _) ‑> unitListen on the address and calls the handler in a blocking fashion. +Using Thread is recommended if handlers might take time. +The callback should raise ExitServer to stop the loop.
val with_file_lock : kind:[ `Read | `Write ] ‑> string ‑> (unit ‑> 'a) ‑> 'awith_file_lock ~kind filename f puts a lock on the offset 0
+of the file named filename, calls f and returns its result after
+the file is unlocked. If f () raises an exception the exception is
+re-raised after the file is unlocked.
module Infix : sig ... endinclude module type of Infixval (?|) : ('a, Buffer.t, unit, call_result) Pervasives.format4 ‑> 'aInfix version of call.
val (?|&) : ('a, Buffer.t, unit, async_call_result) Pervasives.format4 ‑> 'aInfix version of async_call.
+This library exposes the following toplevel modules:
| CCUnix |
.
\ No newline at end of file diff --git a/dev/containers.unix/page-index.odoc b/dev/containers.unix/page-index.odoc new file mode 100644 index 00000000..f267064f Binary files /dev/null and b/dev/containers.unix/page-index.odoc differ diff --git a/dev/containers/CCArray.odoc b/dev/containers/CCArray.odoc new file mode 100644 index 00000000..56f3f332 Binary files /dev/null and b/dev/containers/CCArray.odoc differ diff --git a/dev/containers/CCArray/.jbuilder-keep b/dev/containers/CCArray/.jbuilder-keep new file mode 100644 index 00000000..e69de29b diff --git a/dev/containers/CCArray/index.html b/dev/containers/CCArray/index.html new file mode 100644 index 00000000..fa4be80e --- /dev/null +++ b/dev/containers/CCArray/index.html @@ -0,0 +1,53 @@ + +Hoist an equality test for elements to arrays. +Arrays are only equal if their lengths are the same and +corresponding elements test equal.
val get : 'a t ‑> int ‑> 'aget 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 optionget_safe a i returns Some a.(i) if i is a valid index.
val set : 'a t ‑> int ‑> 'a ‑> unitset 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 fold : ('a ‑> 'b ‑> 'a) ‑> 'a ‑> 'b t ‑> 'afold 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 fold_while : ('a ‑> 'b ‑> 'a * [ `Stop | `Continue ]) ‑> 'a ‑> 'b t ‑> 'aFold left on array until a stop condition via ('a, `Stop) is
+indicated by the accumulator.
fold_map f acc a is a fold_left-like function, but it also maps the
+array to another array.
val iter : ('a ‑> unit) ‑> 'a t ‑> unititer 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 ‑> unitLike Array.iter, but the function is applied to the index of the +element as first argument, and the element itself as second argument.
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 sorted : ('a ‑> 'a ‑> int) ‑> 'a t ‑> 'a arraysorted cmp a makes a copy of a and sorts it with cmp.
val sort_indices : ('a ‑> 'a ‑> int) ‑> 'a t ‑> int arraysort_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.
val sort_ranking : ('a ‑> 'a ‑> int) ‑> 'a t ‑> int arraysort_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).
val find_map : ('a ‑> 'b option) ‑> 'a t ‑> 'b optionfind_map f a returns Some y if there is an element x such
+that f x = Some y, else it returns None.
val find_map_i : (int ‑> 'a ‑> 'b option) ‑> 'a t ‑> 'b optionLike find_map, but also pass the index to the predicate function.
val findi : (int ‑> 'a ‑> 'b option) ‑> 'a t ‑> 'b optionAlias to find_map_i.
val find_idx : ('a ‑> bool) ‑> 'a t ‑> (int * 'a) optionfind_idx p x returns Some (i,x) where x is the i-th element of l,
+and p x holds. Otherwise returns None.
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).
None if the key is not present, or
+Some i (i the index of the key) otherwise.Like lookup, but
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.cmp.val for_all : ('a ‑> bool) ‑> 'a t ‑> boolfor_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).
Forall on pairs of arrays.
val exists : ('a ‑> bool) ‑> 'a t ‑> boolexists 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).
Exists on pairs of arrays.
val random_choose : 'a t ‑> 'a random_genChoose an element randomly.
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.
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) |].
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)|].
val except_idx : 'a t ‑> int ‑> 'a listRemove given index, obtaining the list of the other elements.
val random : 'a random_gen ‑> 'a t random_genval random_non_empty : 'a random_gen ‑> 'a t random_genval random_len : int ‑> 'a random_gen ‑> 'a t random_genmodule type MONO_ARRAY : sig ... endval sort_generic : (module MONO_ARRAY with type elt = 'elt and type t = 'arr) ‑> cmp:('elt ‑> 'elt ‑> int) ‑> 'arr ‑> unitSort the array, without allocating (eats stack space though). Performance +might be lower than Array.sort.
val length : t ‑> intHoist an equality test for elements to arrays. +Arrays are only equal if their lengths are the same and +corresponding elements test equal.
val get : 'a t ‑> int ‑> 'aget 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 optionget_safe a i returns Some a.(i) if i is a valid index.
val set : 'a t ‑> int ‑> 'a ‑> unitset 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 fold : f:('a ‑> 'b ‑> 'a) ‑> init:'a ‑> 'b t ‑> 'afold 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 fold_while : f:('a ‑> 'b ‑> 'a * [ `Stop | `Continue ]) ‑> init:'a ‑> 'b t ‑> 'aFold left on array until a stop condition via ('a, `Stop) is
+indicated by the accumulator.
fold_map f acc a is a fold_left-like function, but it also maps the
+array to another array.
val iter : f:('a ‑> unit) ‑> 'a t ‑> unititer 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 ‑> unitLike Array.iter, but the function is applied to the index of the +element as first argument, and the element itself as second argument.
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 sorted : f:('a ‑> 'a ‑> int) ‑> 'a t ‑> 'a arraysorted cmp a makes a copy of a and sorts it with cmp.
val sort_indices : f:('a ‑> 'a ‑> int) ‑> 'a t ‑> int arraysort_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.
val sort_ranking : f:('a ‑> 'a ‑> int) ‑> 'a t ‑> int arraysort_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).
val find_map : f:('a ‑> 'b option) ‑> 'a t ‑> 'b optionfind_map f a returns Some y if there is an element x such
+that f x = Some y, else it returns None.
val find : f:('a ‑> 'b option) ‑> 'a t ‑> 'b optionfind f a returns Some y if there is an element x such
+that f x = Some y, else it returns None.
val find_map_i : f:(int ‑> 'a ‑> 'b option) ‑> 'a t ‑> 'b optionLike find_map, but also pass the index to the predicate function.
val findi : f:(int ‑> 'a ‑> 'b option) ‑> 'a t ‑> 'b optionLike find, but also pass the index to the predicate function.
val find_idx : f:('a ‑> bool) ‑> 'a t ‑> (int * 'a) optionfind_idx p x returns Some (i,x) where x is the i-th element of l,
+and p x holds. Otherwise returns None.
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).
None if the key is not present, or
+Some i (i the index of the key) otherwise.Like lookup, but
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.cmp.val for_all : f:('a ‑> bool) ‑> 'a t ‑> boolfor_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).
Forall on pairs of arrays.
val exists : f:('a ‑> bool) ‑> 'a t ‑> boolexists 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).
Exists on pairs of arrays.
val random_choose : 'a t ‑> 'a random_genChoose an element randomly.
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) |].
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)|].
val except_idx : 'a t ‑> int ‑> 'a listRemove given index, obtaining the list of the other elements.
val random : 'a random_gen ‑> 'a t random_genval random_non_empty : 'a random_gen ‑> 'a t random_genval random_len : int ‑> 'a random_gen ‑> 'a t random_genmodule type MONO_ARRAY : sig ... endval sort_generic : (module MONO_ARRAY with type elt = 'elt and type t = 'arr) ‑> cmp:('elt ‑> 'elt ‑> int) ‑> 'arr ‑> unitSort the array, without allocating (eats stack space though). Performance +might be lower than Array.sort.
val length : t ‑> intval get : 'a t ‑> int ‑> 'aget 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 optionget_safe a i returns Some a.(i) if i is a valid index.
val make : 'a array ‑> int ‑> len:int ‑> 'a tCreate a slice from given offset and length.
val of_slice : ('a array * int * int) ‑> 'a tMake 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.
val to_slice : 'a t ‑> 'a array * int * intConvert into a triple (arr, i, len) where len is the length of
+the sub-array of arr starting at offset i.
val underlying : 'a t ‑> 'a arrayUnderlying array (shared). Modifying this array will modify the slice.
val set : 'a t ‑> int ‑> 'a ‑> unitset 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 fold : ('a ‑> 'b ‑> 'a) ‑> 'a ‑> 'b t ‑> 'afold 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 fold_while : ('a ‑> 'b ‑> 'a * [ `Stop | `Continue ]) ‑> 'a ‑> 'b t ‑> 'aFold left on array until a stop condition via ('a, `Stop) is
+indicated by the accumulator.
val iter : ('a ‑> unit) ‑> 'a t ‑> unititer 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 ‑> unitLike Array.iter, but the +function is applied with the index of the element as first argument, +and the element itself as second argument.
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 sorted : ('a ‑> 'a ‑> int) ‑> 'a t ‑> 'a arraysorted cmp a makes a copy of a and sorts it with cmp.
val sort_indices : ('a ‑> 'a ‑> int) ‑> 'a t ‑> int arraysort_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.
val sort_ranking : ('a ‑> 'a ‑> int) ‑> 'a t ‑> int arraysort_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).
val find : ('a ‑> 'b option) ‑> 'a t ‑> 'b optionfind 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 optionLike find, but also pass the index to the predicate function.
val find_idx : ('a ‑> bool) ‑> 'a t ‑> (int * 'a) optionfind_idx p x returns Some (i,x) where x is the i-th element of l,
+and p x holds. Otherwise returns None.
Lookup the index of some value in a sorted array.
None if the key is not present, or
+Some i (i the index of the key) otherwise.Like lookup, but
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.cmp.val for_all : ('a ‑> bool) ‑> 'a t ‑> boolfor_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).
Forall on pairs of arrays.
val exists : ('a ‑> bool) ‑> 'a t ‑> boolexists 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).
Exists on pairs of arrays.
val random_choose : 'a t ‑> 'a random_genChoose an element randomly.
include module type of sig ... endThe 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.
Convert the given character to its equivalent lowercase character, +using the US-ASCII character set.
Convert the given character to its equivalent uppercase character, +using the US-ASCII character set.
val of_int_exn : int ‑> tAlias to Char.chr. +Return the character with the given ASCII code.
0,...,255.val int : int tval string : string tval bool : bool tval float : float tval unit : unit tmap 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 ... endval epsilon : tThe smallest positive float x such that 1.0 +. x <> 1.0.
+Equal to Pervasives.epsilon_float.
val hash : t ‑> intval random : t ‑> t random_genval random_small : t random_genval random_range : t ‑> t ‑> t random_genval sign_exn : t ‑> intsign_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.
val to_string : t ‑> stringval of_string_exn : string ‑> tAlias to float_of_string.
val of_string : string ‑> tAlias to float_of_string.
Return the class of the given floating-point number: +normal, subnormal, zero, infinite or nan (not a number).
module Infix : sig ... endinclude module type of Infixval unit : unit tval int : int tval string : string tval bool : bool tval float : float tval char : char tval int32 : int32 tval int64 : int64 tval nativeint : nativeint tinclude module type of sig ... endval pp_open_box : formatter ‑> int ‑> unitval pp_close_box : formatter ‑> unit ‑> unitval pp_open_hbox : formatter ‑> unit ‑> unitval pp_open_vbox : formatter ‑> int ‑> unitval pp_open_hvbox : formatter ‑> int ‑> unitval pp_open_hovbox : formatter ‑> int ‑> unitval pp_print_string : formatter ‑> string ‑> unitval pp_print_as : formatter ‑> int ‑> string ‑> unitval pp_print_int : formatter ‑> int ‑> unitval pp_print_float : formatter ‑> float ‑> unitval pp_print_char : formatter ‑> char ‑> unitval pp_print_bool : formatter ‑> bool ‑> unitval pp_print_space : formatter ‑> unit ‑> unitval pp_print_cut : formatter ‑> unit ‑> unitval pp_print_break : formatter ‑> int ‑> int ‑> unitval pp_force_newline : formatter ‑> unit ‑> unitval pp_print_if_newline : formatter ‑> unit ‑> unitval pp_print_flush : formatter ‑> unit ‑> unitval pp_print_newline : formatter ‑> unit ‑> unitval pp_set_margin : formatter ‑> int ‑> unitval pp_get_margin : formatter ‑> unit ‑> intval pp_set_max_indent : formatter ‑> int ‑> unitval pp_get_max_indent : formatter ‑> unit ‑> intval pp_set_max_boxes : formatter ‑> int ‑> unitval pp_get_max_boxes : formatter ‑> unit ‑> intval pp_over_max_boxes : formatter ‑> unit ‑> boolval pp_open_tbox : formatter ‑> unit ‑> unitval pp_close_tbox : formatter ‑> unit ‑> unitval pp_set_tab : formatter ‑> unit ‑> unitval pp_print_tab : formatter ‑> unit ‑> unitval pp_print_tbreak : formatter ‑> int ‑> int ‑> unitval pp_set_ellipsis_text : formatter ‑> string ‑> unitval pp_get_ellipsis_text : formatter ‑> unit ‑> stringval pp_open_tag : formatter ‑> string ‑> unitval open_tag : tag ‑> unitval pp_close_tag : formatter ‑> unit ‑> unitval pp_set_tags : formatter ‑> bool ‑> unitval pp_set_print_tags : formatter ‑> bool ‑> unitval pp_set_mark_tags : formatter ‑> bool ‑> unitval pp_get_print_tags : formatter ‑> unit ‑> boolval pp_get_mark_tags : formatter ‑> unit ‑> boolval pp_set_formatter_out_channel : formatter ‑> Pervasives.out_channel ‑> unitval pp_set_formatter_output_functions : formatter ‑> (string ‑> int ‑> int ‑> unit) ‑> (unit ‑> unit) ‑> unitval pp_get_formatter_output_functions : formatter ‑> unit ‑> (string ‑> int ‑> int ‑> unit) * (unit ‑> unit)val pp_set_formatter_out_functions : formatter ‑> formatter_out_functions ‑> unitval set_formatter_out_functions : formatter_out_functions ‑> unitval pp_get_formatter_out_functions : formatter ‑> unit ‑> formatter_out_functionsval get_formatter_out_functions : unit ‑> formatter_out_functionsval pp_set_formatter_tag_functions : formatter ‑> formatter_tag_functions ‑> unitval set_formatter_tag_functions : formatter_tag_functions ‑> unitval pp_get_formatter_tag_functions : formatter ‑> unit ‑> formatter_tag_functionsval get_formatter_tag_functions : unit ‑> formatter_tag_functionsval formatter_of_out_channel : Pervasives.out_channel ‑> formatterval std_formatter : formatterval err_formatter : formatterval formatter_of_buffer : Buffer.t ‑> formatterval str_formatter : formatterval make_formatter : (string ‑> int ‑> int ‑> unit) ‑> (unit ‑> unit) ‑> formatterval formatter_of_out_functions : formatter_out_functions ‑> formatterval make_symbolic_output_buffer : unit ‑> symbolic_output_bufferval clear_symbolic_output_buffer : symbolic_output_buffer ‑> unitval get_symbolic_output_buffer : symbolic_output_buffer ‑> symbolic_output_item listval flush_symbolic_output_buffer : symbolic_output_buffer ‑> symbolic_output_item listval add_symbolic_output_item : symbolic_output_buffer ‑> symbolic_output_item ‑> unitval formatter_of_symbolic_output_buffer : symbolic_output_buffer ‑> formatterval pp_print_text : formatter ‑> string ‑> unitval printf : ('a, formatter, unit) Pervasives.format ‑> 'aval eprintf : ('a, formatter, unit) Pervasives.format ‑> 'aval asprintf : ('a, formatter, unit, string) Pervasives.format4 ‑> 'aval kasprintf : (string ‑> 'a) ‑> ('b, formatter, unit, 'a) Pervasives.format4 ‑> 'bval bprintf : Buffer.t ‑> ('a, formatter, unit) Pervasives.format ‑> 'aval kprintf : (string ‑> 'a) ‑> ('b, unit, string, 'a) Pervasives.format4 ‑> 'bval set_all_formatter_output_functions : out:(string ‑> int ‑> int ‑> unit) ‑> flush:(unit ‑> unit) ‑> newline:(unit ‑> unit) ‑> spaces:(int ‑> unit) ‑> unitval 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) ‑> unitval pp_get_all_formatter_output_functions : formatter ‑> unit ‑> (string ‑> int ‑> int ‑> unit) * (unit ‑> unit) * (unit ‑> unit) * (int ‑> unit)val int : int printerval string : string printerval bool : bool printerval float3 : float printerval float : float printerval substring : (string * int * int) printerPrint the substring (s,i,len), where i is the offset
+in s and len the number of bytes in the substring.
(s,i,len) does not
+describe a proper substring.val text : string printerPrint string, but replacing spaces with breaks and newlines
+with newline.
+See pp_print_text on recent versions of OCaml.
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.
within a b p wraps p inside the strings a and b. Convenient,
+for instances, for brackets, parenthesis, quotes, etc.
Wrap the printer in a vertical box.
Wrap the printer in a horizontal/vertical box.
Wrap the printer in a horizontal or vertical box.
val return : ('a, _, _, 'a) Pervasives.format4 ‑> unit printerreturn "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@]"val of_to_string : ('a ‑> string) ‑> 'a printerof_to_string f converts its input to a string using f,
+then prints the string.
some pp will print options as follows:
+
Some x is printed using pp on xNone is not printed at alllazy_or ?default pp out x prints default if x is not
+evaluated yet, or uses pp otherwise.
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;;
+
+ Format.printf
+ "what is your @{<White>favorite color@}? @{<blue>blue@}! No, @{<red>red@}! Ahhhhhhh@.";;status: unstable
val set_color_tag_handling : t ‑> unitAdd functions to support color tags to the given formatter.
val set_color_default : bool ‑> unitset_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.
with_color "Blue" pp behaves like the printer pp, but with the given
+style.
status: unstable
with_colorf "Blue" out "%s %d" "yolo" 42 will behave like Format.fprintf,
+but wrapping the content with the given style.
status: unstable
val with_color_sf : string ‑> ('a, t, unit, string) Pervasives.format4 ‑> 'awith_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
val with_color_ksf : f:(string ‑> 'b) ‑> string ‑> ('a, t, unit, 'b) Pervasives.format4 ‑> 'awith_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];;val to_string : 'a printer ‑> 'a ‑> stringval with_out_chan : Pervasives.out_channel ‑> (t ‑> 'a) ‑> 'awith_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.
val stdout : tval stderr : tval sprintf : ('a, t, unit, string) Pervasives.format4 ‑> 'aPrint into a string any format string that would usually be compatible +with fprintf. Like Format.asprintf.
val sprintf_no_color : ('a, t, unit, string) Pervasives.format4 ‑> 'aLike sprintf but never prints colors.
val sprintf_dyn_color : colors:bool ‑> ('a, t, unit, string) Pervasives.format4 ‑> 'aLike 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;;Like fprintf but enable/disable colors depending on colors.
val ksprintf : ?margin:int ‑> f:(string ‑> 'b) ‑> ('a, Format.formatter, unit, 'b) Pervasives.format4 ‑> 'aksprintf fmt ~f formats using fmt, in a way similar to sprintf,
+and then calls f on the resulting string.
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] |];;module Dump : sig ... endX : sig ... endval compose_binop : ('a ‑> 'b) ‑> ('b ‑> 'b ‑> 'c) ‑> 'a ‑> 'a ‑> 'ccompose_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].
val const : 'a ‑> 'b ‑> 'aProduce a function that just returns its first argument.
+const x y = x for any y.
val curry : (('a * 'b) ‑> 'c) ‑> 'a ‑> 'b ‑> 'cConvert 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) ‑> 'cConvert 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 ‑> 'atap 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.compareval lexicographic : ('a ‑> 'a ‑> int) ‑> ('a ‑> 'a ‑> int) ‑> 'a ‑> 'a ‑> intLexicographic combination of comparison functions.
val finally : h:(unit ‑> _) ‑> f:(unit ‑> 'a) ‑> 'afinally 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 ‑> 'bfinally1 ~h f x is the same as f x, but after the computation,
+h () is called whether f x rose an exception or not.
val finally2 : h:(unit ‑> _) ‑> ('a ‑> 'b ‑> 'c) ‑> 'a ‑> 'b ‑> 'cfinally2 ~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.
val opaque_identity : 'a ‑> 'aopaque_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).
val iterate : int ‑> ('a ‑> 'a) ‑> 'a ‑> 'aiterate 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.
Functions with a fixed domain are monads in their codomain.
\ No newline at end of file diff --git a/dev/containers/CCHash.odoc b/dev/containers/CCHash.odoc new file mode 100644 index 00000000..d9dad901 Binary files /dev/null and b/dev/containers/CCHash.odoc differ diff --git a/dev/containers/CCHash/.jbuilder-keep b/dev/containers/CCHash/.jbuilder-keep new file mode 100644 index 00000000..e69de29b diff --git a/dev/containers/CCHash/index.html b/dev/containers/CCHash/index.html new file mode 100644 index 00000000..149af87c --- /dev/null +++ b/dev/containers/CCHash/index.html @@ -0,0 +1,8 @@ + +val const0 : _ tAlways 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).
val int : int tval bool : bool tval char : char tval int32 : int32 tval int64 : int64 tval nativeint : nativeint tval slice : string ‑> int ‑> int tslice s i len state hashes the slice i, ... i+len-1 of s
+into state.
val string : string tCommutative version of list. Lists that are equal up to permutation +will have the same hash.
Commutative version of array. Arrays that are equal up to permutation +will have the same hash.
val get_or : ('a, 'b) Hashtbl.t ‑> 'a ‑> default:'b ‑> 'bget_or tbl k ~default returns the value associated to k if present,
+and returns default otherwise (if k doesn't belong in tbl).
val keys_list : ('a, 'b) Hashtbl.t ‑> 'a listkeys_list t is the list of keys in t.
+If the key is in the Hashtable multiple times, all occurrences will be returned.
val map_list : ('a ‑> 'b ‑> 'c) ‑> ('a, 'b) Hashtbl.t ‑> 'c listMap on a hashtable's items, collect into a list.
val incr : ?by:int ‑> ('a, int) Hashtbl.t ‑> 'a ‑> unitincr ?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).
by rather than 1.val decr : ?by:int ‑> ('a, int) Hashtbl.t ‑> 'a ‑> unitLike 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.
val add_list : ('a, 'b list) Hashtbl.t ‑> 'a ‑> 'b ‑> unitadd_list tbl x y adds y to the list x is bound to. If x is
+not bound, it becomes bound to y.
val add_seq : ('a, 'b) Hashtbl.t ‑> ('a * 'b) sequence ‑> unitAdd the corresponding pairs to the table, using Hashtbl.add.
val add_seq_count : ('a, int) Hashtbl.t ‑> 'a sequence ‑> unitadd_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.
val of_seq_count : 'a sequence ‑> ('a, int) Hashtbl.tLike add_seq_count, but allocates a new table and returns it.
val of_list : ('a * 'b) list ‑> ('a, 'b) Hashtbl.tBuild 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 ‑> unitupdate 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.
val get_or_add : ('a, 'b) Hashtbl.t ‑> f:('a ‑> 'b) ‑> k:'a ‑> 'bget_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.
This sub-module contains the extension of the standard polymorphic Hashtbl.
module Poly : sig ... endinclude module type of Polyval get_or : ('a, 'b) Hashtbl.t ‑> 'a ‑> default:'b ‑> 'bget_or tbl k ~default returns the value associated to k if present,
+and returns default otherwise (if k doesn't belong in tbl).
val keys_list : ('a, 'b) Hashtbl.t ‑> 'a listkeys_list t is the list of keys in t.
+If the key is in the Hashtable multiple times, all occurrences will be returned.
val map_list : ('a ‑> 'b ‑> 'c) ‑> ('a, 'b) Hashtbl.t ‑> 'c listMap on a hashtable's items, collect into a list.
val incr : ?by:int ‑> ('a, int) Hashtbl.t ‑> 'a ‑> unitincr ?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).
by rather than 1.val decr : ?by:int ‑> ('a, int) Hashtbl.t ‑> 'a ‑> unitLike 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.
val add_list : ('a, 'b list) Hashtbl.t ‑> 'a ‑> 'b ‑> unitadd_list tbl x y adds y to the list x is bound to. If x is
+not bound, it becomes bound to y.
val add_seq : ('a, 'b) Hashtbl.t ‑> ('a * 'b) sequence ‑> unitAdd the corresponding pairs to the table, using Hashtbl.add.
val add_seq_count : ('a, int) Hashtbl.t ‑> 'a sequence ‑> unitadd_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.
val of_seq_count : 'a sequence ‑> ('a, int) Hashtbl.tLike add_seq_count, but allocates a new table and returns it.
val of_list : ('a * 'b) list ‑> ('a, 'b) Hashtbl.tBuild 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 ‑> unitupdate 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.
module type S : sig ... endget_or tbl k ~default returns the value associated to k if present,
+and returns default otherwise (if k doesn't belong in tbl).
add_list tbl x y adds y to the list x is bound to. If x is
+not bound, it becomes bound to y.
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).
by rather than 1.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.
keys_list t is the list of keys in t.
+If the key is in the Hashtable multiple times, all occurrences will be returned.
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.
Like add_seq_count, but allocates a new table and returns it.
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.
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.
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.
E : PARTIAL_ORDExtract and return the minimum element, and the new heap (without
+this element), or None if the heap is empty.
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.
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.
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).
Add the elements of the list to the heap. An element occurring several +times will be added that many times to the heap.
following Okasaki
module type PARTIAL_ORD : sig ... endmodule type S : sig ... endExtract and return the minimum element, and the new heap (without
+this element), or None if the heap is empty.
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.
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.
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).
Add the elements of the list to the heap. An element occurring several +times will be added that many times to the heap.
type t = stringA file should be represented by its absolute path, but currently +this is not enforced.
val to_string : t ‑> stringval exists : t ‑> boolval is_directory : t ‑> boolval remove_exn : t ‑> unitremove_exn path tries to remove the file at path from the
+file system.
path or access rights are wrong.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).
false), sub-directories are also
+explored.val read_exn : t ‑> stringRead the content of the given file, or raises some exception.
val append_exn : t ‑> string ‑> unitAppend the given string into the given file, possibly raising.
val write_exn : t ‑> string ‑> unitWrite the given string into the given file, possibly raising.
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.)
Like walk but returns a list (therefore it's eager and might +take some time on large directories).
val show_walk_item : walk_item ‑> stringval with_temp : ?temp_dir:string ‑> prefix:string ‑> suffix:string ‑> (string ‑> 'a) ‑> 'awith_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.
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
+ )
+ )
+ ) ;;val with_in : ?mode:int ‑> ?flags:Pervasives.open_flag list ‑> string ‑> (Pervasives.in_channel ‑> 'a) ‑> 'aOpen 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.
[Open_text]). Open_rdonly is used in any cases.val read_chunks : ?size:int ‑> Pervasives.in_channel ‑> string genRead the channel's content into chunks of size size.
val read_line : Pervasives.in_channel ‑> string optionRead 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 genRead all lines. The generator should be traversed only once.
val read_all : ?size:int ‑> Pervasives.in_channel ‑> stringRead the whole channel into a buffer, then converted into a string.
val read_all_bytes : ?size:int ‑> Pervasives.in_channel ‑> Bytes.tRead the whole channel into a mutable byte array.
val with_out : ?mode:int ‑> ?flags:Pervasives.open_flag list ‑> string ‑> (Pervasives.out_channel ‑> 'a) ‑> 'aLike with_in but for an output channel.
[Open_creat; Open_trunc; Open_text]).Open_wronly is used in any cases.val with_out_a : ?mode:int ‑> ?flags:Pervasives.open_flag list ‑> string ‑> (Pervasives.out_channel ‑> 'a) ‑> 'aLike with_out but with the [Open_append; Open_creat; Open_wronly]
+flags activated, to append to the file.
val write_line : Pervasives.out_channel ‑> string ‑> unitWrite the given string on the channel, followed by "\n".
val write_gen : ?sep:string ‑> Pervasives.out_channel ‑> string gen ‑> unitWrite 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 ‑> unitWrite every string on the output, followed by "\n".
val with_in_out : ?mode:int ‑> ?flags:Pervasives.open_flag list ‑> string ‑> (Pervasives.in_channel ‑> Pervasives.out_channel ‑> 'a) ‑> 'atee funs gen behaves like gen, but each element is given to
+every function f in funs at the time the element is produced.
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 ... endval hash : t ‑> intpow 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.
floor_div a n is integer division rounding towards negative infinity.
+It satisfies a = m * floor_div a n + rem a n.
val random : int ‑> t random_genval random_small : t random_genval random_range : int ‑> int ‑> t random_genval to_string : t ‑> stringReturn the string representation of its argument, in signed decimal.
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.
step=0.range i j iterates on integers from i to j included . It works
+both for decreasing and increasing ranges.
Like range but the second bound is excluded.
+For instance range' 0 5 = Sequence.of_list [0;1;2;3;4].
module Infix : sig ... endinclude module type of InfixHelpers 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.
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.(/).
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.
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.
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.
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 ... endval to_int : t ‑> intConvert 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_float : float ‑> tAlias 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 of_string_exn : string ‑> tAlias 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 optionSafe version of of_string_exn.
+Like of_string_exn, but return None instead of raising.
Infix operators
Helpers for 64-bit integers
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.(/).
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.
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.
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.
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 to_int : t ‑> intConvert 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 ‑> tAlias to Int64.of_int. +NOTE: used to return an option, but the function actually never fails.
val to_int32 : t ‑> int32Convert 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 ‑> tAlias to Int64.of_int32. +NOTE: use to return an option, but the function actually never fails.
val to_nativeint : t ‑> nativeintConvert 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 ‑> tAlias to Int64.of_nativeint. +NOTE: use to return an option, but the function actually never fails.
val of_float : float ‑> tAlias 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_string_exn : string ‑> tAlias 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.
val get_exn : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> ('a, 'b) t ‑> 'bLike get, but unsafe.
val mem : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> ('a, _) t ‑> boolmem x l returns true iff x is a key in l.
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'.
val push : 'a t ‑> 'a ‑> unitval pop : 'a t ‑> 'a optionval push_list : 'a t ‑> 'a list ‑> unitAdd 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.
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).
include module type of ListSafe 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 ‑> 'bSafe 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 ‑> 'aFold until a stop condition via ('a, `Stop) is
+indicated by the accumulator.
val fold_map : ('acc ‑> 'a ‑> 'acc * 'b) ‑> 'acc ‑> 'a list ‑> 'acc * 'b listfold_map f acc l is a fold_left-like function, but it also maps the
+list to another list.
val scan_left : ('acc ‑> 'a ‑> 'acc) ‑> 'acc ‑> 'a list ‑> 'acc listscan_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.
val fold_map2 : ('acc ‑> 'a ‑> 'b ‑> 'acc * 'c) ‑> 'acc ‑> 'a list ‑> 'b list ‑> 'acc * 'c listfold_map2 is to fold_map what List.map2 is to List.map.
val fold_filter_map : ('acc ‑> 'a ‑> 'acc * 'b option) ‑> 'acc ‑> 'a list ‑> 'acc * 'b listfold_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.
val fold_flat_map : ('acc ‑> 'a ‑> 'acc * 'b list) ‑> 'acc ‑> 'a list ‑> 'acc * 'b listfold_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.
val count : ('a ‑> bool) ‑> 'a list ‑> intcount f l counts how much elements of l comply with the function f.
val init : int ‑> (int ‑> 'a) ‑> 'a tinit len f is f 0; f 1; ...; f (len-1).
val combine : 'a list ‑> 'b list ‑> ('a * 'b) listLike 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)].
val combine_gen : 'a list ‑> 'b list ‑> ('a * 'b) genA 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]).
Equivalent to compare (length l1) (length l2) but more efficient.
+Compare the lengths of two lists.
val compare_length_with : 'a t ‑> int ‑> intEquivalent to compare (length l) x but more efficient.
+Compare the length of a list to an integer.
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.
val map_product_l : ('a ‑> 'b list) ‑> 'a list ‑> 'b list listmap_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.
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 listpartition_map f l maps f on l and gather results in lists:
+
f x = `Left y, adds y to the first list.f x = `Right z, adds z to the second list.f x = `Drop, ignores x.val sublists_of_len : ?last:('a list ‑> 'a list option) ‑> ?offset:int ‑> int ‑> 'a list ‑> 'a list listsublists_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]].n. If offset < n, the sub-lists
+will overlap; if offset > n, some elements will not appear at all.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.offset <= 0 or n <= 0.val intersperse : 'a ‑> 'a list ‑> 'a listInsert the first argument between every element of the list
val interleave : 'a list ‑> 'a list ‑> 'a listinterleave [x1…xn] [y1…ym] is x1,y1,x2,y2,… and finishes with
+the suffix of the longest list
val find_pred : ('a ‑> bool) ‑> 'a t ‑> 'a optionfind_pred p l finds the first element of l that satisfies p,
+or returns None if no element satisfies p.
val find_pred_exn : ('a ‑> bool) ‑> 'a t ‑> 'aUnsafe version of find_pred.
val find_map : ('a ‑> 'b option) ‑> 'a t ‑> 'b optionfind_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.
val find_mapi : (int ‑> 'a ‑> 'b option) ‑> 'a t ‑> 'b optionLike find_map, but also pass the index to the predicate function.
val find_idx : ('a ‑> bool) ‑> 'a t ‑> (int * 'a) optionfind_idx p x returns Some (i,x) where x is the i-th element of l,
+and p x holds. Otherwise returns None.
remove ~x l removes every instance of x from l. Tail-recursive.
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.
all_some l returns Some l' if all elements of l are of the form Some x,
+or None otherwise.
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).
val sorted_merge : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a list ‑> 'a listMerge elements from both sorted list.
val sort_uniq : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a listSort the list and remove duplicate elements.
val sorted_merge_uniq : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a list ‑> 'a listsorted_merge_uniq l1 l2 merges the sorted lists l1 and l2 and
+removes duplicates.
val is_sorted : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> boolis_sorted l returns true iff l is sorted (according to given order).
Pervasives.compare).val sorted_insert : cmp:('a ‑> 'a ‑> int) ‑> ?uniq:bool ‑> 'a ‑> 'a list ‑> 'a listsorted_insert x l inserts x into l such that, if l was sorted,
+then sorted_insert x l is sorted too.
x is already in sorted position in l, then
+x is not duplicated. Default false (x will be inserted in any case).val uniq_succ : eq:('a ‑> 'a ‑> bool) ‑> 'a list ‑> 'a listuniq_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].
val group_succ : eq:('a ‑> 'a ‑> bool) ‑> 'a list ‑> 'a list listgroup_succ ~eq l groups together consecutive elements that are equal
+according to eq.
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 ‑> unitLike 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 : ('b ‑> int ‑> 'a ‑> 'b) ‑> 'b ‑> 'a t ‑> 'bLike fold but it also passes in the index of each element to the folded function. Tail-recursive.
Fold on two lists, with index.
val get_at_idx : int ‑> 'a t ‑> 'a optionGet 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 optionSafe version of nth.
val get_at_idx_exn : int ‑> 'a t ‑> 'aGet the i-th element, or
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.
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.
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.
Those operations maintain the invariant that the list does not +contain duplicates (if it already satisfies it).
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 range_by : step:int ‑> int ‑> int ‑> int trange_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.
step=0.val range : int ‑> int ‑> int trange i j iterates on integers from i to j included. It works
+both for decreasing and increasing ranges.
val range' : int ‑> int ‑> int tLike range but the second bound is excluded.
+For instance range' 0 5 = [0;1;2;3;4].
module Assoc : sig ... endmodule Ref : sig ... endval random : 'a random_gen ‑> 'a t random_genval random_non_empty : 'a random_gen ‑> 'a t random_genval random_len : int ‑> 'a random_gen ‑> 'a t random_genval random_choose : 'a t ‑> 'a random_genRandomly choose an element in the list.
val random_sequence : 'a random_gen t ‑> 'a t random_genBuild a list from a given sequence.
+In the result, elements appear in the same order as they did in the source sequence.
Build a list from a given gen.
+In the result, elements appear in the same order as they did in the source gen.
Build a list from a given klist.
+In the result, elements appear in the same order as they did in the source klist.
+It is convenient to open CCList.Infix to access the infix operators +without cluttering the scope too much.
module Infix : sig ... endval get_exn : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> ('a, 'b) t ‑> 'bLike get, but unsafe.
val mem : eq:('a ‑> 'a ‑> bool) ‑> 'a ‑> ('a, _) t ‑> boolmem x l returns true iff x is a key in l.
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'.
val push : 'a t ‑> 'a ‑> unitval pop : 'a t ‑> 'a optionval push_list : 'a t ‑> 'a list ‑> unitAdd 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.
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).
include module type of ListLabelsSafe 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 ‑> 'bSafe 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 ‑> 'aFold until a stop condition via ('a, `Stop) is
+indicated by the accumulator.
val fold_map : f:('acc ‑> 'a ‑> 'acc * 'b) ‑> init:'acc ‑> 'a list ‑> 'acc * 'b listfold_map ~f ~init l is a fold_left-like function, but it also maps the
+list to another list.
val fold_map2 : f:('acc ‑> 'a ‑> 'b ‑> 'acc * 'c) ‑> init:'acc ‑> 'a list ‑> 'b list ‑> 'acc * 'c listfold_map2 is to fold_map what List.map2 is to List.map.
val fold_filter_map : f:('acc ‑> 'a ‑> 'acc * 'b option) ‑> init:'acc ‑> 'a list ‑> 'acc * 'b listfold_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.
val fold_flat_map : f:('acc ‑> 'a ‑> 'acc * 'b list) ‑> init:'acc ‑> 'a list ‑> 'acc * 'b listfold_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.
val init : int ‑> f:(int ‑> 'a) ‑> 'a tinit len ~f is f 0; f 1; ...; f (len-1).
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 listpartition_map ~f l maps f on l and gather results in lists:
+
f x = `Left y, adds y to the first list.f x = `Right z, adds z to the second list.f x = `Drop, ignores x.val sublists_of_len : ?last:('a list ‑> 'a list option) ‑> ?offset:int ‑> len:int ‑> 'a list ‑> 'a list listsublists_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.
val find_pred : f:('a ‑> bool) ‑> 'a t ‑> 'a optionfind_pred p l finds the first element of l that satisfies p,
+or returns None if no element satisfies p.
val find_pred_exn : f:('a ‑> bool) ‑> 'a t ‑> 'aUnsafe version of find_pred.
val find_map : f:('a ‑> 'b option) ‑> 'a t ‑> 'b optionfind_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.
val find_mapi : f:(int ‑> 'a ‑> 'b option) ‑> 'a t ‑> 'b optionLike find_map, but also pass the index to the predicate function.
val find_idx : f:('a ‑> bool) ‑> 'a t ‑> (int * 'a) optionfind_idx p x returns Some (i,x) where x is the i-th element of l,
+and p x holds. Otherwise returns None.
remove ~key l removes every instance of key from l. Tail-recursive.
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 listMerges elements from both sorted list.
val sort_uniq : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a listSort the list and remove duplicate elements.
val sorted_merge_uniq : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a list ‑> 'a listsorted_merge_uniq l1 l2 merges the sorted lists l1 and l2 and
+removes duplicates.
val is_sorted : cmp:('a ‑> 'a ‑> int) ‑> 'a list ‑> boolis_sorted l returns true iff l is sorted (according to given order).
Pervasives.compare).val sorted_insert : cmp:('a ‑> 'a ‑> int) ‑> ?uniq:bool ‑> 'a ‑> 'a list ‑> 'a listsorted_insert x l inserts x into l such that, if l was sorted,
+then sorted_insert x l is sorted too.
x is already in sorted position in l, then
+x is not duplicated. Default false (x will be inserted in any case).val uniq_succ : eq:('a ‑> 'a ‑> bool) ‑> 'a list ‑> 'a listuniq_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].
val group_succ : eq:('a ‑> 'a ‑> bool) ‑> 'a list ‑> 'a list listgroup_succ ~eq l groups together consecutive elements that are equal
+according to eq.
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 ‑> unitLike 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 ‑> 'bLike 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 optionGet 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 ‑> 'aGet the i-th element, or
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.
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.
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.
Those operations maintain the invariant that the list does not +contain duplicates (if it already satisfies it).
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 range_by : step:int ‑> int ‑> int ‑> int trange_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.
step=0.val range : int ‑> int ‑> int trange i j iterates on integers from i to j included. It works
+both for decreasing and increasing ranges.
val range' : int ‑> int ‑> int tLike range but the second bound is excluded.
+For instance range' 0 5 = [0;1;2;3;4].
module Assoc : sig ... endmodule Ref : sig ... endval random : 'a random_gen ‑> 'a t random_genval random_non_empty : 'a random_gen ‑> 'a t random_genval random_len : int ‑> 'a random_gen ‑> 'a t random_genval random_choose : 'a t ‑> 'a random_genRandomly choose an element in the list.
val random_sequence : 'a random_gen t ‑> 'a t random_gen+It is convenient to open CCList.Infix to access the infix operators +without cluttering the scope too much.
module Infix : sig ... endProvide useful functions and iterators on Map.S
module type S : sig ... endget_or k m ~default returns the value associated to k if present,
+and returns default otherwise (if k doesn't belong in m).
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.
Safe version of find_first.
val merge_safe : f:(key ‑> [ `Left of 'a | `Right of 'b | `Both of 'a * 'b ] ‑> 'c option) ‑> 'a t ‑> 'b t ‑> 'c tmerge_safe ~f a b merges the maps a and b together.
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.
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.
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.(/).
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.
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.
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.
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 ... endval to_int : t ‑> intConvert the given native integer (type nativeint) to an
+integer (type int). The high-order bit is lost
+during the conversion.
val of_int : int ‑> tAlias to Nativeint.of_int.
+Convert the given integer (type int) to a native integer (type nativeint).
val of_float : float ‑> tAlias 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 of_string_exn : string ‑> tAlias 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 optionSafe version of of_string_exn.
+Like of_string_exn, but return None instead of raising.
val map_or : default:'b ‑> ('a ‑> 'b) ‑> 'a t ‑> 'bmap_or ~default f o is f x if o = Some x, default otherwise.
val map_lazy : (unit ‑> 'b) ‑> ('a ‑> 'b) ‑> 'a t ‑> 'bmap_lazy default_fn f o if f o if o = Some x, default_fn () otherwise.
Compare two options, using custom comparators for the value.
+None is always assumed to be less than Some _.
val exists : ('a ‑> bool) ‑> 'a t ‑> boolReturn true iff there exists an element for which the provided function evaluates to true.
val for_all : ('a ‑> bool) ‑> 'a t ‑> boolReturn true iff the provided function evaluates to true for all elements.
val get_or : default:'a ‑> 'a t ‑> 'aget_or ~default o extracts the value from o, or
+returns default if o = None.
val get_exn : 'a t ‑> 'aOpen the option, possibly failing if it is None.
None.val get_lazy : (unit ‑> 'a) ‑> 'a t ‑> 'aget_lazy default_fn x unwraps x, but if x = None it returns default_fn () instead.
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 optionwrap 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.
true if the
+exception is to be caught.val wrap2 : ?handler:(exn ‑> bool) ‑> ('a ‑> 'b ‑> 'c) ‑> 'a ‑> 'b ‑> 'c optionwrap2 f x y is similar to wrap but for binary functions.
module Infix : sig ... endval to_list : 'a t ‑> 'a listval random : 'a random_gen ‑> 'a t random_genchoice_seq s is similar to choice, but works on sequences.
+It returns the first Some x occurring in s, or None otherwise.
val (<?>) : int ‑> ('a t * 'a * 'a) ‑> intc1 <?> (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 int : int tval string : string tval bool : bool tval float : float tval (<?>) : int ‑> ('a t * 'a * 'a) ‑> intc1 <?> (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
+ <?> (string, "a", "b")
+ <?> (bool, true, false))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.
module Infix : sig ... endval map : ('a ‑> 'c) ‑> ('b ‑> 'd) ‑> ('a * 'b) ‑> 'c * 'dSynonym to ( *** ). Map on both sides of a tuple.
val map_same : ('a ‑> 'b) ‑> ('a * 'a) ‑> 'b * 'bLike map but specialized for pairs with elements of the same type.
val (&&&) : ('a ‑> 'b) ‑> ('a ‑> 'c) ‑> 'a ‑> 'b * 'cf &&& g is fun x -> f x, g x. It splits the computations into
+two parts.
val dup_map : ('a ‑> 'b) ‑> 'a ‑> 'a * 'bdup_map f x = (x, f x). Duplicates the value and applies the function
+to the second copy.
Monadic bind.
+p >>= f results in a new parser which behaves as p then,
+in case of success, applies f to the result.
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".
list p parses a list of p, with the OCaml conventions for
+start token "", stop token "" and separator ";".
+Whitespace between items are skipped.
val triple : ?start:string ‑> ?stop:string ‑> ?sep:string ‑> 'a t ‑> 'b t ‑> 'c t ‑> ('a * 'b * 'c) tParse a triple using OCaml whitespace conventions. +The default is "(a, b, c)".
open CCParse;;
+
+ type tree = L of int | N of tree * tree;;
+
+ 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) )
+ ;;
+
+ parse_string_exn ptree "(1 (2 3))" ;;
+ parse_string_exn ptree "((1 2) (3 (4 5)))" ;;
+ open Containers.Parse;;
+ let p = U.list ~sep:"," U.word;;
+ parse_string_exn p "[abc , de, hello ,world ]";;+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' = CCParse.parse_string_exn p l_printed;;
+
+ assert (l=l');;val string_of_branch : parse_branch ‑> stringval state_of_string : string ‑> stateTakes the input and two continuations: +
ok to call with the result when it's doneerr to call when the parser met an errorMonadic bind.
+p >>= f results in a new parser which behaves as p then,
+in case of success, applies f to the result.
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".
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.
Those functions have a label ~p on the parser, since 0.14.
module Infix : sig ... endThis is useful to parse OCaml-like values in a simple way.
module U : sig ... endval return : 'a ‑> 'a treturn x is the generator that always returns x.
+Example: let random_int = return 4 (* fair dice roll *).
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)
+ )Like choose but without option.
val choose_return : 'a list ‑> 'a tChoose among the list.
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.
n <= 0.val pick_list : 'a list ‑> 'a tPick an element at random from the list.
val pick_array : 'a array ‑> 'a tPick an element at random from the array.
val float_range : float ‑> float ‑> float tInclusive range. float_range a b assumes a < b.
val split : int ‑> (int * int) option tSplit a positive value n into n1,n2 where n = n1 + n2.
None if the value is too small.val split_list : int ‑> len:int ‑> int list option tSplit 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.
len <= 1.None if the value is too small.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.
10.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.
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 tRecursion combinators, for building recursive values.
+The integer generator is used to provide fuel. The sub_ generators
+should use their arguments only once!
val pure : 'a ‑> 'a tval incr_then_get : int t ‑> intincr_then_get r increments r and returns its new value, think ++ r.
val get_then_incr : int t ‑> intget_then_incr r increments r and returns its old value, think r++.
val to_list : 'a t ‑> 'a lista <*> 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.
Uses the new "result" type from OCaml 4.03.
val of_exn_trace : exn ‑> ('a, string) tof_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 ‑> 'afail_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 ‑> 'afail_fprintf format uses format to obtain an error message
+and then returns Error msg.
add_ctx msg leaves Ok x untouched, but transforms
+Error s into Error s' where s' contains the additional
+context given by msg.
val add_ctxf : ('a, Format.formatter, unit, ('b, string) t ‑> ('b, string) t) Pervasives.format4 ‑> 'aadd_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)"Like map, but also with a function that can transform +the error message in case of failure.
val get_exn : ('a, _) t ‑> 'aExtract the value x from Ok x, fails otherwise.
+You should be careful with this function, and favor other combinators
+whenever possible.
val get_or : ('a, _) t ‑> default:'a ‑> 'aget_or e ~default returns x if e = Ok x, default otherwise.
val map_or : ('a ‑> 'b) ‑> ('a, 'c) t ‑> default:'b ‑> 'bmap_or f e ~default returns f x if e = Ok x, default otherwise.
val catch : ('a, 'err) t ‑> ok:('a ‑> 'b) ‑> err:('err ‑> 'b) ‑> 'bcatch e ~ok ~err calls either ok or err depending on
+the value of e.
val fold : ok:('a ‑> 'b) ‑> error:('err ‑> 'b) ‑> ('a, 'err) t ‑> 'bfold ~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 ‑> 'afold_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.
val guard : (unit ‑> 'a) ‑> ('a, exn) tguard 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_trace : (unit ‑> 'a) ‑> ('a, string) tLike guard_str but uses of_exn_trace instead of of_exn so +that the stack trace is printed.
val wrap2 : ('a ‑> 'b ‑> 'c) ‑> 'a ‑> 'b ‑> ('c, exn) tLike guard but gives the function two arguments.
val wrap3 : ('a ‑> 'b ‑> 'c ‑> 'd) ‑> 'a ‑> 'b ‑> 'c ‑> ('d, exn) tLike guard but gives the function three arguments.
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.
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.
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.
module Infix : sig ... endchoose l selects a member of l that is a Ok _ value,
+or returns Error l otherwise, where l is the list of errors.
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 S : sig ... endval compile : string ‑> [ `Direct ] patternval rcompile : string ‑> [ `Reverse ] patternval find : ?start:int ‑> pattern:[ `Direct ] pattern ‑> string ‑> intSearch for pattern in the string, left-to-right.
val rfind : ?start:int ‑> pattern:[ `Reverse ] pattern ‑> string ‑> intSearch for pattern in the string, right-to-left.
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.
val list_ : ?drop:drop_if_empty ‑> by:string ‑> string ‑> (string * int * int) listSplit the given string along the given separator by. Should only
+be used with very small separators, otherwise
+use Containers_string.KMP.
(s,index,length) that are
+separated by by. String.sub can then be used to actually extract
+a string from the slice.by = "".val gen : ?drop:drop_if_empty ‑> by:string ‑> string ‑> (string * int * int) genval seq : ?drop:drop_if_empty ‑> by:string ‑> string ‑> (string * int * int) sequenceval klist : ?drop:drop_if_empty ‑> by:string ‑> string ‑> (string * int * int) klistThose 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 listval gen_cpy : ?drop:drop_if_empty ‑> by:string ‑> string ‑> string genval seq_cpy : ?drop:drop_if_empty ‑> by:string ‑> string ‑> string sequenceval klist_cpy : ?drop:drop_if_empty ‑> by:string ‑> string ‑> string klistval left : by:string ‑> string ‑> (string * string) optionSplit on the first occurrence of by from the leftmost part of
+the string.
val left_exn : by:string ‑> string ‑> string * stringSplit on the first occurrence of by from the leftmost part of the string.
by is not part of the string.val right : by:string ‑> string ‑> (string * string) optionSplit on the first occurrence of by from the rightmost part of
+the string.
val right_exn : by:string ‑> string ‑> string * stringSplit on the first occurrence of by from the rightmost part of the string.
by is not part of the string.val make : string ‑> int ‑> len:int ‑> tval underlying : t ‑> stringval get : t ‑> int ‑> charget s i gets the i-th element, or fails.
0 ... length - 1.Consider using Containers_string.KMP for pattern search, or Regex +libraries.
module type S : sig ... endinclude module type of sig ... endval is_empty : string ‑> boolis_empty s returns true iff s is empty (i.e. its length is 0).
val pad : ?side:[ `Left | `Right ] ‑> ?c:char ‑> int ‑> string ‑> stringpad 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.
`Left).val find : ?start:int ‑> sub:string ‑> string ‑> intFind sub in string, returns its first index or -1.
val find_all : ?start:int ‑> sub:string ‑> string ‑> int genfind_all ~sub s finds all occurrences of sub in s, even overlapping
+instances.
s.val find_all_l : ?start:int ‑> sub:string ‑> string ‑> int listfind_all_l ~sub s finds all occurrences of sub in s and returns
+them in a list.
s.val mem : ?start:int ‑> sub:string ‑> string ‑> boolmem ~sub s is true iff sub is a substring of s.
val rfind : sub:string ‑> string ‑> intFind sub in string from the right, returns its first index or -1.
+Should only be used with very small sub.
val replace : ?which:[ `Left | `Right | `All ] ‑> sub:string ‑> by:string ‑> string ‑> stringreplace ~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)sub = "".val is_sub : sub:string ‑> int ‑> string ‑> int ‑> len:int ‑> boolis_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 suffix : suf:string ‑> string ‑> boolsuffix ~suf s returns true iff suf is a suffix of s.
val chop_prefix : pre:string ‑> string ‑> string optionchop_prefix ~pre s removes pre from s if pre really is a prefix
+of s, returns None otherwise.
val chop_suffix : suf:string ‑> string ‑> string optionchop_suffix ~suf s removes suf from s if suf really is a suffix
+of s, returns None otherwise.
val lines : string ‑> string listlines s returns a list of the lines of s (splits along '\n').
val lines_gen : string ‑> string genlines_gen s returns a generator of the lines of s (splits along '\n').
val concat_gen : sep:string ‑> string gen ‑> stringconcat_gen ~sep g concatenates all strings of g, separated with sep.
val unlines : string list ‑> stringunlines l concatenates all strings of l, separated with '\n'.
val unlines_gen : string gen ‑> stringunlines_gen g concatenates all strings of g, separated with '\n'.
val set : string ‑> int ‑> char ‑> stringset s i c creates a new string which is a copy of s, except
+for index i, which becomes c.
i is an invalid index.val filter_map : (char ‑> char option) ‑> string ‑> stringfilter_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).
val filter : (char ‑> bool) ‑> string ‑> stringfilter f s discards characters not satisfying f.
val flat_map : ?sep:string ‑> (char ‑> string) ‑> string ‑> stringMap each chars to a string, then concatenates them all.
val map2 : (char ‑> char ‑> char) ‑> string ‑> string ‑> stringMap pairs of chars.
val iter2 : (char ‑> char ‑> unit) ‑> string ‑> string ‑> unitIterate on pairs of chars.
val iteri2 : (int ‑> char ‑> char ‑> unit) ‑> string ‑> string ‑> unitIterate on pairs of chars with their index.
val fold2 : ('a ‑> char ‑> char ‑> 'a) ‑> 'a ‑> string ‑> string ‑> 'aFold on pairs of chars.
val for_all2 : (char ‑> char ‑> bool) ‑> string ‑> string ‑> boolAll pairs of chars respect the predicate?
val exists2 : (char ‑> char ‑> bool) ‑> string ‑> string ‑> boolExists a pair of chars?
Those functions are deprecated in String since 4.03, so we provide +a stable alias for them even in older versions.
val equal_caseless : string ‑> string ‑> boolComparison without respect to ascii lowercase.
A relatively efficient algorithm for finding sub-strings.
module Find : sig ... endmodule Split : sig ... endval compare_versions : string ‑> string ‑> intcompare_versions a b compares version stringsa and b,
+considering that numbers are above text.
val compare_natural : string ‑> string ‑> intNatural Sort Order, comparing chunks of digits as natural numbers. +https://en.wikipedia.org/wiki/Natural_sort_order
val edit_distance : string ‑> string ‑> intEdition 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.
A contiguous part of a string
module Sub : sig ... endval blit : t ‑> int ‑> Bytes.t ‑> int ‑> int ‑> unitLike String.blit.
+Compatible with the -safe-string option.
val hash : t ‑> intval pp : Format.formatter ‑> t ‑> unitval of_string_exn : string ‑> tValidate string by checking it is valid UTF8.
val unsafe_of_string : string ‑> tConversion from a string without validating. +Upon iteration, if an invalid substring is met, Malformed will be raised.
Mutability is rw (read-write) or ro (read-only).
Create a new vector, using the given value as a filler.
Hint to the vector that it should have at least the given capacity.
capacity v = 0, used as a filler
+element for the underlying array (see create_with).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.
Shrink to the given size (remove elements above this size). +Does nothing if the parameter is bigger than the current size.
Sort the vector, returning a copy of it that is sorted +w.r.t the given ordering. The vector itself is unchanged.
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 exists : ('a ‑> bool) ‑> ('a, _) t ‑> boolExistential test (is there an element that satisfies the predicate?).
val for_all : ('a ‑> bool) ‑> ('a, _) t ‑> boolUniversal test (do all the elements satisfy the predicate?).
val find_exn : ('a ‑> bool) ‑> ('a, _) t ‑> 'aFind an element that satisfies the predicate, or
val find_map : ('a ‑> 'b option) ‑> ('a, _) t ‑> 'b optionfind_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.
Like flat_map, but using list for +intermediate collections.
val get : ('a, _) t ‑> int ‑> 'aAccess element by its index, or
Remove the n-th element of the vector. Does NOT preserve the order
+of the elements (might swap with the last element).
val rev_iter : ('a ‑> unit) ‑> ('a, _) t ‑> unitrev_iter f a is the same as iter f (rev a), only more efficient.
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) tRange 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) tRange of integers, either ascending or descending, but excluding right.
+Example: 1 --^ 10 returns the vector [1;2;3;4;5;6;7;8;9].
val of_array : 'a array ‑> ('a, 'mut) tof_array a returns a vector corresponding to the array a. Operates in O(n) time.
val of_list : 'a list ‑> ('a, 'mut) tto_seq_rev v returns the sequence of elements of v in reverse order,
+that is, the last elements of v are iterated on first.
val create : int ‑> 'a tval clear : 'a t ‑> unitval reset : 'a t ‑> unitval length : 'a t ‑> intval stats : 'a t ‑> Hashtbl.statisticsval hash : int ‑> t ‑> intval create : ?random:bool ‑> int ‑> 'a tval clear : 'a t ‑> unitval reset : 'a t ‑> unitval length : 'a t ‑> intval stats : 'a t ‑> statisticsinclude 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.tval create : ?random:bool ‑> int ‑> ('a, 'b) tval clear : ('a, 'b) t ‑> unitval reset : ('a, 'b) t ‑> unitval add : ('a, 'b) t ‑> 'a ‑> 'b ‑> unitval find : ('a, 'b) t ‑> 'a ‑> 'bval find_opt : ('a, 'b) t ‑> 'a ‑> 'b optionval find_all : ('a, 'b) t ‑> 'a ‑> 'b listval mem : ('a, 'b) t ‑> 'a ‑> boolval remove : ('a, 'b) t ‑> 'a ‑> unitval replace : ('a, 'b) t ‑> 'a ‑> 'b ‑> unitval iter : ('a ‑> 'b ‑> unit) ‑> ('a, 'b) t ‑> unitval filter_map_inplace : ('a ‑> 'b ‑> 'b option) ‑> ('a, 'b) t ‑> unitval fold : ('a ‑> 'b ‑> 'c ‑> 'c) ‑> ('a, 'b) t ‑> 'c ‑> 'cval length : ('a, 'b) t ‑> intval stats : ('a, 'b) t ‑> statisticsmodule type HashedType : sig ... endmodule type S : sig ... endmodule type SeededHashedType : sig ... endmodule type SeededS : sig ... endmodule MakeSeeded : functor (H : SeededHashedType) -> sig ... endinclude CCHashtbl.Polyval get_or : ('a, 'b) Hashtbl.t ‑> 'a ‑> default:'b ‑> 'bget_or tbl k ~default returns the value associated to k if present,
+and returns default otherwise (if k doesn't belong in tbl).
val keys : ('a, 'b) Hashtbl.t ‑> 'a CCHashtbl.sequenceIterate on keys (similar order as Hashtbl.iter).
val keys_list : ('a, 'b) Hashtbl.t ‑> 'a listkeys_list t is the list of keys in t.
+If the key is in the Hashtable multiple times, all occurrences will be returned.
val map_list : ('a ‑> 'b ‑> 'c) ‑> ('a, 'b) Hashtbl.t ‑> 'c listMap on a hashtable's items, collect into a list.
val incr : ?by:int ‑> ('a, int) Hashtbl.t ‑> 'a ‑> unitincr ?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).
by rather than 1.val decr : ?by:int ‑> ('a, int) Hashtbl.t ‑> 'a ‑> unitLike 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.
val add_list : ('a, 'b list) Hashtbl.t ‑> 'a ‑> 'b ‑> unitadd_list tbl x y adds y to the list x is bound to. If x is
+not bound, it becomes bound to y.
val add_seq : ('a, 'b) Hashtbl.t ‑> ('a * 'b) CCHashtbl.sequence ‑> unitAdd the corresponding pairs to the table, using Hashtbl.add.
val of_seq : ('a * 'b) CCHashtbl.sequence ‑> ('a, 'b) Hashtbl.tFrom the given bindings, added in order.
val add_seq_count : ('a, int) Hashtbl.t ‑> 'a CCHashtbl.sequence ‑> unitadd_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.
val of_seq_count : 'a CCHashtbl.sequence ‑> ('a, int) Hashtbl.tLike add_seq_count, but allocates a new table and returns it.
val of_list : ('a * 'b) list ‑> ('a, 'b) Hashtbl.tBuild 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 ‑> unitupdate 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.
val get_or_add : ('a, 'b) Hashtbl.t ‑> f:('a ‑> 'b) ‑> k:'a ‑> 'bget_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.
val pp : 'a CCHashtbl.printer ‑> 'b CCHashtbl.printer ‑> ('a, 'b) Hashtbl.t CCHashtbl.printermodule type S' = CCHashtbl.Smodule Make' = CCHashtbl.Makeval hash : t ‑> intget_or tbl k ~default returns the value associated to k if present,
+and returns default otherwise (if k doesn't belong in tbl).
add_list tbl x y adds y to the list x is bound to. If x is
+not bound, it becomes bound to y.
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).
by rather than 1.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.
keys_list t is the list of keys in t.
+If the key is in the Hashtable multiple times, all occurrences will be returned.
val add_seq : 'a t ‑> (key * 'a) CCHashtbl.sequence ‑> unitAdd the corresponding pairs to the table, using Hashtbl.add.
val add_seq_count : int t ‑> key CCHashtbl.sequence ‑> unitadd_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.
val of_seq_count : key CCHashtbl.sequence ‑> int tLike add_seq_count, but allocates a new table and returns it.
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.
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.
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.
val pp : key CCHashtbl.printer ‑> 'a CCHashtbl.printer ‑> 'a t CCHashtbl.printerval create : int ‑> 'a tval clear : 'a t ‑> unitval reset : 'a t ‑> unitval length : 'a t ‑> intval stats : 'a t ‑> statisticsval hash : int ‑> t ‑> intval create : ?random:bool ‑> int ‑> 'a tval clear : 'a t ‑> unitval reset : 'a t ‑> unitval length : 'a t ‑> intval stats : 'a t ‑> statisticsmodule Array = CCArraymodule ArrayLabels = CCArrayLabelsmodule Array_slice = CCArray_slicemodule Bool = CCBoolmodule Equal = CCEqualmodule Float = CCFloatmodule Format = CCFormatmodule Fun = CCFunmodule Hash = CCHashmodule Hashtbl : sig ... endmodule Heap = CCHeapmodule Int = CCIntmodule Int32 = CCInt32module Int64 = CCInt64module IO = CCIOmodule List = CCListmodule ListLabels = CCListLabelsmodule Map = CCMapmodule Nativeint = CCNativeintmodule Option = CCOptmodule Ord = CCOrdmodule Pair = CCPairmodule Parse = CCParsemodule Random = CCRandommodule Ref = CCRefmodule Result = CCResultmodule Set = CCSetmodule String = CCStringmodule Vector = CCVectormodule Utf8_string = CCUtf8_stringinclude Monomorphic+This library exposes the following toplevel modules:
.
\ No newline at end of file diff --git a/dev/containers/page-index.odoc b/dev/containers/page-index.odoc new file mode 100644 index 00000000..9b8426d2 Binary files /dev/null and b/dev/containers/page-index.odoc differ diff --git a/dev/index.html b/dev/index.html index a8eb8664..86e83d8a 100644 --- a/dev/index.html +++ b/dev/index.html @@ -10,14 +10,14 @@