From f1878e9924fbd4c51f20063f5c94f01d65ce13c1 Mon Sep 17 00:00:00 2001 From: FardaleM Date: Thu, 11 Nov 2021 13:48:35 +0000 Subject: [PATCH] deploy: 099f2e176fbc2e506994b5005ad39e053b868396 --- dev/containers-data/CCBV/index.html | 2 +- dev/containers-data/CCBijection/index.html | 2 +- dev/containers-data/CCBitField/index.html | 4 ++-- dev/containers-data/CCCache/index.html | 2 +- dev/containers-data/CCDeque/index.html | 2 +- dev/containers-data/CCFQueue/index.html | 2 +- dev/containers-data/CCFun_vec/index.html | 2 +- dev/containers-data/CCGraph/index.html | 2 +- dev/containers-data/CCHashSet/index.html | 2 +- dev/containers-data/CCHashTrie/index.html | 2 +- dev/containers-data/CCHet/index.html | 2 +- dev/containers-data/CCImmutArray/index.html | 2 +- dev/containers-data/CCIntMap/index.html | 2 +- dev/containers-data/CCKTree/index.html | 2 +- dev/containers-data/CCLazy_list/index.html | 2 +- dev/containers-data/CCMixmap/index.html | 4 ++-- dev/containers-data/CCMixset/index.html | 4 ++-- dev/containers-data/CCMixtbl/index.html | 4 ++-- dev/containers-data/CCMultiMap/index.html | 2 +- dev/containers-data/CCMultiSet/index.html | 2 +- dev/containers-data/CCMutHeap/index.html | 2 +- dev/containers-data/CCPersistentArray/index.html | 2 +- dev/containers-data/CCPersistentHashtbl/index.html | 2 +- dev/containers-data/CCRAL/index.html | 2 +- dev/containers-data/CCRingBuffer/index.html | 2 +- dev/containers-data/CCSimple_queue/index.html | 2 +- dev/containers-data/CCTrie/index.html | 2 +- dev/containers-data/CCWBTree/index.html | 2 +- dev/containers-data/CCZipper/index.html | 2 +- dev/containers-data/index.html | 2 +- dev/containers/CCArray/index.html | 2 +- dev/containers/CCArrayLabels/index.html | 2 +- dev/containers/CCBool/index.html | 2 +- dev/containers/CCCanonical_sexp/index.html | 2 +- dev/containers/CCChar/index.html | 2 +- dev/containers/CCEither/index.html | 2 +- dev/containers/CCEqual/index.html | 2 +- dev/containers/CCEqualLabels/index.html | 2 +- dev/containers/CCFloat/index.html | 2 +- dev/containers/CCFormat/index.html | 2 +- dev/containers/CCFun/index.html | 2 +- dev/containers/CCHash/index.html | 2 +- dev/containers/CCHashtbl/index.html | 2 +- dev/containers/CCHeap/index.html | 2 +- dev/containers/CCIO/index.html | 4 ++-- dev/containers/CCInt/index.html | 2 +- dev/containers/CCInt32/index.html | 2 +- dev/containers/CCInt64/index.html | 2 +- dev/containers/CCList/index.html | 2 +- dev/containers/CCListLabels/index.html | 2 +- dev/containers/CCMap/index.html | 2 +- dev/containers/CCNativeint/index.html | 2 +- dev/containers/CCOpt/index.html | 2 +- dev/containers/CCOption/index.html | 2 +- dev/containers/CCOrd/index.html | 2 +- dev/containers/CCPair/index.html | 2 +- dev/containers/CCParse/index.html | 2 +- dev/containers/CCRandom/index.html | 2 +- dev/containers/CCRef/index.html | 2 +- dev/containers/CCResult/index.html | 2 +- dev/containers/CCSeq/index.html | 2 +- dev/containers/CCSet/index.html | 2 +- dev/containers/CCSexp/index.html | 2 +- dev/containers/CCString/index.html | 2 +- dev/containers/CCStringLabels/index.html | 2 +- dev/containers/CCUtf8_string/index.html | 2 +- dev/containers/CCVector/index.html | 2 +- dev/containers/Containers/index.html | 2 +- dev/containers/ContainersLabels/index.html | 2 +- dev/containers/index.html | 2 +- 70 files changed, 75 insertions(+), 75 deletions(-) diff --git a/dev/containers-data/CCBV/index.html b/dev/containers-data/CCBV/index.html index 463a6090..6e9f375d 100644 --- a/dev/containers-data/CCBV/index.html +++ b/dev/containers-data/CCBV/index.html @@ -1,2 +1,2 @@ -CCBV (containers-data.CCBV)

Module CCBV

Imperative Bitvectors

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.

type t

A resizable bitvector

val empty : unit -> t

Empty bitvector.

val create : size:int -> bool -> t

Create a bitvector of given size, with given default value.

val copy : t -> t

Copy of bitvector.

val cardinal : t -> int

Number of bits set to one, seen as a set of bits.

val length : t -> int

Size of underlying bitvector. This is not related to the underlying implementation. Changed at 1.2

val capacity : t -> int

The number of bits this bitvector can store without resizing.

  • since 1.2
val resize : t -> int -> unit

Resize the BV so that it has the specified length. This can grow or shrink the underlying bitvector.

  • raises Invalid_arg

    on negative sizes.

val is_empty : t -> bool

Are there any true bits?

val set : t -> int -> unit

Set i-th bit, extending the bitvector if needed.

val get : t -> int -> bool

Is the i-th bit true? Return false if the index is too high.

val reset : t -> int -> unit

Set i-th bit to 0, extending the bitvector if needed.

val flip : t -> int -> unit

Flip i-th bit, extending the bitvector if needed.

val clear : t -> unit

Set every bit to 0.

val iter : t -> (int -> bool -> unit) -> unit

Iterate on all bits.

val iter_true : t -> (int -> unit) -> unit

Iterate on bits set to 1.

val to_list : t -> int list

List of indexes that are true.

val to_sorted_list : t -> int list

Same as to_list, but also guarantees the list is sorted in increasing order.

val of_list : int list -> t

From a list of true bits.

The bits are interpreted as indices into the returned bitvector, so the final bitvector bv will have length bv equal to 1 more than max of list indices.

val first : t -> int option

First set bit, or return None. Changed type at 1.2

val first_exn : t -> int

First set bit, or

  • raises Not_found

    if all bits are 0.

  • since 1.2
val filter : t -> (int -> bool) -> unit

filter bv p only keeps the true bits of bv whose index satisfies p index.

val negate_self : t -> unit

negate_self t flips all of the bits in t.

  • since 1.2
val negate : t -> t

negate t returns a copy of t with all of the bits flipped.

val union_into : into:t -> t -> unit

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.

val inter_into : into:t -> t -> unit

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 union : t -> t -> t

union bv1 bv2 returns the union of the two sets.

val inter : t -> t -> t

inter bv1 bv2 returns the intersection of the two sets.

val diff_into : into:t -> t -> unit

diff_into ~into t modifies into with only the bits set but not in t.

  • since 1.2
val diff : t -> t -> t

diff t1 t2 returns those bits found in t1 but not in t2.

  • since 1.2
val select : t -> 'a array -> 'a list

select 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) list

Same as select, but selected elements are paired with their indexes.

val equal : t -> t -> bool

Bitwise comparison, including the size (equal a b implies length a=length b).

  • since 3.5
type 'a iter = ('a -> unit) -> unit
val to_iter : t -> int iter
val of_iter : int iter -> t
val pp : Stdlib.Format.formatter -> t -> unit

Print the bitvector as a string of bits.

  • since 0.13
\ No newline at end of file +CCBV (containers-data.CCBV)

Module CCBV

Imperative Bitvectors

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.

type t

A resizable bitvector

val empty : unit -> t

Empty bitvector.

val create : size:int -> bool -> t

Create a bitvector of given size, with given default value.

val copy : t -> t

Copy of bitvector.

val cardinal : t -> int

Number of bits set to one, seen as a set of bits.

val length : t -> int

Size of underlying bitvector. This is not related to the underlying implementation. Changed at 1.2

val capacity : t -> int

The number of bits this bitvector can store without resizing.

  • since 1.2
val resize : t -> int -> unit

Resize the BV so that it has the specified length. This can grow or shrink the underlying bitvector.

  • raises Invalid_arg

    on negative sizes.

val is_empty : t -> bool

Are there any true bits?

val set : t -> int -> unit

Set i-th bit, extending the bitvector if needed.

val get : t -> int -> bool

Is the i-th bit true? Return false if the index is too high.

val reset : t -> int -> unit

Set i-th bit to 0, extending the bitvector if needed.

val flip : t -> int -> unit

Flip i-th bit, extending the bitvector if needed.

val clear : t -> unit

Set every bit to 0.

val iter : t -> (int -> bool -> unit) -> unit

Iterate on all bits.

val iter_true : t -> (int -> unit) -> unit

Iterate on bits set to 1.

val to_list : t -> int list

List of indexes that are true.

val to_sorted_list : t -> int list

Same as to_list, but also guarantees the list is sorted in increasing order.

val of_list : int list -> t

From a list of true bits.

The bits are interpreted as indices into the returned bitvector, so the final bitvector bv will have length bv equal to 1 more than max of list indices.

val first : t -> int option

First set bit, or return None. Changed type at 1.2

val first_exn : t -> int

First set bit, or

  • raises Not_found

    if all bits are 0.

  • since 1.2
val filter : t -> (int -> bool) -> unit

filter bv p only keeps the true bits of bv whose index satisfies p index.

val negate_self : t -> unit

negate_self t flips all of the bits in t.

  • since 1.2
val negate : t -> t

negate t returns a copy of t with all of the bits flipped.

val union_into : into:t -> t -> unit

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.

val inter_into : into:t -> t -> unit

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 union : t -> t -> t

union bv1 bv2 returns the union of the two sets.

val inter : t -> t -> t

inter bv1 bv2 returns the intersection of the two sets.

val diff_into : into:t -> t -> unit

diff_into ~into t modifies into with only the bits set but not in t.

  • since 1.2
val diff : t -> t -> t

diff t1 t2 returns those bits found in t1 but not in t2.

  • since 1.2
val select : t -> 'a array -> 'a list

select 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) list

Same as select, but selected elements are paired with their indexes.

val equal : t -> t -> bool

Bitwise comparison, including the size (equal a b implies length a=length b).

  • since 3.5
type 'a iter = ('a -> unit) -> unit
val to_iter : t -> int iter
val of_iter : int iter -> t
val pp : Stdlib.Format.formatter -> t -> unit

Print the bitvector as a string of bits.

  • since 0.13
\ No newline at end of file diff --git a/dev/containers-data/CCBijection/index.html b/dev/containers-data/CCBijection/index.html index 542f9fc9..7ec8cf52 100644 --- a/dev/containers-data/CCBijection/index.html +++ b/dev/containers-data/CCBijection/index.html @@ -1,2 +1,2 @@ -CCBijection (containers-data.CCBijection)

Module CCBijection

Bijection

Represents 1-to-1 mappings between two types. Each element from the "left" is mapped to one "right" value, and conversely.

type 'a iter = ('a -> unit) -> unit
module type OrderedType = sig ... end
module type S = sig ... end
module Make (L : OrderedType) (R : OrderedType) : S with type left = L.t and type right = R.t
\ No newline at end of file +CCBijection (containers-data.CCBijection)

Module CCBijection

Functor to build a bijection Represents 1-to-1 mappings between two types. Each element from the "left" is mapped to one "right" value, and conversely.

type 'a iter = ('a -> unit) -> unit
module type OrderedType = sig ... end
module type S = sig ... end
module Make (L : OrderedType) (R : OrderedType) : S with type left = L.t and type right = R.t
\ No newline at end of file diff --git a/dev/containers-data/CCBitField/index.html b/dev/containers-data/CCBitField/index.html index 798f7ff2..716d4b6d 100644 --- a/dev/containers-data/CCBitField/index.html +++ b/dev/containers-data/CCBitField/index.html @@ -1,5 +1,5 @@ -CCBitField (containers-data.CCBitField)

Module CCBitField

Bit Field

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);;
+CCBitField (containers-data.CCBitField)

Module CCBitField

Efficient Bit Field for up to 31 or 61 fiels

This module defines efficient bitfields up to 31 or 61 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 ()
@@ -9,4 +9,4 @@ 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);;
exception TooManyFields

Raised when too many fields are packed into one bitfield.

exception Frozen

Raised when a frozen bitfield is modified.

val max_width : int

System-dependent maximum width for a bitfield, typically 30 or 62.

module type S = sig ... end
module Make (_ : sig ... end) : S

Create a new bitfield type

\ No newline at end of file +assert (f |> B.set z true |> B.get z);;
exception TooManyFields

Raised when too many fields are packed into one bitfield.

exception Frozen

Raised when a frozen bitfield is modified.

val max_width : int

System-dependent maximum width for a bitfield, typically 30 or 62.

module type S = sig ... end
module Make (_ : sig ... end) : S

Create a new bitfield type

\ No newline at end of file diff --git a/dev/containers-data/CCCache/index.html b/dev/containers-data/CCCache/index.html index 663f2fbe..24de7623 100644 --- a/dev/containers-data/CCCache/index.html +++ b/dev/containers-data/CCCache/index.html @@ -1,5 +1,5 @@ -CCCache (containers-data.CCCache)

Module CCCache

Caches

Particularly useful for memoization. See with_cache and with_cache_rec for more details.

type 'a equal = 'a -> 'a -> bool
type 'a hash = 'a -> int

Value interface

Typical use case: one wants to memoize a function f : 'a -> 'b. Code sample:

let f x =
+CCCache (containers-data.CCCache)

Module CCCache

Caches Utils

Particularly useful for memoization. See with_cache and with_cache_rec for more details.

  • since 0.6
type 'a equal = 'a -> 'a -> bool
type 'a hash = 'a -> int

Value interface

Typical use case: one wants to memoize a function f : 'a -> 'b. Code sample:

let f x =
   print_endline "call f";
   x + 1;;
 
diff --git a/dev/containers-data/CCDeque/index.html b/dev/containers-data/CCDeque/index.html
index e8da8a15..ca965c50 100644
--- a/dev/containers-data/CCDeque/index.html
+++ b/dev/containers-data/CCDeque/index.html
@@ -1,2 +1,2 @@
 
-CCDeque (containers-data.CCDeque)

Module CCDeque

Imperative deque

This structure provides fast access to its front and back elements, with O(1) operations.

type 'a t

Contains 'a elements, queue in both ways

exception Empty
val create : unit -> 'a t

New deque.

val clear : _ t -> unit

Remove all elements.

  • since 0.13
val is_empty : 'a t -> bool

Is the deque empty?

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

equal a b checks whether a and b contain the same sequence of elements.

  • parameter eq

    comparison function for elements.

  • since 0.13
val compare : cmp:('a -> 'a -> int) -> 'a t -> 'a t -> int

compare a b compares lexicographically a and b.

  • parameter cmp

    comparison function for elements.

  • since 0.13
val length : 'a t -> int

Number of elements. Used to be linear time, now constant time.

val push_front : 'a t -> 'a -> unit

Push value at the front.

val push_back : 'a t -> 'a -> unit

Push value at the back.

val peek_front : 'a t -> 'a

First value.

  • raises Empty

    if empty.

val peek_front_opt : 'a t -> 'a option

First value.

  • since 2.7
val peek_back : 'a t -> 'a

Last value.

  • raises Empty

    if empty.

val peek_back_opt : 'a t -> 'a option

Last value.

  • since 2.7
val remove_back : 'a t -> unit

Remove last value. If the deque is empty do nothing

  • since 2.7
val remove_front : 'a t -> unit

Remove first value. If the deque is empty do nothing

  • since 2.7
val take_back : 'a t -> 'a

Take last value.

  • raises Empty

    if empty.

val take_back_opt : 'a t -> 'a option

Take last value.

  • since 2.7
val take_front : 'a t -> 'a

Take first value.

  • raises Empty

    if empty.

val take_front_opt : 'a t -> 'a option

Take first value.

  • since 2.7
val update_back : 'a t -> ('a -> 'a option) -> unit

Update last value. If the deque is empty do nothing. If the function returns None, remove last element; if it returns Some x, replace last element with x.

  • since 2.7
val update_front : 'a t -> ('a -> 'a option) -> unit

Update first value. If the deque is empty do nothing. Similar to update_back but for the first value.

  • since 2.7
val append_front : into:'a t -> 'a t -> unit

append_front ~into q adds all elements of q at the front of into. O(length q) in time.

  • since 0.13
val append_back : into:'a t -> 'a t -> unit

append_back ~into q adds all elements of q at the back of into. O(length q) in time.

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

Iterate on elements.

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

Fold on elements.

  • since 0.13

Conversions

type 'a gen = unit -> 'a option
type 'a iter = ('a -> unit) -> unit
val of_iter : 'a iter -> 'a t

Create a deque from the sequence. Optional argument deque disappears, use add_iter_back instead.

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

Iterate on the elements.

val of_gen : 'a gen -> 'a t

of_gen g makes a deque containing the elements of g.

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

Iterate on the elements of the deque.

  • since 0.13
val add_iter_front : 'a t -> 'a iter -> unit

add_iter_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.

  • since 0.13
val add_iter_back : 'a t -> 'a iter -> unit

add_iter_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.

  • since 0.13
val copy : 'a t -> 'a t

Fresh copy, O(n) in time.

val of_list : 'a list -> 'a t

Conversion from list, in order.

  • since 0.13
val to_list : 'a t -> 'a list

List of elements, in order. Less efficient than to_rev_list.

  • since 0.13
val to_rev_list : 'a t -> 'a list

Efficient conversion to list, in reverse order.

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

Filter into a new copy.

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

Filter map into a new copy

  • since 2.7
val filter_in_place : 'a t -> ('a -> bool) -> unit

Keep only elements that satisfy the predicate.

  • since 2.7

print

type 'a printer = Stdlib.Format.formatter -> 'a -> unit
val pp : 'a printer -> 'a t printer

Print the elements.

  • since 0.13
\ No newline at end of file +CCDeque (containers-data.CCDeque)

Module CCDeque

Imperative deque

This structure provides fast access to its front and back elements, with O(1) operations.

type 'a t

Contains 'a elements, queue in both ways

exception Empty
val create : unit -> 'a t

New deque.

val clear : _ t -> unit

Remove all elements.

  • since 0.13
val is_empty : 'a t -> bool

Is the deque empty?

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

equal a b checks whether a and b contain the same sequence of elements.

  • parameter eq

    comparison function for elements.

  • since 0.13
val compare : cmp:('a -> 'a -> int) -> 'a t -> 'a t -> int

compare a b compares lexicographically a and b.

  • parameter cmp

    comparison function for elements.

  • since 0.13
val length : 'a t -> int

Number of elements. Used to be linear time, now constant time.

val push_front : 'a t -> 'a -> unit

Push value at the front.

val push_back : 'a t -> 'a -> unit

Push value at the back.

val peek_front : 'a t -> 'a

First value.

  • raises Empty

    if empty.

val peek_front_opt : 'a t -> 'a option

First value.

  • since 2.7
val peek_back : 'a t -> 'a

Last value.

  • raises Empty

    if empty.

val peek_back_opt : 'a t -> 'a option

Last value.

  • since 2.7
val remove_back : 'a t -> unit

Remove last value. If the deque is empty do nothing

  • since 2.7
val remove_front : 'a t -> unit

Remove first value. If the deque is empty do nothing

  • since 2.7
val take_back : 'a t -> 'a

Take last value.

  • raises Empty

    if empty.

val take_back_opt : 'a t -> 'a option

Take last value.

  • since 2.7
val take_front : 'a t -> 'a

Take first value.

  • raises Empty

    if empty.

val take_front_opt : 'a t -> 'a option

Take first value.

  • since 2.7
val update_back : 'a t -> ('a -> 'a option) -> unit

Update last value. If the deque is empty do nothing. If the function returns None, remove last element; if it returns Some x, replace last element with x.

  • since 2.7
val update_front : 'a t -> ('a -> 'a option) -> unit

Update first value. If the deque is empty do nothing. Similar to update_back but for the first value.

  • since 2.7
val append_front : into:'a t -> 'a t -> unit

append_front ~into q adds all elements of q at the front of into. O(length q) in time.

  • since 0.13
val append_back : into:'a t -> 'a t -> unit

append_back ~into q adds all elements of q at the back of into. O(length q) in time.

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

Iterate on elements.

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

Fold on elements.

  • since 0.13

Conversions

type 'a gen = unit -> 'a option
type 'a iter = ('a -> unit) -> unit
val of_iter : 'a iter -> 'a t

Create a deque from the sequence. Optional argument deque disappears, use add_iter_back instead.

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

Iterate on the elements.

val of_gen : 'a gen -> 'a t

of_gen g makes a deque containing the elements of g.

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

Iterate on the elements of the deque.

  • since 0.13
val add_iter_front : 'a t -> 'a iter -> unit

add_iter_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.

  • since 0.13
val add_iter_back : 'a t -> 'a iter -> unit

add_iter_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.

  • since 0.13
val copy : 'a t -> 'a t

Fresh copy, O(n) in time.

val of_list : 'a list -> 'a t

Conversion from list, in order.

  • since 0.13
val to_list : 'a t -> 'a list

List of elements, in order. Less efficient than to_rev_list.

  • since 0.13
val to_rev_list : 'a t -> 'a list

Efficient conversion to list, in reverse order.

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

Filter into a new copy.

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

Filter map into a new copy

  • since 2.7
val filter_in_place : 'a t -> ('a -> bool) -> unit

Keep only elements that satisfy the predicate.

  • since 2.7

print

type 'a printer = Stdlib.Format.formatter -> 'a -> unit
val pp : 'a printer -> 'a t printer

Print the elements.

  • since 0.13
\ No newline at end of file diff --git a/dev/containers-data/CCFQueue/index.html b/dev/containers-data/CCFQueue/index.html index 0a8786f9..e536c934 100644 --- a/dev/containers-data/CCFQueue/index.html +++ b/dev/containers-data/CCFQueue/index.html @@ -1,2 +1,2 @@ -CCFQueue (containers-data.CCFQueue)

Module CCFQueue

Functional queues

type 'a iter = ('a -> unit) -> unit
type 'a equal = 'a -> 'a -> bool
type 'a printer = Stdlib.Format.formatter -> 'a -> unit

Basics

type +'a t

Queue containing elements of type 'a

val empty : 'a t
val is_empty : 'a t -> bool
val singleton : 'a -> 'a t
val doubleton : 'a -> 'a -> 'a t
exception Empty
val cons : 'a -> 'a t -> 'a t

Push element at the front of the queue.

val snoc : 'a t -> 'a -> 'a t

Push element at the end of the queue.

val take_front : 'a t -> ('a * 'a t) option

Get and remove the first element.

val take_front_exn : 'a t -> 'a * 'a t

Same as take_front, but fails on empty queues.

  • raises Empty

    if the queue is empty.

val take_front_l : int -> 'a t -> 'a list * 'a t

take_front_l n q takes at most n elements from the front of q, and returns them wrapped in a list.

  • raises Invalid_argument

    if n<0.

val take_front_while : ('a -> bool) -> 'a t -> 'a list * 'a t
val take_back : 'a t -> ('a t * 'a) option

Take last element.

val take_back_exn : 'a t -> 'a t * 'a

Same as take_back, but fails on empty queues.

  • raises Empty

    if the queue is empty.

val take_back_l : int -> 'a t -> 'a t * 'a list

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].

  • raises Invalid_argument

    if n<0.

val take_back_while : ('a -> bool) -> 'a t -> 'a t * 'a list

Individual extraction

val first : 'a t -> 'a option

First element of the queue.

val last : 'a t -> 'a option

Last element of the queue.

val first_exn : 'a t -> 'a

Same as first but

  • raises Empty

    if the queue is empty.

val last_exn : 'a t -> 'a
val nth : int -> 'a t -> 'a option

Return the i-th element of the queue in logarithmic time.

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

Unsafe version of nth.

  • raises Not_found

    if the index is wrong.

val tail : 'a t -> 'a t

Queue deprived of its first element. Does nothing on empty queues.

val init : 'a t -> 'a t

Queue deprived of its last element. Does nothing on empty queues.

Global Operations

val append : 'a t -> 'a t -> 'a t

Append two queues. Elements from the second one come after elements of the first one. Linear in the size of the second queue.

val rev : 'a t -> 'a t

Reverse the queue, O(n) complexity.

  • since 0.10
val map : ('a -> 'b) -> 'a t -> 'b t

Map values.

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

Synonym to map.

val size : 'a t -> int

Number of elements in the queue (constant time).

val fold : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'b
val iter : ('a -> unit) -> 'a t -> unit
val equal : 'a equal -> 'a t equal

Conversions

val of_list : 'a list -> 'a t
val to_list : 'a t -> 'a list
val add_iter_front : 'a iter -> 'a t -> 'a t
  • since 3.0
val add_iter_back : 'a t -> 'a iter -> 'a t
  • since 3.0
val to_iter : 'a t -> 'a iter
  • since 3.0
val of_iter : 'a iter -> 'a t
  • since 3.0
val add_seq_front : 'a Stdlib.Seq.t -> 'a t -> 'a t
  • since 3.0
val add_seq_back : 'a t -> 'a Stdlib.Seq.t -> 'a t
  • since 3.0
val to_seq : 'a t -> 'a Stdlib.Seq.t
  • since 3.0
val of_seq : 'a Stdlib.Seq.t -> 'a t
  • since 3.0
val (--) : int -> int -> int t

a -- b is the integer range from a to b, both included.

  • since 0.10
val (--^) : int -> int -> int t

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

  • since 0.17
val pp : 'a printer -> 'a t printer
  • since 0.13
\ No newline at end of file +CCFQueue (containers-data.CCFQueue)

Module CCFQueue

Functional queues

type 'a iter = ('a -> unit) -> unit
type 'a equal = 'a -> 'a -> bool
type 'a printer = Stdlib.Format.formatter -> 'a -> unit

Basics

type +'a t

Queue containing elements of type 'a

val empty : 'a t
val is_empty : 'a t -> bool
val singleton : 'a -> 'a t
val doubleton : 'a -> 'a -> 'a t
exception Empty
val cons : 'a -> 'a t -> 'a t

Push element at the front of the queue.

val snoc : 'a t -> 'a -> 'a t

Push element at the end of the queue.

val take_front : 'a t -> ('a * 'a t) option

Get and remove the first element.

val take_front_exn : 'a t -> 'a * 'a t

Same as take_front, but fails on empty queues.

  • raises Empty

    if the queue is empty.

val take_front_l : int -> 'a t -> 'a list * 'a t

take_front_l n q takes at most n elements from the front of q, and returns them wrapped in a list.

  • raises Invalid_argument

    if n<0.

val take_front_while : ('a -> bool) -> 'a t -> 'a list * 'a t
val take_back : 'a t -> ('a t * 'a) option

Take last element.

val take_back_exn : 'a t -> 'a t * 'a

Same as take_back, but fails on empty queues.

  • raises Empty

    if the queue is empty.

val take_back_l : int -> 'a t -> 'a t * 'a list

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].

  • raises Invalid_argument

    if n<0.

val take_back_while : ('a -> bool) -> 'a t -> 'a t * 'a list

Individual extraction

val first : 'a t -> 'a option

First element of the queue.

val last : 'a t -> 'a option

Last element of the queue.

val first_exn : 'a t -> 'a

Same as first but

  • raises Empty

    if the queue is empty.

val last_exn : 'a t -> 'a
val nth : int -> 'a t -> 'a option

Return the i-th element of the queue in logarithmic time.

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

Unsafe version of nth.

  • raises Not_found

    if the index is wrong.

val tail : 'a t -> 'a t

Queue deprived of its first element. Does nothing on empty queues.

val init : 'a t -> 'a t

Queue deprived of its last element. Does nothing on empty queues.

Global Operations

val append : 'a t -> 'a t -> 'a t

Append two queues. Elements from the second one come after elements of the first one. Linear in the size of the second queue.

val rev : 'a t -> 'a t

Reverse the queue, O(n) complexity.

  • since 0.10
val map : ('a -> 'b) -> 'a t -> 'b t

Map values.

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

Synonym to map.

val size : 'a t -> int

Number of elements in the queue (constant time).

val fold : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'b
val iter : ('a -> unit) -> 'a t -> unit
val equal : 'a equal -> 'a t equal

Conversions

val of_list : 'a list -> 'a t
val to_list : 'a t -> 'a list
val add_iter_front : 'a iter -> 'a t -> 'a t
  • since 3.0
val add_iter_back : 'a t -> 'a iter -> 'a t
  • since 3.0
val to_iter : 'a t -> 'a iter
  • since 3.0
val of_iter : 'a iter -> 'a t
  • since 3.0
val add_seq_front : 'a Stdlib.Seq.t -> 'a t -> 'a t
  • since 3.0
val add_seq_back : 'a t -> 'a Stdlib.Seq.t -> 'a t
  • since 3.0
val to_seq : 'a t -> 'a Stdlib.Seq.t
  • since 3.0
val of_seq : 'a Stdlib.Seq.t -> 'a t
  • since 3.0
val (--) : int -> int -> int t

a -- b is the integer range from a to b, both included.

  • since 0.10
val (--^) : int -> int -> int t

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

  • since 0.17
val pp : 'a printer -> 'a t printer
  • since 0.13
\ No newline at end of file diff --git a/dev/containers-data/CCFun_vec/index.html b/dev/containers-data/CCFun_vec/index.html index 78f1b6b8..a74b7895 100644 --- a/dev/containers-data/CCFun_vec/index.html +++ b/dev/containers-data/CCFun_vec/index.html @@ -1,2 +1,2 @@ -CCFun_vec (containers-data.CCFun_vec)

Module CCFun_vec

Functional Vectors

Tree with a large branching factor for logarithmic operations with a low multiplicative factor.

status: experimental. DO NOT USE (yet)

  • since 2.1
type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a ktree = unit -> [ `Nil | `Node of 'a * 'a ktree list ]

Signature

type 'a t
val empty : 'a t
val is_empty : _ t -> bool
val return : 'a -> 'a t
val length : _ t -> int
val push : 'a -> 'a t -> 'a t

Add element at the end.

val get : int -> 'a t -> 'a option
val get_exn : int -> 'a t -> 'a
  • raises Not_found

    if key not present.

val pop_exn : 'a t -> 'a * 'a t

Pop last element.

val pop : 'a t -> ('a * 'a t) option

Pop last element.

  • since 2.5
val iter : f:('a -> unit) -> 'a t -> unit
val iteri : f:(int -> 'a -> unit) -> 'a t -> unit

Iterate on elements with their index, in increasing order.

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

Iterate on elements with their index, but starting from the end.

val fold : f:('b -> 'a -> 'b) -> x:'b -> 'a t -> 'b
val foldi : f:('b -> int -> 'a -> 'b) -> x:'b -> 'a t -> 'b
val append : 'a t -> 'a t -> 'a t
val map : ('a -> 'b) -> 'a t -> 'b t
val choose : 'a t -> 'a option
Conversions
val to_list : 'a t -> 'a list
val of_list : 'a list -> 'a t
val add_list : 'a t -> 'a list -> 'a t
val add_iter : 'a t -> 'a iter -> 'a t
val of_iter : 'a iter -> 'a t
val to_iter : 'a t -> 'a iter
val add_gen : 'a t -> 'a gen -> 'a t
val of_gen : 'a gen -> 'a t
val to_gen : 'a t -> 'a gen
IO
val pp : 'a printer -> 'a t printer
\ No newline at end of file +CCFun_vec (containers-data.CCFun_vec)

Module CCFun_vec

Functional Vectors

Tree with a large branching factor for logarithmic operations with a low multiplicative factor.

status: experimental. DO NOT USE (yet)

  • since 2.1
type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a ktree = unit -> [ `Nil | `Node of 'a * 'a ktree list ]

Signature

type 'a t
val empty : 'a t
val is_empty : _ t -> bool
val return : 'a -> 'a t
val length : _ t -> int
val push : 'a -> 'a t -> 'a t

Add element at the end.

val get : int -> 'a t -> 'a option
val get_exn : int -> 'a t -> 'a
  • raises Not_found

    if key not present.

val pop_exn : 'a t -> 'a * 'a t

Pop last element.

val pop : 'a t -> ('a * 'a t) option

Pop last element.

  • since 2.5
val iter : f:('a -> unit) -> 'a t -> unit
val iteri : f:(int -> 'a -> unit) -> 'a t -> unit

Iterate on elements with their index, in increasing order.

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

Iterate on elements with their index, but starting from the end.

val fold : f:('b -> 'a -> 'b) -> x:'b -> 'a t -> 'b
val foldi : f:('b -> int -> 'a -> 'b) -> x:'b -> 'a t -> 'b
val append : 'a t -> 'a t -> 'a t
val map : ('a -> 'b) -> 'a t -> 'b t
val choose : 'a t -> 'a option
Conversions
val to_list : 'a t -> 'a list
val of_list : 'a list -> 'a t
val add_list : 'a t -> 'a list -> 'a t
val add_iter : 'a t -> 'a iter -> 'a t
val of_iter : 'a iter -> 'a t
val to_iter : 'a t -> 'a iter
val add_gen : 'a t -> 'a gen -> 'a t
val of_gen : 'a gen -> 'a t
val to_gen : 'a t -> 'a gen
IO
val pp : 'a printer -> 'a t printer
\ No newline at end of file diff --git a/dev/containers-data/CCGraph/index.html b/dev/containers-data/CCGraph/index.html index afb5ff4a..d92826cd 100644 --- a/dev/containers-data/CCGraph/index.html +++ b/dev/containers-data/CCGraph/index.html @@ -1,5 +1,5 @@ -CCGraph (containers-data.CCGraph)

Module CCGraph

Simple Graph Interface

A 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 an iterator of vertices as input. The helper module Iter contains basic functions for that, as does the iter library on opam. If the user only has a single vertex (e.g., for a topological sort from a given vertex), they can use Iter.return x to build a iter of one element.

status: unstable

  • since 0.12

Iter Helpers

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

A sequence of items of type 'a, possibly infinite

  • since 2.8
type 'a iter_once = 'a iter

Iter that should be used only once

  • since 2.8
exception Iter_once

Raised when a sequence meant to be used once is used several times.

module Iter : sig ... end

Interfaces for graphs

This interface is designed for oriented graphs with labels on edges

type ('v, 'e) t = 'v -> ('e * 'v) iter

Directed graph with vertices of type 'v and edges labeled with e'

type ('v, 'e) graph = ('v'e) t
val make : ('v -> ('e * 'v) iter) -> ('v'e) t

Make a graph by providing the children function.

type 'v tag_set = {
get_tag : 'v -> bool;
set_tag : 'v -> unit;(*

Set tag for the given element

*)
}

Tags

Mutable tags from values of type 'v to tags of type bool

type ('k, 'a) table = {
mem : 'k -> bool;
find : 'k -> 'a;(*
  • raises Not_found

    if element not added before

*)
add : 'k -> 'a -> unit;(*

Erases previous binding

*)
}

Table

Mutable table with keys 'k and values 'a

type 'a set = ('a, unit) table

Mutable set

val mk_table : eq:('k -> 'k -> bool) -> ?hash:('k -> int) -> int -> ('k'a) table

Default implementation for Table: a Hashtbl.t.

val mk_map : cmp:('k -> 'k -> int) -> unit -> ('k'a) table

Use a Map.S underneath.

Bags of vertices

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 bag
val mk_stack : unit -> 'a bag
val mk_heap : leq:('a -> 'a -> bool) -> 'a bag

mk_heap ~leq makes a priority queue where leq x y = true means that x is smaller than y and should be prioritary.

Traversals

module Traverse : sig ... end

Cycles

val is_dag : tbl:'v set -> eq:('v -> 'v -> bool) -> graph:('v_) t -> 'v iter -> bool

is_dag ~graph vs returns true if the subset of graph reachable from vs is acyclic.

  • since 0.18

Topological Sort

exception Has_cycle
val topo_sort : eq:('v -> 'v -> bool) -> ?rev:bool -> tbl:'v set -> graph:('v'e) t -> +CCGraph (containers-data.CCGraph)

Module CCGraph

Simple Graph Interface

A 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 an iterator of vertices as input. The helper module Iter contains basic functions for that, as does the iter library on opam. If the user only has a single vertex (e.g., for a topological sort from a given vertex), they can use Iter.return x to build a iter of one element.

status: unstable

  • since 0.12

Iter Helpers

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

A sequence of items of type 'a, possibly infinite

  • since 2.8
type 'a iter_once = 'a iter

Iter that should be used only once

  • since 2.8
exception Iter_once

Raised when a sequence meant to be used once is used several times.

module Iter : sig ... end

Interfaces for graphs

This interface is designed for oriented graphs with labels on edges

type ('v, 'e) t = 'v -> ('e * 'v) iter

Directed graph with vertices of type 'v and edges labeled with e'

type ('v, 'e) graph = ('v'e) t
val make : ('v -> ('e * 'v) iter) -> ('v'e) t

Make a graph by providing the children function.

type 'v tag_set = {
get_tag : 'v -> bool;
set_tag : 'v -> unit;(*

Set tag for the given element

*)
}

Tags

Mutable tags from values of type 'v to tags of type bool

type ('k, 'a) table = {
mem : 'k -> bool;
find : 'k -> 'a;(*
  • raises Not_found

    if element not added before

*)
add : 'k -> 'a -> unit;(*

Erases previous binding

*)
}

Table

Mutable table with keys 'k and values 'a

type 'a set = ('a, unit) table

Mutable set

val mk_table : eq:('k -> 'k -> bool) -> ?hash:('k -> int) -> int -> ('k'a) table

Default implementation for Table: a Hashtbl.t.

val mk_map : cmp:('k -> 'k -> int) -> unit -> ('k'a) table

Use a Map.S underneath.

Bags of vertices

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 bag
val mk_stack : unit -> 'a bag
val mk_heap : leq:('a -> 'a -> bool) -> 'a bag

mk_heap ~leq makes a priority queue where leq x y = true means that x is smaller than y and should be prioritary.

Traversals

module Traverse : sig ... end

Cycles

val is_dag : tbl:'v set -> eq:('v -> 'v -> bool) -> graph:('v_) t -> 'v iter -> bool

is_dag ~graph vs returns true if the subset of graph reachable from vs is acyclic.

  • since 0.18

Topological Sort

exception Has_cycle
val topo_sort : eq:('v -> 'v -> bool) -> ?rev:bool -> tbl:'v set -> graph:('v'e) t -> 'v iter -> 'v list

topo_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.

  • parameter eq

    equality predicate on vertices (default (=)).

  • parameter rev

    if true, the dependency relation is inverted (v -> v' means v' occurs before v).

  • raises Has_cycle

    if the graph is not a DAG.

val topo_sort_tag : eq:('v -> 'v -> bool) -> ?rev:bool -> tags:'v tag_set -> graph:('v'e) t -> 'v iter -> 'v list

Same as topo_sort but uses an explicit tag set.

  • raises Has_cycle

    if the graph is not a DAG.

Lazy Spanning Tree

module Lazy_tree : sig ... end
val spanning_tree : tbl:'v set -> graph:('v'e) t -> 'v -> ('v'e) Lazy_tree.t

spanning_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.t

Strongly Connected Components

type 'v scc_state

Hidden state for scc.

val scc : tbl:('v'v scc_state) table -> graph:('v'e) t -> 'v iter -> 'v list iter_once

Strongly 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.

  • parameter tbl

    table used to map nodes to some hidden state.

  • raises Iter_once

    if the result is iterated on more than once.

Pretty printing in the DOT (graphviz) format

Example (print divisors from 42):

let open CCGraph in
 let open Dot in
diff --git a/dev/containers-data/CCHashSet/index.html b/dev/containers-data/CCHashSet/index.html
index 5da846e3..864f3fe3 100644
--- a/dev/containers-data/CCHashSet/index.html
+++ b/dev/containers-data/CCHashSet/index.html
@@ -1,2 +1,2 @@
 
-CCHashSet (containers-data.CCHashSet)

Module CCHashSet

Mutable Set

status: unstable

  • since 0.13
type 'a iter = ('a -> unit) -> unit
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
module type S = sig ... end
module type ELEMENT = sig ... end
module Make (E : ELEMENT) : S with type elt = E.t
\ No newline at end of file +CCHashSet (containers-data.CCHashSet)

Module CCHashSet

Mutable Set

status: unstable

  • since 0.13
type 'a iter = ('a -> unit) -> unit
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
module type S = sig ... end
module type ELEMENT = sig ... end
module Make (E : ELEMENT) : S with type elt = E.t
\ No newline at end of file diff --git a/dev/containers-data/CCHashTrie/index.html b/dev/containers-data/CCHashTrie/index.html index e0115305..24e52be8 100644 --- a/dev/containers-data/CCHashTrie/index.html +++ b/dev/containers-data/CCHashTrie/index.html @@ -1,2 +1,2 @@ -CCHashTrie (containers-data.CCHashTrie)

Module CCHashTrie

Hash Tries

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

  • since 0.13
type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a ktree = unit -> [ `Nil | `Node of 'a * 'a ktree list ]
module Transient : sig ... end
module type S = sig ... end
module type KEY = sig ... end
module Make (K : KEY) : S with type key = K.t
\ No newline at end of file +CCHashTrie (containers-data.CCHashTrie)

Module CCHashTrie

Hash Tries

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

  • since 0.13
type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a ktree = unit -> [ `Nil | `Node of 'a * 'a ktree list ]
module Transient : sig ... end
module type S = sig ... end
module type KEY = sig ... end
module Make (K : KEY) : S with type key = K.t
\ No newline at end of file diff --git a/dev/containers-data/CCHet/index.html b/dev/containers-data/CCHet/index.html index 4a34be79..486d0336 100644 --- a/dev/containers-data/CCHet/index.html +++ b/dev/containers-data/CCHet/index.html @@ -1,2 +1,2 @@ -CCHet (containers-data.CCHet)

Module CCHet

Associative containers with Heterogeneous Values

This is similar to CCMixtbl, but the injection is directly used as a key.

  • since 0.17
type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
module Key : sig ... end
type pair =
| Pair : 'a Key.t * 'a -> pair
module Tbl : sig ... end
module Map : sig ... end
\ No newline at end of file +CCHet (containers-data.CCHet)

Module CCHet

Associative containers with Heterogeneous Values

This is similar to CCMixtbl, but the injection is directly used as a key.

  • since 0.17
type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
module Key : sig ... end
type pair =
| Pair : 'a Key.t * 'a -> pair
module Tbl : sig ... end
module Map : sig ... end
\ No newline at end of file diff --git a/dev/containers-data/CCImmutArray/index.html b/dev/containers-data/CCImmutArray/index.html index 28bc6bcb..f34be80e 100644 --- a/dev/containers-data/CCImmutArray/index.html +++ b/dev/containers-data/CCImmutArray/index.html @@ -1,2 +1,2 @@ -CCImmutArray (containers-data.CCImmutArray)

Module CCImmutArray

Immutable Arrays

Purely 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.

  • since 0.17
type 'a t

Array 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 t
val length : _ t -> int
val singleton : 'a -> 'a t
val doubleton : 'a -> 'a -> 'a t
val make : int -> 'a -> 'a t

make n x makes an array of n times x.

val init : int -> (int -> 'a) -> 'a t

init n f makes the array [| f 0; f 1; ... ; f (n-1) |].

  • raises Invalid_argument

    if n < 0.

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

Access the element.

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

Copy the array and modify its copy.

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

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.

  • since 1.5
val map : ('a -> 'b) -> 'a t -> 'b t
val mapi : (int -> 'a -> 'b) -> 'a t -> 'b t
val append : 'a t -> 'a t -> 'a t
val iter : ('a -> unit) -> 'a t -> unit
val iteri : (int -> 'a -> unit) -> 'a t -> unit
val foldi : ('a -> int -> 'b -> 'a) -> 'a -> 'b t -> 'a
val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a
val for_all : ('a -> bool) -> 'a t -> bool
val exists : ('a -> bool) -> 'a t -> bool

Conversions

type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
val of_list : 'a list -> 'a t
val to_list : 'a t -> 'a list
val of_array_unsafe : 'a array -> 'a t

Take ownership of the given array. Careful, the array must NOT be modified afterwards!

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

IO

type 'a printer = Stdlib.Format.formatter -> 'a -> unit
val pp : ?pp_start:unit printer -> ?pp_stop:unit printer -> ?pp_sep:unit printer -> 'a printer -> 'a t printer

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

\ No newline at end of file +CCImmutArray (containers-data.CCImmutArray)

Module CCImmutArray

Immutable Arrays

Purely 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.

  • since 0.17
type 'a t

Array 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 t
val length : _ t -> int
val singleton : 'a -> 'a t
val doubleton : 'a -> 'a -> 'a t
val make : int -> 'a -> 'a t

make n x makes an array of n times x.

val init : int -> (int -> 'a) -> 'a t

init n f makes the array [| f 0; f 1; ... ; f (n-1) |].

  • raises Invalid_argument

    if n < 0.

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

Access the element.

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

Copy the array and modify its copy.

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

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.

  • since 1.5
val map : ('a -> 'b) -> 'a t -> 'b t
val mapi : (int -> 'a -> 'b) -> 'a t -> 'b t
val append : 'a t -> 'a t -> 'a t
val iter : ('a -> unit) -> 'a t -> unit
val iteri : (int -> 'a -> unit) -> 'a t -> unit
val foldi : ('a -> int -> 'b -> 'a) -> 'a -> 'b t -> 'a
val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a
val for_all : ('a -> bool) -> 'a t -> bool
val exists : ('a -> bool) -> 'a t -> bool

Conversions

type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
val of_list : 'a list -> 'a t
val to_list : 'a t -> 'a list
val of_array_unsafe : 'a array -> 'a t

Take ownership of the given array. Careful, the array must NOT be modified afterwards!

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

IO

type 'a printer = Stdlib.Format.formatter -> 'a -> unit
val pp : ?pp_start:unit printer -> ?pp_stop:unit printer -> ?pp_sep:unit printer -> 'a printer -> 'a t printer

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

\ No newline at end of file diff --git a/dev/containers-data/CCIntMap/index.html b/dev/containers-data/CCIntMap/index.html index 3953a53f..8ee04a16 100644 --- a/dev/containers-data/CCIntMap/index.html +++ b/dev/containers-data/CCIntMap/index.html @@ -1,3 +1,3 @@ -CCIntMap (containers-data.CCIntMap)

Module CCIntMap

Map specialized for Int keys

status: stable

  • since 0.10
type +'a t
val empty : 'a t
val is_empty : _ t -> bool

Is the map empty?

  • since 2.3
val singleton : int -> 'a -> 'a t
val doubleton : int -> 'a -> int -> 'a -> 'a t
val mem : int -> _ t -> bool
val find : int -> 'a t -> 'a option
val find_exn : int -> 'a t -> 'a

Same as find but unsafe.

  • raises Not_found

    if key is not present.

val add : int -> 'a -> 'a t -> 'a t
val remove : int -> 'a t -> 'a t
val equal : eq:('a -> 'a -> bool) -> 'a t -> 'a t -> bool

equal ~eq a b checks whether a and b have the same set of pairs (key, value), comparing values with eq.

  • since 0.13
val compare : cmp:('a -> 'a -> int) -> 'a t -> 'a t -> int

Total order between maps; the precise order is unspecified.

  • since 0.13
val update : int -> ('a option -> 'a option) -> 'a t -> 'a t
val filter : (int -> 'a -> bool) -> 'a t -> 'a t

Filter values using the given predicate

  • since 2.3
val filter_map : (int -> 'a -> 'b option) -> 'a t -> 'b t

Filter-map values using the given function

  • since 2.3
val cardinal : _ t -> int

Number of bindings in the map. Linear time.

val iter : (int -> 'a -> unit) -> 'a t -> unit
val fold : (int -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
val mapi : (int -> 'a -> 'b) -> 'a t -> 'b t
  • since 0.17
val map : ('a -> 'b) -> 'a t -> 'b t
  • since 0.17
val choose : 'a t -> (int * 'a) option
val choose_exn : 'a t -> int * 'a
  • raises Not_found

    if not pair was found.

val union : (int -> 'a -> 'a -> 'a) -> 'a t -> 'a t -> 'a t
val inter : (int -> 'a -> 'a -> 'a) -> 'a t -> 'a t -> 'a t
val merge : f:(int -> [ `Left of 'a | `Right of 'b | `Both of 'a * 'b ] -> 'c option) +CCIntMap (containers-data.CCIntMap)

Module CCIntMap

Map specialized for Int keys

status: stable

  • since 0.10
type +'a t
val empty : 'a t
val is_empty : _ t -> bool

Is the map empty?

  • since 2.3
val singleton : int -> 'a -> 'a t
val doubleton : int -> 'a -> int -> 'a -> 'a t
val mem : int -> _ t -> bool
val find : int -> 'a t -> 'a option
val find_exn : int -> 'a t -> 'a

Same as find but unsafe.

  • raises Not_found

    if key is not present.

val add : int -> 'a -> 'a t -> 'a t
val remove : int -> 'a t -> 'a t
val equal : eq:('a -> 'a -> bool) -> 'a t -> 'a t -> bool

equal ~eq a b checks whether a and b have the same set of pairs (key, value), comparing values with eq.

  • since 0.13
val compare : cmp:('a -> 'a -> int) -> 'a t -> 'a t -> int

Total order between maps; the precise order is unspecified.

  • since 0.13
val update : int -> ('a option -> 'a option) -> 'a t -> 'a t
val filter : (int -> 'a -> bool) -> 'a t -> 'a t

Filter values using the given predicate

  • since 2.3
val filter_map : (int -> 'a -> 'b option) -> 'a t -> 'b t

Filter-map values using the given function

  • since 2.3
val cardinal : _ t -> int

Number of bindings in the map. Linear time.

val iter : (int -> 'a -> unit) -> 'a t -> unit
val fold : (int -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
val mapi : (int -> 'a -> 'b) -> 'a t -> 'b t
  • since 0.17
val map : ('a -> 'b) -> 'a t -> 'b t
  • since 0.17
val choose : 'a t -> (int * 'a) option
val choose_exn : 'a t -> int * 'a
  • raises Not_found

    if not pair was found.

val union : (int -> 'a -> 'a -> 'a) -> 'a t -> 'a t -> 'a t
val inter : (int -> 'a -> 'a -> 'a) -> 'a t -> 'a t -> 'a t
val merge : f:(int -> [ `Left of 'a | `Right of 'b | `Both of 'a * 'b ] -> 'c option) -> 'a t -> 'b t -> 'c t

merge ~f m1 m2 merges m1 and m2 together, calling f once on every key that occurs in at least one of m1 and m2. if f k binding = Some c then k -> c is part of the result, else k is not part of the result.

  • since 2.3

Whole-collection operations

type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
val add_list : 'a t -> (int * 'a) list -> 'a t
val of_list : (int * 'a) list -> 'a t
val to_list : 'a t -> (int * 'a) list
val add_iter : 'a t -> (int * 'a) iter -> 'a t
val of_iter : (int * 'a) iter -> 'a t
val to_iter : 'a t -> (int * 'a) iter
val keys : _ t -> int iter
val values : 'a t -> 'a iter
val add_gen : 'a t -> (int * 'a) gen -> 'a t
  • since 0.13
val of_gen : (int * 'a) gen -> 'a t
  • since 0.13
val to_gen : 'a t -> (int * 'a) gen
  • since 0.13
val add_seq : 'a t -> (int * 'a) Stdlib.Seq.t -> 'a t
  • since 3.0
val of_seq : (int * 'a) Stdlib.Seq.t -> 'a t
  • since 3.0
val to_seq : 'a t -> (int * 'a) Stdlib.Seq.t
  • since 3.0
type 'a tree = unit -> [ `Nil | `Node of 'a * 'a tree list ]
val as_tree : 'a t -> [ `Node of int * int | `Leaf of int * 'a ] tree

IO

type 'a printer = Stdlib.Format.formatter -> 'a -> unit
val pp : 'a printer -> 'a t printer
  • since 0.13

Helpers

\ No newline at end of file diff --git a/dev/containers-data/CCKTree/index.html b/dev/containers-data/CCKTree/index.html index f190d528..14f7d30c 100644 --- a/dev/containers-data/CCKTree/index.html +++ b/dev/containers-data/CCKTree/index.html @@ -1,5 +1,5 @@ -CCKTree (containers-data.CCKTree)

Module CCKTree

Lazy Tree Structure

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.

type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
type 'a printer = Stdlib.Format.formatter -> 'a -> unit

Basics

type +'a t = unit -> [ `Nil | `Node of 'a * 'a t list ]
val empty : 'a t
val is_empty : _ t -> bool
val singleton : 'a -> 'a t

Tree with only one label.

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

Build a node from a label and a list of children.

val node1 : 'a -> 'a t -> 'a t

Node with one child.

val node2 : 'a -> 'a t -> 'a t -> 'a t

Node with two children.

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

Fold on values in no specified order. May not terminate if the tree is infinite.

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

Number of elements.

val height : _ t -> int

Length of the longest path to empty leaves.

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

Cut the tree at the given depth, so it becomes finite.

Graph Traversals

class type 'a pset = object ... end

Abstract Set structure

val set_of_cmp : cmp:('a -> 'a -> int) -> unit -> 'a pset

Build a set structure given a total ordering.

val dfs : pset:'a pset -> 'a t -> [ `Enter of 'a | `Exit of 'a ] Stdlib.Seq.t

Depth-first traversal of the tree.

val bfs : pset:'a pset -> 'a t -> 'a Stdlib.Seq.t

Breadth-first traversal of the tree.

val force : 'a t -> [ `Nil | `Node of 'a * 'b list ] as 'b

force t evaluates t completely and returns a regular tree structure.

  • since 0.13
val find : pset:'a pset -> ('a -> 'b option) -> 'a t -> 'b option

Look for an element that maps to Some _.

Pretty-printing

Example (tree of calls for naive Fibonacci function):

let mk_fib n =
+CCKTree (containers-data.CCKTree)

Module CCKTree

Lazy Tree Structure 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.

type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
type 'a printer = Stdlib.Format.formatter -> 'a -> unit

Basics

type +'a t = unit -> [ `Nil | `Node of 'a * 'a t list ]
val empty : 'a t
val is_empty : _ t -> bool
val singleton : 'a -> 'a t

Tree with only one label.

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

Build a node from a label and a list of children.

val node1 : 'a -> 'a t -> 'a t

Node with one child.

val node2 : 'a -> 'a t -> 'a t -> 'a t

Node with two children.

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

Fold on values in no specified order. May not terminate if the tree is infinite.

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

Number of elements.

val height : _ t -> int

Length of the longest path to empty leaves.

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

Cut the tree at the given depth, so it becomes finite.

Graph Traversals

class type 'a pset = object ... end

Abstract Set structure

val set_of_cmp : cmp:('a -> 'a -> int) -> unit -> 'a pset

Build a set structure given a total ordering.

val dfs : pset:'a pset -> 'a t -> [ `Enter of 'a | `Exit of 'a ] Stdlib.Seq.t

Depth-first traversal of the tree.

val bfs : pset:'a pset -> 'a t -> 'a Stdlib.Seq.t

Breadth-first traversal of the tree.

val force : 'a t -> [ `Nil | `Node of 'a * 'b list ] as 'b

force t evaluates t completely and returns a regular tree structure.

  • since 0.13
val find : pset:'a pset -> ('a -> 'b option) -> 'a t -> 'b option

Look for an element that maps to Some _.

Pretty-printing

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;;
diff --git a/dev/containers-data/CCLazy_list/index.html b/dev/containers-data/CCLazy_list/index.html
index dbe4106a..990bb1f4 100644
--- a/dev/containers-data/CCLazy_list/index.html
+++ b/dev/containers-data/CCLazy_list/index.html
@@ -1,2 +1,2 @@
 
-CCLazy_list (containers-data.CCLazy_list)

Module CCLazy_list

Lazy List

  • since 0.17
type +'a t = 'a node lazy_t
and +'a node =
| Nil
| Cons of 'a * 'a t
val empty : 'a t

Empty list.

val return : 'a -> 'a t

Return a computed value.

val is_empty : _ t -> bool

Evaluate the head.

val length : _ t -> int

length l returns the number of elements in l, eagerly (linear time). Caution, will not terminate if l is infinite.

val cons : 'a -> 'a t -> 'a t
val head : 'a t -> ('a * 'a t) option

Evaluate head, return it, or None if the list is empty.

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

Lazy map.

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

Filter values.

  • since 0.18
val take : int -> 'a t -> 'a t

Take at most n values.

  • since 0.18
val append : 'a t -> 'a t -> 'a t

Lazy concatenation.

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

Monadic flatten + map.

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

Choice operator.

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

Alias to default.

  • since 2.1
type 'a gen = unit -> 'a option
val of_gen : 'a gen -> 'a t
val of_list : 'a list -> 'a t
val to_list : 'a t -> 'a list
val to_list_rev : 'a t -> 'a list
val to_gen : 'a t -> 'a gen
\ No newline at end of file +CCLazy_list (containers-data.CCLazy_list)

Module CCLazy_list

Lazy List

  • since 0.17
type +'a t = 'a node lazy_t
and +'a node =
| Nil
| Cons of 'a * 'a t
val empty : 'a t

Empty list.

val return : 'a -> 'a t

Return a computed value.

val is_empty : _ t -> bool

Evaluate the head.

val length : _ t -> int

length l returns the number of elements in l, eagerly (linear time). Caution, will not terminate if l is infinite.

val cons : 'a -> 'a t -> 'a t
val head : 'a t -> ('a * 'a t) option

Evaluate head, return it, or None if the list is empty.

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

Lazy map.

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

Filter values.

  • since 0.18
val take : int -> 'a t -> 'a t

Take at most n values.

  • since 0.18
val append : 'a t -> 'a t -> 'a t

Lazy concatenation.

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

Monadic flatten + map.

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

Choice operator.

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

Alias to default.

  • since 2.1
type 'a gen = unit -> 'a option
val of_gen : 'a gen -> 'a t
val of_list : 'a list -> 'a t
val to_list : 'a t -> 'a list
val to_list_rev : 'a t -> 'a list
val to_gen : 'a t -> 'a gen
\ No newline at end of file diff --git a/dev/containers-data/CCMixmap/index.html b/dev/containers-data/CCMixmap/index.html index 14a14552..698f9587 100644 --- a/dev/containers-data/CCMixmap/index.html +++ b/dev/containers-data/CCMixmap/index.html @@ -1,5 +1,5 @@ -CCMixmap (containers-data.CCMixmap)

Module CCMixmap

Maps with Heterogeneous Values

status: experimental

module M = CCMixmap.Make(CCInt)
+CCMixmap (containers-data.CCMixmap)

Module CCMixmap

Maps with Heterogeneous Values

status: experimental

module M = CCMixmap.Make(CCInt)
 
 let inj_int = CCMixmap.create_inj()
 let inj_str = CCMixmap.create_inj()
@@ -16,4 +16,4 @@ let m =
     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.

  • since 0.9
type 'a injection

An 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 injection

Return 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 ... end
module type ORD = sig ... end
module Make (X : ORD) : S with type key = X.t
\ No newline at end of file + 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.

  • since 0.9
type 'a injection

An 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 injection

Return 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 ... end
module type ORD = sig ... end
module Make (X : ORD) : S with type key = X.t
\ No newline at end of file diff --git a/dev/containers-data/CCMixset/index.html b/dev/containers-data/CCMixset/index.html index 2c7ffe67..b1f304b4 100644 --- a/dev/containers-data/CCMixset/index.html +++ b/dev/containers-data/CCMixset/index.html @@ -1,5 +1,5 @@ -CCMixset (containers-data.CCMixset)

Module CCMixset

Set of Heterogeneous Values

let k1 : int key = newkey () in
+CCMixset (containers-data.CCMixset)

Module CCMixset

Set of Heterogeneous Values

let k1 : int key = newkey () in
 let k2 : int key = newkey () in
 let k3 : string key = newkey () in
 let set =
@@ -11,4 +11,4 @@ in
 assert (get ~key:k1 set = Some 1);
 assert (get ~key:k2 set = Some 2);
 assert (get ~key:k3 set = Some "3");
-()
  • since 0.11
type t

A set of values of heterogeneous types

type 'a key

A unique "key" to access a value of type 'a in a set

val newkey : unit -> 'a key

newkey () 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.

val empty : t

Empty set.

val set : key:'a key -> 'a -> t -> t

set ~key v set maps key to v in set. It means that for every set, get ~key (set ~key v set) = Some v.

val get : key:'a key -> t -> 'a option

get ~key set obtains the value for key in set, if any.

val get_exn : key:'a key -> t -> 'a

Same as get, but can fail.

  • raises Not_found

    if the key is not present.

val cardinal : t -> int

Number of mappings.

\ No newline at end of file +()
  • since 0.11
type t

A set of values of heterogeneous types

type 'a key

A unique "key" to access a value of type 'a in a set

val newkey : unit -> 'a key

newkey () 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.

val empty : t

Empty set.

val set : key:'a key -> 'a -> t -> t

set ~key v set maps key to v in set. It means that for every set, get ~key (set ~key v set) = Some v.

val get : key:'a key -> t -> 'a option

get ~key set obtains the value for key in set, if any.

val get_exn : key:'a key -> t -> 'a

Same as get, but can fail.

  • raises Not_found

    if the key is not present.

val cardinal : t -> int

Number of mappings.

\ No newline at end of file diff --git a/dev/containers-data/CCMixtbl/index.html b/dev/containers-data/CCMixtbl/index.html index 507cd00f..51448b5b 100644 --- a/dev/containers-data/CCMixtbl/index.html +++ b/dev/containers-data/CCMixtbl/index.html @@ -1,5 +1,5 @@ -CCMixtbl (containers-data.CCMixtbl)

Module CCMixtbl

Hash Table with Heterogeneous Keys

From https://github.com/mjambon/mixtbl (thanks to him). Example:

let inj_int = CCMixtbl.create_inj () ;;
+CCMixtbl (containers-data.CCMixtbl)

Module CCMixtbl

Hash Table with Heterogeneous Keys

From https://github.com/mjambon/mixtbl (thanks to him). Example:

let inj_int = CCMixtbl.create_inj () ;;
 
 let tbl = CCMixtbl.create 10 ;;
 
@@ -19,4 +19,4 @@ 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");;
  • since 0.6
type 'a t

A hash table containing values of different types. The type parameter 'a represents the type of the keys.

type 'b injection

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

create n creates a hash table of initial size n.

val create_inj : unit -> 'b injection

Return 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).

val get : inj:'b injection -> 'a t -> 'a -> 'b option

Get the value corresponding to this key, if it exists and belongs to the same key.

val set : inj:'b injection -> 'a t -> 'a -> 'b -> unit

Bind the key to the value, using inj.

val find : inj:'b injection -> 'a t -> 'a -> 'b

Find the value for the given key, which must be of the right type.

  • raises Not_found

    if either the key is not found, or if its value doesn't belong to the right type.

val length : 'a t -> int

Number of bindings.

val clear : 'a t -> unit

Clear content of the hashtable.

val remove : 'a t -> 'a -> unit

Remove the binding for this key.

val copy : 'a t -> 'a t

Copy of the table.

val mem : inj:_ injection -> 'a t -> 'a -> bool

Is the given key in the table, with the right type?

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

Iterate on the keys of this table.

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

Fold over the keys.

Iterators

type 'a iter = ('a -> unit) -> unit
val keys_iter : 'a t -> 'a iter

All the keys.

val bindings_of : inj:'b injection -> 'a t -> ('a * 'b) iter

All the bindings that come from the corresponding injection.

type value =
| Value : ('b injection -> 'b option) -> value
val bindings : 'a t -> ('a * value) iter

Iterate on all bindings.

\ No newline at end of file +OUnit.assert_equal (Some "Bye") (CCMixtbl.get inj_string tbl "a");;
  • since 0.6
type 'a t

A hash table containing values of different types. The type parameter 'a represents the type of the keys.

type 'b injection

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

create n creates a hash table of initial size n.

val create_inj : unit -> 'b injection

Return 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).

val get : inj:'b injection -> 'a t -> 'a -> 'b option

Get the value corresponding to this key, if it exists and belongs to the same key.

val set : inj:'b injection -> 'a t -> 'a -> 'b -> unit

Bind the key to the value, using inj.

val find : inj:'b injection -> 'a t -> 'a -> 'b

Find the value for the given key, which must be of the right type.

  • raises Not_found

    if either the key is not found, or if its value doesn't belong to the right type.

val length : 'a t -> int

Number of bindings.

val clear : 'a t -> unit

Clear content of the hashtable.

val remove : 'a t -> 'a -> unit

Remove the binding for this key.

val copy : 'a t -> 'a t

Copy of the table.

val mem : inj:_ injection -> 'a t -> 'a -> bool

Is the given key in the table, with the right type?

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

Iterate on the keys of this table.

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

Fold over the keys.

Iterators

type 'a iter = ('a -> unit) -> unit
val keys_iter : 'a t -> 'a iter

All the keys.

val bindings_of : inj:'b injection -> 'a t -> ('a * 'b) iter

All the bindings that come from the corresponding injection.

type value =
| Value : ('b injection -> 'b option) -> value
val bindings : 'a t -> ('a * value) iter

Iterate on all bindings.

\ No newline at end of file diff --git a/dev/containers-data/CCMultiMap/index.html b/dev/containers-data/CCMultiMap/index.html index ccdfcb41..4bc62930 100644 --- a/dev/containers-data/CCMultiMap/index.html +++ b/dev/containers-data/CCMultiMap/index.html @@ -1,2 +1,2 @@ -CCMultiMap (containers-data.CCMultiMap)

Module CCMultiMap

Multimap

type 'a iter = ('a -> unit) -> unit
module type S = sig ... end
module type OrderedType = sig ... end
module Make (K : OrderedType) (V : OrderedType) : S with type key = K.t and type value = V.t

Two-Way Multimap

Represents n-to-n mappings between two types. Each element from the "left" is mapped to several right values, and conversely.

  • since 0.3.3
module type BIDIR = sig ... end
module MakeBidir (L : OrderedType) (R : OrderedType) : BIDIR with type left = L.t and type right = R.t
\ No newline at end of file +CCMultiMap (containers-data.CCMultiMap)

Module CCMultiMap

Map that can map key to several values

type 'a iter = ('a -> unit) -> unit
module type S = sig ... end
module type OrderedType = sig ... end
module Make (K : OrderedType) (V : OrderedType) : S with type key = K.t and type value = V.t

Two-Way Multimap

Represents n-to-n mappings between two types. Each element from the "left" is mapped to several right values, and conversely.

  • since 0.3.3
module type BIDIR = sig ... end
module MakeBidir (L : OrderedType) (R : OrderedType) : BIDIR with type left = L.t and type right = R.t
\ No newline at end of file diff --git a/dev/containers-data/CCMultiSet/index.html b/dev/containers-data/CCMultiSet/index.html index e31e6bd7..6ef0cb75 100644 --- a/dev/containers-data/CCMultiSet/index.html +++ b/dev/containers-data/CCMultiSet/index.html @@ -1,2 +1,2 @@ -CCMultiSet (containers-data.CCMultiSet)

Module CCMultiSet

Multiset

type 'a iter = ('a -> unit) -> unit
module type S = sig ... end
module Make (O : Stdlib.Set.OrderedType) : S with type elt = O.t
\ No newline at end of file +CCMultiSet (containers-data.CCMultiSet)

Module CCMultiSet

Multiset

type 'a iter = ('a -> unit) -> unit
module type S = sig ... end
module Make (O : Stdlib.Set.OrderedType) : S with type elt = O.t
\ No newline at end of file diff --git a/dev/containers-data/CCMutHeap/index.html b/dev/containers-data/CCMutHeap/index.html index 86c4d2d9..9dff272f 100644 --- a/dev/containers-data/CCMutHeap/index.html +++ b/dev/containers-data/CCMutHeap/index.html @@ -1,2 +1,2 @@ -CCMutHeap (containers-data.CCMutHeap)

Module CCMutHeap

Mutable Heaps

The classic binary heap in a vector.

STATUS: experimental, this might change in breaking ways.

  • since 3.1
module type RANKED = CCMutHeap_intf.RANKED
module type S = CCMutHeap_intf.S
module Make (X : RANKED) : S with type elt = X.t
\ No newline at end of file +CCMutHeap (containers-data.CCMutHeap)

Module CCMutHeap

Mutable Heaps

The classic binary heap in a vector.

STATUS: experimental, this might change in breaking ways.

  • since 3.1
module type RANKED = CCMutHeap_intf.RANKED
module type S = CCMutHeap_intf.S
module Make (X : RANKED) : S with type elt = X.t
\ No newline at end of file diff --git a/dev/containers-data/CCPersistentArray/index.html b/dev/containers-data/CCPersistentArray/index.html index 5d06bbbf..2ad31d2b 100644 --- a/dev/containers-data/CCPersistentArray/index.html +++ b/dev/containers-data/CCPersistentArray/index.html @@ -1,2 +1,2 @@ -CCPersistentArray (containers-data.CCPersistentArray)

Module CCPersistentArray

Persistent Arrays

From the paper by Jean-Christophe Filliâtre, "A persistent Union-Find data structure", see the ps version

  • since 0.10
type 'a t

The type of persistent arrays

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

make 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.

  • raises Invalid_argument

    if 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 t

init n f returns a persistent array of length n, with element i initialized to the result of f i.

  • raises Invalid_argument

    if 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 -> 'a

get a i returns the element with index i from the array a.

  • raises Invalid_argument

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

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

set a i v sets the element index i from the array a to v.

  • raises Invalid_argument

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

val length : 'a t -> int

Return the length of the persistent array.

val copy : 'a t -> 'a t

copy a returns a fresh copy of a. Both copies are independent.

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

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 -> unit

iter 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 -> unit

iter 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 -> 'a
val fold_right : ('a -> 'b -> 'b) -> 'a t -> 'b -> 'b

Fold on the elements of the array.

val append : 'a t -> 'a t -> 'a t

Append the two arrays.

  • since 0.13
val flatten : 'a t t -> 'a t

Concatenates all the sub-arrays.

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

Flat map (map + concatenation).

  • since 0.13
val to_array : 'a t -> 'a array

to_array t returns a mutable copy of t.

val of_array : 'a array -> 'a t

of_array a returns an immutable copy of a.

val to_list : 'a t -> 'a list

to_list t returns the list of elements in t.

val of_list : 'a list -> 'a t

of_list l returns a fresh persistent array containing the elements of l.

val of_rev_list : 'a list -> 'a t

of_rev_list l is the same as of_list (List.rev l) but more efficient.

  • since 0.13

Conversions

type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
val to_iter : 'a t -> 'a iter
val of_iter : 'a iter -> 'a t
val of_gen : 'a gen -> 'a t
  • since 0.13
val to_gen : 'a t -> 'a gen
  • since 0.13

IO

type 'a printer = Stdlib.Format.formatter -> 'a -> unit
val pp : 'a printer -> 'a t printer
  • since 0.13
\ No newline at end of file +CCPersistentArray (containers-data.CCPersistentArray)

Module CCPersistentArray

Persistent Arrays

From the paper by Jean-Christophe Filliâtre, "A persistent Union-Find data structure", see the ps version

  • since 0.10
type 'a t

The type of persistent arrays

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

make 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.

  • raises Invalid_argument

    if 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 t

init n f returns a persistent array of length n, with element i initialized to the result of f i.

  • raises Invalid_argument

    if 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 -> 'a

get a i returns the element with index i from the array a.

  • raises Invalid_argument

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

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

set a i v sets the element index i from the array a to v.

  • raises Invalid_argument

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

val length : 'a t -> int

Return the length of the persistent array.

val copy : 'a t -> 'a t

copy a returns a fresh copy of a. Both copies are independent.

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

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 -> unit

iter 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 -> unit

iter 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 -> 'a
val fold_right : ('a -> 'b -> 'b) -> 'a t -> 'b -> 'b

Fold on the elements of the array.

val append : 'a t -> 'a t -> 'a t

Append the two arrays.

  • since 0.13
val flatten : 'a t t -> 'a t

Concatenates all the sub-arrays.

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

Flat map (map + concatenation).

  • since 0.13
val to_array : 'a t -> 'a array

to_array t returns a mutable copy of t.

val of_array : 'a array -> 'a t

of_array a returns an immutable copy of a.

val to_list : 'a t -> 'a list

to_list t returns the list of elements in t.

val of_list : 'a list -> 'a t

of_list l returns a fresh persistent array containing the elements of l.

val of_rev_list : 'a list -> 'a t

of_rev_list l is the same as of_list (List.rev l) but more efficient.

  • since 0.13

Conversions

type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
val to_iter : 'a t -> 'a iter
val of_iter : 'a iter -> 'a t
val of_gen : 'a gen -> 'a t
  • since 0.13
val to_gen : 'a t -> 'a gen
  • since 0.13

IO

type 'a printer = Stdlib.Format.formatter -> 'a -> unit
val pp : 'a printer -> 'a t printer
  • since 0.13
\ No newline at end of file diff --git a/dev/containers-data/CCPersistentHashtbl/index.html b/dev/containers-data/CCPersistentHashtbl/index.html index 39808b77..b427ed27 100644 --- a/dev/containers-data/CCPersistentHashtbl/index.html +++ b/dev/containers-data/CCPersistentHashtbl/index.html @@ -1,2 +1,2 @@ -CCPersistentHashtbl (containers-data.CCPersistentHashtbl)

Module CCPersistentHashtbl

Persistent hash-table on top of OCaml's hashtables

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.

type 'a iter = ('a -> unit) -> unit
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a equal = 'a -> 'a -> bool
module type HashedType = sig ... end

Signature of such a hashtable

module type S = sig ... end

Implementation

module Make (H : HashedType) : S with type key = H.t
\ No newline at end of file +CCPersistentHashtbl (containers-data.CCPersistentHashtbl)

Module CCPersistentHashtbl

Persistent hash-table on top of OCaml's hashtables

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.

type 'a iter = ('a -> unit) -> unit
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a equal = 'a -> 'a -> bool
module type HashedType = sig ... end

Signature of such a hashtable

module type S = sig ... end

Implementation

module Make (H : HashedType) : S with type key = H.t
\ No newline at end of file diff --git a/dev/containers-data/CCRAL/index.html b/dev/containers-data/CCRAL/index.html index 9c38c493..0a5848fc 100644 --- a/dev/containers-data/CCRAL/index.html +++ b/dev/containers-data/CCRAL/index.html @@ -1,2 +1,2 @@ -CCRAL (containers-data.CCRAL)

Module CCRAL

Random-Access Lists

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

  • since 0.13
type +'a t

List containing elements of type 'a

val empty : 'a t

Empty list.

val is_empty : _ t -> bool

Check whether the list is empty.

val cons : 'a -> 'a t -> 'a t

Add an element at the front of the list.

val return : 'a -> 'a t

Singleton.

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

Map on elements.

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

Map with index.

val hd : 'a t -> 'a

First element of the list, or

  • raises Invalid_argument

    if the list is empty.

val tl : 'a t -> 'a t

Remove the first element from the list, or

  • raises Invalid_argument

    if the list is empty.

val front : 'a t -> ('a * 'a t) option

Remove and return the first element of the list.

val front_exn : 'a t -> 'a * 'a t

Unsafe version of front.

  • raises Invalid_argument

    if the list is empty.

val length : 'a t -> int

Number of elements. Complexity O(ln n) where n=number of elements.

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

get l i accesses the i-th element of the list. O(log(n)).

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

Unsafe version of get.

  • raises Invalid_argument

    if the list has less than i+1 elements.

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

set l i v sets the i-th element of the list to v. O(log(n)).

  • raises Invalid_argument

    if the list has less than i+1 elements.

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

remove l i removes the i-th element of l.

  • raises Invalid_argument

    if the list has less than i+1 elements.

val get_and_remove_exn : 'a t -> int -> 'a * 'a t

get_and_remove_exn l i accesses and removes the i-th element of l.

  • raises Invalid_argument

    if the list has less than i+1 elements.

val append : 'a t -> 'a t -> 'a t
val filter : f:('a -> bool) -> 'a t -> 'a t
val filter_map : f:('a -> 'b option) -> 'a t -> 'b t
val flat_map : ('a -> 'b t) -> 'a t -> 'b t
val flatten : 'a t t -> 'a t
val app : ('a -> 'b) t -> 'a t -> 'b t
val take : int -> 'a t -> 'a t
val take_while : f:('a -> bool) -> 'a t -> 'a t
val drop : int -> 'a t -> 'a t
val drop_while : f:('a -> bool) -> 'a t -> 'a t
val take_drop : int -> 'a t -> 'a t * 'a t

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

Iterate on the list's elements.

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

Fold on the list's elements.

val fold_rev : f:('b -> 'a -> 'b) -> x:'b -> 'a t -> 'b

Fold on the list's elements, in reverse order (starting from the tail).

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

rev_map f l is the same as map f (rev l).

val rev : 'a t -> 'a t

Reverse the list.

val equal : eq:('a -> 'a -> bool) -> 'a t -> 'a t -> bool
val compare : cmp:('a -> 'a -> int) -> 'a t -> 'a t -> int

Lexicographic comparison.

Utils

val make : int -> 'a -> 'a t
val repeat : int -> 'a t -> 'a t

repeat n l is append l (append l ... l) n times.

val range : int -> int -> int t

range i j is i; i+1; ... ; j or j; j-1; ...; i.

Conversions

type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
val add_list : 'a t -> 'a list -> 'a t
val of_list : 'a list -> 'a t

Convert a list to a RAL. Caution: non tail-rec.

val to_list : 'a t -> 'a list
val of_list_map : f:('a -> 'b) -> 'a list -> 'b t

Combination of of_list and map.

val of_array : 'a array -> 'a t
val add_array : 'a t -> 'a array -> 'a t
val to_array : 'a t -> 'a array

More efficient than on usual lists.

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

Infix

module Infix : sig ... end
include module type of Infix
val (@+) : 'a -> 'a t -> 'a t

Cons (alias to cons).

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

Alias to flat_map.

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

Alias to map.

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

Alias to app.

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

Alias to range.

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

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

  • since 0.17

IO

type 'a printer = Stdlib.Format.formatter -> 'a -> unit
val pp : ?pp_sep:unit printer -> 'a printer -> 'a t printer
\ No newline at end of file +CCRAL (containers-data.CCRAL)

Module CCRAL

Random-Access Lists

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

  • since 0.13
type +'a t

List containing elements of type 'a

val empty : 'a t

Empty list.

val is_empty : _ t -> bool

Check whether the list is empty.

val cons : 'a -> 'a t -> 'a t

Add an element at the front of the list.

val return : 'a -> 'a t

Singleton.

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

Map on elements.

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

Map with index.

val hd : 'a t -> 'a

First element of the list, or

  • raises Invalid_argument

    if the list is empty.

val tl : 'a t -> 'a t

Remove the first element from the list, or

  • raises Invalid_argument

    if the list is empty.

val front : 'a t -> ('a * 'a t) option

Remove and return the first element of the list.

val front_exn : 'a t -> 'a * 'a t

Unsafe version of front.

  • raises Invalid_argument

    if the list is empty.

val length : 'a t -> int

Number of elements. Complexity O(ln n) where n=number of elements.

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

get l i accesses the i-th element of the list. O(log(n)).

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

Unsafe version of get.

  • raises Invalid_argument

    if the list has less than i+1 elements.

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

set l i v sets the i-th element of the list to v. O(log(n)).

  • raises Invalid_argument

    if the list has less than i+1 elements.

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

remove l i removes the i-th element of l.

  • raises Invalid_argument

    if the list has less than i+1 elements.

val get_and_remove_exn : 'a t -> int -> 'a * 'a t

get_and_remove_exn l i accesses and removes the i-th element of l.

  • raises Invalid_argument

    if the list has less than i+1 elements.

val append : 'a t -> 'a t -> 'a t
val filter : f:('a -> bool) -> 'a t -> 'a t
val filter_map : f:('a -> 'b option) -> 'a t -> 'b t
val flat_map : ('a -> 'b t) -> 'a t -> 'b t
val flatten : 'a t t -> 'a t
val app : ('a -> 'b) t -> 'a t -> 'b t
val take : int -> 'a t -> 'a t
val take_while : f:('a -> bool) -> 'a t -> 'a t
val drop : int -> 'a t -> 'a t
val drop_while : f:('a -> bool) -> 'a t -> 'a t
val take_drop : int -> 'a t -> 'a t * 'a t

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

Iterate on the list's elements.

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

Fold on the list's elements.

val fold_rev : f:('b -> 'a -> 'b) -> x:'b -> 'a t -> 'b

Fold on the list's elements, in reverse order (starting from the tail).

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

rev_map f l is the same as map f (rev l).

val rev : 'a t -> 'a t

Reverse the list.

val equal : eq:('a -> 'a -> bool) -> 'a t -> 'a t -> bool
val compare : cmp:('a -> 'a -> int) -> 'a t -> 'a t -> int

Lexicographic comparison.

Utils

val make : int -> 'a -> 'a t
val repeat : int -> 'a t -> 'a t

repeat n l is append l (append l ... l) n times.

val range : int -> int -> int t

range i j is i; i+1; ... ; j or j; j-1; ...; i.

Conversions

type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
val add_list : 'a t -> 'a list -> 'a t
val of_list : 'a list -> 'a t

Convert a list to a RAL. Caution: non tail-rec.

val to_list : 'a t -> 'a list
val of_list_map : f:('a -> 'b) -> 'a list -> 'b t

Combination of of_list and map.

val of_array : 'a array -> 'a t
val add_array : 'a t -> 'a array -> 'a t
val to_array : 'a t -> 'a array

More efficient than on usual lists.

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

Infix

module Infix : sig ... end
include module type of Infix
val (@+) : 'a -> 'a t -> 'a t

Cons (alias to cons).

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

Alias to flat_map.

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

Alias to map.

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

Alias to app.

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

Alias to range.

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

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

  • since 0.17

IO

type 'a printer = Stdlib.Format.formatter -> 'a -> unit
val pp : ?pp_sep:unit printer -> 'a printer -> 'a t printer
\ No newline at end of file diff --git a/dev/containers-data/CCRingBuffer/index.html b/dev/containers-data/CCRingBuffer/index.html index dc5834c6..4c465c19 100644 --- a/dev/containers-data/CCRingBuffer/index.html +++ b/dev/containers-data/CCRingBuffer/index.html @@ -1,2 +1,2 @@ -CCRingBuffer (containers-data.CCRingBuffer)

Module CCRingBuffer

Circular Buffer (Deque)

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

  • since 0.9

Underlying Array

module Array : sig ... end

The abstract type for arrays

module type S = sig ... end
module Byte : S with module Array = Array.Byte

An efficient byte based ring buffer

module MakeFromArray (A : Array.S) : S with module Array = A

Makes a ring buffer module with the given array type

module Make (X : sig ... end) : S with type Array.elt = X.t and type Array.t = X.t array

Buffer using regular arrays

\ No newline at end of file +CCRingBuffer (containers-data.CCRingBuffer)

Module CCRingBuffer

Circular Buffer (Deque)

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

  • since 0.9

Underlying Array

module Array : sig ... end

The abstract type for arrays

module type S = sig ... end
module Byte : S with module Array = Array.Byte

An efficient byte based ring buffer

module MakeFromArray (A : Array.S) : S with module Array = A

Makes a ring buffer module with the given array type

module Make (X : sig ... end) : S with type Array.elt = X.t and type Array.t = X.t array

Buffer using regular arrays

\ No newline at end of file diff --git a/dev/containers-data/CCSimple_queue/index.html b/dev/containers-data/CCSimple_queue/index.html index 858d441e..3c185448 100644 --- a/dev/containers-data/CCSimple_queue/index.html +++ b/dev/containers-data/CCSimple_queue/index.html @@ -1,2 +1,2 @@ -CCSimple_queue (containers-data.CCSimple_queue)

Module CCSimple_queue

Functional queues (fifo)

Simple implementation of functional queues

  • since 1.3
type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

  • since 2.8
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a gen = unit -> 'a option
type +'a t

Queue containing elements of type 'a

val empty : 'a t
val is_empty : 'a t -> bool
val push : 'a -> 'a t -> 'a t

Push element at the end of the queue.

val snoc : 'a t -> 'a -> 'a t

Flip version of push.

val peek : 'a t -> 'a option

First element of the queue.

val peek_exn : 'a t -> 'a

Same as peek but

  • raises Invalid_argument

    if the queue is empty.

val pop : 'a t -> ('a * 'a t) option

Get and remove the first element.

val pop_exn : 'a t -> 'a * 'a t

Same as pop, but fails on empty queues.

  • raises Invalid_argument

    if the queue is empty.

val junk : 'a t -> 'a t

Remove first element. If the queue is empty, do nothing.

val append : 'a t -> 'a t -> 'a t

Append two queues. Elements from the second one come after elements of the first one. Linear in the size of the second queue.

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

Map values.

val rev : 'a t -> 'a t

Reverse the queue. Constant time.

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

Alias to map.

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

Alias to append.

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

Alias to snoc.

val length : 'a t -> int

Number of elements in the queue (linear in time).

val fold : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'b
val iter : ('a -> unit) -> 'a t -> unit
val to_list : 'a t -> 'a list
val add_list : 'a t -> 'a list -> 'a t
val of_list : 'a list -> 'a t
val to_iter : 'a t -> 'a iter
val add_iter : 'a t -> 'a iter -> 'a t
val of_iter : 'a iter -> 'a t
val to_seq : 'a t -> 'a Stdlib.Seq.t

Renamed from to_std_seq since 3.0.

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

Renamed from add_std_seq since 3.0.

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

Renamed from of_std_seq since 3.0.

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

IO

val pp : ?sep:unit printer -> 'a printer -> 'a t printer
\ No newline at end of file +CCSimple_queue (containers-data.CCSimple_queue)

Module CCSimple_queue

Functional queues (fifo)

Simple implementation of functional queues

  • since 1.3
type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

  • since 2.8
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a gen = unit -> 'a option
type +'a t

Queue containing elements of type 'a

val empty : 'a t
val is_empty : 'a t -> bool
val push : 'a -> 'a t -> 'a t

Push element at the end of the queue.

val snoc : 'a t -> 'a -> 'a t

Flip version of push.

val peek : 'a t -> 'a option

First element of the queue.

val peek_exn : 'a t -> 'a

Same as peek but

  • raises Invalid_argument

    if the queue is empty.

val pop : 'a t -> ('a * 'a t) option

Get and remove the first element.

val pop_exn : 'a t -> 'a * 'a t

Same as pop, but fails on empty queues.

  • raises Invalid_argument

    if the queue is empty.

val junk : 'a t -> 'a t

Remove first element. If the queue is empty, do nothing.

val append : 'a t -> 'a t -> 'a t

Append two queues. Elements from the second one come after elements of the first one. Linear in the size of the second queue.

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

Map values.

val rev : 'a t -> 'a t

Reverse the queue. Constant time.

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

Alias to map.

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

Alias to append.

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

Alias to snoc.

val length : 'a t -> int

Number of elements in the queue (linear in time).

val fold : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'b
val iter : ('a -> unit) -> 'a t -> unit
val to_list : 'a t -> 'a list
val add_list : 'a t -> 'a list -> 'a t
val of_list : 'a list -> 'a t
val to_iter : 'a t -> 'a iter
val add_iter : 'a t -> 'a iter -> 'a t
val of_iter : 'a iter -> 'a t
val to_seq : 'a t -> 'a Stdlib.Seq.t

Renamed from to_std_seq since 3.0.

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

Renamed from add_std_seq since 3.0.

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

Renamed from of_std_seq since 3.0.

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

IO

val pp : ?sep:unit printer -> 'a printer -> 'a t printer
\ No newline at end of file diff --git a/dev/containers-data/CCTrie/index.html b/dev/containers-data/CCTrie/index.html index 5769e037..868ec9d2 100644 --- a/dev/containers-data/CCTrie/index.html +++ b/dev/containers-data/CCTrie/index.html @@ -1,2 +1,2 @@ -CCTrie (containers-data.CCTrie)

Module CCTrie

Prefix Tree

type 'a iter = ('a -> unit) -> unit
type 'a ktree = unit -> [ `Nil | `Node of 'a * 'a ktree list ]

Signatures

A Composite Word

Words are made of characters, who belong to a total order

module type WORD = sig ... end
module type S = sig ... end

Implementation

module Make (W : WORD) : S with type key = W.t and type char_ = W.char_
module type ORDERED = sig ... end
module MakeArray (X : ORDERED) : S with type key = X.t array and type char_ = X.t
module MakeList (X : ORDERED) : S with type key = X.t list and type char_ = X.t
module String : S with type key = string and type char_ = char
\ No newline at end of file +CCTrie (containers-data.CCTrie)

Module CCTrie

Prefix Tree

type 'a iter = ('a -> unit) -> unit
type 'a ktree = unit -> [ `Nil | `Node of 'a * 'a ktree list ]

Signatures

A Composite Word

Words are made of characters, who belong to a total order

module type WORD = sig ... end
module type S = sig ... end

Implementation

module Make (W : WORD) : S with type key = W.t and type char_ = W.char_
module type ORDERED = sig ... end
module MakeArray (X : ORDERED) : S with type key = X.t array and type char_ = X.t
module MakeList (X : ORDERED) : S with type key = X.t list and type char_ = X.t
module String : S with type key = string and type char_ = char
\ No newline at end of file diff --git a/dev/containers-data/CCWBTree/index.html b/dev/containers-data/CCWBTree/index.html index 37603ae5..0b1e7e23 100644 --- a/dev/containers-data/CCWBTree/index.html +++ b/dev/containers-data/CCWBTree/index.html @@ -1,2 +1,2 @@ -CCWBTree (containers-data.CCWBTree)

Module CCWBTree

Weight-Balanced Tree

status: experimental

  • since 0.13
type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
module type ORD = sig ... end
module type KEY = sig ... end

Signature

module type S = sig ... end

Functor

module Make (X : ORD) : S with type key = X.t
module MakeFull (X : KEY) : S with type key = X.t

Use the custom X.weight function

\ No newline at end of file +CCWBTree (containers-data.CCWBTree)

Module CCWBTree

Weight-Balanced Tree

status: experimental

  • since 0.13
type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
module type ORD = sig ... end
module type KEY = sig ... end

Signature

module type S = sig ... end

Functor

module Make (X : ORD) : S with type key = X.t
module MakeFull (X : KEY) : S with type key = X.t

Use the custom X.weight function

\ No newline at end of file diff --git a/dev/containers-data/CCZipper/index.html b/dev/containers-data/CCZipper/index.html index 7a423161..0b3079ef 100644 --- a/dev/containers-data/CCZipper/index.html +++ b/dev/containers-data/CCZipper/index.html @@ -1,2 +1,2 @@ -CCZipper (containers-data.CCZipper)

Module CCZipper

List Zipper

  • since 1.0
type 'a t = 'a list * 'a list

The pair l, r represents the list List.rev_append l r, but with the focus on r

val empty : 'a t

Empty zipper.

val is_empty : _ t -> bool

Empty zipper? Returns true iff the two lists are empty.

val to_list : 'a t -> 'a list

Convert the zipper back to a list. to_list (l,r) is List.rev_append l r.

val to_rev_list : 'a t -> 'a list

Convert the zipper back to a reversed list. In other words, to_list (l,r) is List.rev_append r l.

val make : 'a list -> 'a t

Create a zipper pointing at the first element of the list.

val left : 'a t -> 'a t

Go to the left, or do nothing if the zipper is already at leftmost pos.

val left_exn : 'a t -> 'a t

Go to the left, or

  • raises Invalid_argument

    if the zipper is already at leftmost pos.

val right : 'a t -> 'a t

Go to the right, or do nothing if the zipper is already at rightmost pos.

val right_exn : 'a t -> 'a t

Go to the right, or

  • raises Invalid_argument

    if the zipper is already at rightmost pos.

val modify : ('a option -> 'a option) -> 'a t -> 'a t

Modify the current element, if any, by returning a new element, or returning None if the element is to be deleted.

val insert : 'a -> 'a t -> 'a t

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

remove l removes the current element, if any.

val is_focused : _ t -> bool

Is the zipper focused on some element? That is, will focused return a Some v?

val focused : 'a t -> 'a option

Return the focused element, if any. focused zip = Some _ iff empty zip = false.

val focused_exn : 'a t -> 'a

Return the focused element, or

  • raises Not_found

    if the zipper is at an end.

val drop_before : 'a t -> 'a t

Drop every element on the "left" (calling left then will do nothing).

val drop_after : 'a t -> 'a t

Drop every element on the "right" (calling right then will do nothing), keeping the focused element, if any.

val drop_after_and_focused : 'a t -> 'a t

Drop every element on the "right" (calling right then will do nothing), including the focused element if it is present.

\ No newline at end of file +CCZipper (containers-data.CCZipper)

Module CCZipper

List Zipper

  • since 1.0
type 'a t = 'a list * 'a list

The pair l, r represents the list List.rev_append l r, but with the focus on r

val empty : 'a t

Empty zipper.

val is_empty : _ t -> bool

Empty zipper? Returns true iff the two lists are empty.

val to_list : 'a t -> 'a list

Convert the zipper back to a list. to_list (l,r) is List.rev_append l r.

val to_rev_list : 'a t -> 'a list

Convert the zipper back to a reversed list. In other words, to_list (l,r) is List.rev_append r l.

val make : 'a list -> 'a t

Create a zipper pointing at the first element of the list.

val left : 'a t -> 'a t

Go to the left, or do nothing if the zipper is already at leftmost pos.

val left_exn : 'a t -> 'a t

Go to the left, or

  • raises Invalid_argument

    if the zipper is already at leftmost pos.

val right : 'a t -> 'a t

Go to the right, or do nothing if the zipper is already at rightmost pos.

val right_exn : 'a t -> 'a t

Go to the right, or

  • raises Invalid_argument

    if the zipper is already at rightmost pos.

val modify : ('a option -> 'a option) -> 'a t -> 'a t

Modify the current element, if any, by returning a new element, or returning None if the element is to be deleted.

val insert : 'a -> 'a t -> 'a t

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

remove l removes the current element, if any.

val is_focused : _ t -> bool

Is the zipper focused on some element? That is, will focused return a Some v?

val focused : 'a t -> 'a option

Return the focused element, if any. focused zip = Some _ iff empty zip = false.

val focused_exn : 'a t -> 'a

Return the focused element, or

  • raises Not_found

    if the zipper is at an end.

val drop_before : 'a t -> 'a t

Drop every element on the "left" (calling left then will do nothing).

val drop_after : 'a t -> 'a t

Drop every element on the "right" (calling right then will do nothing), keeping the focused element, if any.

val drop_after_and_focused : 'a t -> 'a t

Drop every element on the "right" (calling right then will do nothing), including the focused element if it is present.

\ No newline at end of file diff --git a/dev/containers-data/index.html b/dev/containers-data/index.html index 6aeb5b86..5d4fe3cd 100644 --- a/dev/containers-data/index.html +++ b/dev/containers-data/index.html @@ -1,2 +1,2 @@ -index (containers-data.index)

containers-data index

\ No newline at end of file +index (containers-data.index)

containers-data index

Library containers-data

This library exposes the following toplevel modules:

Library containers-data.top

The entry point of this library is the module: Containers_data_top.

\ No newline at end of file diff --git a/dev/containers/CCArray/index.html b/dev/containers/CCArray/index.html index 3f3b8d33..186bf252 100644 --- a/dev/containers/CCArray/index.html +++ b/dev/containers/CCArray/index.html @@ -1,4 +1,4 @@ -CCArray (containers.CCArray)

Module CCArray

Array utils

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

Fast internal iterator.

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

Arrays

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

reverse_in_place a reverses the array a in place.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  • returns

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

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

lookup_exn ~cmp key a is like lookup, but

  • raises Not_found

    if the key key is not present.

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

Module CCArray

Array utils

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

Fast internal iterator.

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

Arrays

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

reverse_in_place a reverses the array a in place.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  • returns

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

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

lookup_exn ~cmp key a is like lookup, but

  • raises Not_found

    if the key key is not present.

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

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

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

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

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

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

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

  • raises Invalid_argument

    if arrays have distinct lengths. Allow different types.

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

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

  • raises Invalid_argument

    if arrays have distinct lengths. Allow different types.

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

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

  • raises Invalid_argument

    if a and b have distinct lengths.

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

shuffle a randomly shuffles the array a, in place.

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

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

val random_choose : 'a t -> 'a random_gen

random_choose a rs randomly chooses an element of a.

  • raises Not_found

    if the array/slice is empty.

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

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

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

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

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

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

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

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

IO

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

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

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

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

val rev : 'a t -> 'a t

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

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

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

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

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

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

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

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

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

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

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

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

Generic Functions

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

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

  • since 0.14

Infix Operators

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

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

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

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

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

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

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

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

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

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

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

  • since 0.17

Let operators on OCaml >= 4.08.0, nothing otherwise

  • since 2.8
include CCShimsMkLet_.S with type 'a t_let := 'a array
val let+ : 'a array -> ('a -> 'b) -> 'b array
val and+ : 'a array -> 'b array -> ('a * 'b) array
val let* : 'a array -> ('a -> 'b array) -> 'b array
val and* : 'a array -> 'b array -> ('a * 'b) array
\ No newline at end of file diff --git a/dev/containers/CCArrayLabels/index.html b/dev/containers/CCArrayLabels/index.html index 5d7564ae..8a0284e2 100644 --- a/dev/containers/CCArrayLabels/index.html +++ b/dev/containers/CCArrayLabels/index.html @@ -1,5 +1,5 @@ -CCArrayLabels (containers.CCArrayLabels)

Module CCArrayLabels

Array utils

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

Fast internal iterator.

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

Arrays

include module type of CCShimsArrayLabels_
include module type of Stdlib.ArrayLabels with module Floatarray = Stdlib.Array.Floatarray
type !'a t = 'a array
val length : 'a array -> int
val get : 'a array -> int -> 'a
val set : 'a array -> int -> 'a -> unit
val make : int -> 'a -> 'a array
val create : int -> 'a -> 'a array
val create_float : int -> float array
val make_float : int -> float array
val init : int -> f:(int -> 'a) -> 'a array
val make_matrix : dimx:int -> dimy:int -> 'a -> 'a array array
val create_matrix : dimx:int -> dimy:int -> 'a -> 'a array array
val append : 'a array -> 'a array -> 'a array
val concat : 'a array list -> 'a array
val sub : 'a array -> pos:int -> len:int -> 'a array
val copy : 'a array -> 'a array
val fill : 'a array -> pos:int -> len:int -> 'a -> unit
val blit : src:'a array -> src_pos:int -> dst:'a array -> dst_pos:int -> len:int -> +CCArrayLabels (containers.CCArrayLabels)

Module CCArrayLabels

Array utils (Labeled version of CCArray)

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

Fast internal iterator.

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

Arrays

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

reverse_in_place a reverses the array a in place.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  • returns

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

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

lookup_exn ~cmp ~key a is like lookup, but

  • raises Not_found

    if the key key is not present.

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

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

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

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

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

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

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

  • raises Invalid_argument

    if arrays have distinct lengths. Allow different types.

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

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

  • raises Invalid_argument

    if arrays have distinct lengths. Allow different types.

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

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

  • raises Invalid_argument

    if a and b have distinct lengths.

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

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

  • raises Invalid_argument

    if a and b have distinct lengths.

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

shuffle a randomly shuffles the array a, in place.

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

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

val random_choose : 'a t -> 'a random_gen

random_choose a rs randomly chooses an element of a.

  • raises Not_found

    if the array/slice is empty.

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

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

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

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

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

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

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

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

IO

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

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

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

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

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

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

  • raises Invalid_argument

    if a and b have distinct lengths.

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

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

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

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

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

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

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

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

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

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

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

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

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

Generic Functions

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

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

  • since 0.14

Infix Operators

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

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

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

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

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

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

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

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

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

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

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

  • since 0.17

Let operators on OCaml >= 4.08.0, nothing otherwise

  • since 2.8
include CCShimsMkLet_.S with type 'a t_let := 'a array
val let+ : 'a array -> ('a -> 'b) -> 'b array
val and+ : 'a array -> 'b array -> ('a * 'b) array
val let* : 'a array -> ('a -> 'b array) -> 'b array
val and* : 'a array -> 'b array -> ('a * 'b) array
\ No newline at end of file diff --git a/dev/containers/CCBool/index.html b/dev/containers/CCBool/index.html index 266a3fab..b2da18b5 100644 --- a/dev/containers/CCBool/index.html +++ b/dev/containers/CCBool/index.html @@ -1,2 +1,2 @@ -CCBool (containers.CCBool)

Module CCBool

Basic Bool functions

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

compare b1 b2 is the total ordering on booleans b1 and b2, similar to Stdlib.compare.

val equal : t -> t -> bool

equal b1 b2 is true if b1 and b2 are the same.

val to_int : t -> int

to_int true = 1, to_int false = 0.

  • since 2.7
val of_int : int -> t

of_int i is the same as i <> 0

  • since 2.7
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
val pp : t printer
\ No newline at end of file +CCBool (containers.CCBool)

Module CCBool

Basic Bool functions

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

compare b1 b2 is the total ordering on booleans b1 and b2, similar to Stdlib.compare.

val equal : t -> t -> bool

equal b1 b2 is true if b1 and b2 are the same.

val to_int : t -> int

to_int true = 1, to_int false = 0.

  • since 2.7
val of_int : int -> t

of_int i is the same as i <> 0

  • since 2.7
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
val pp : t printer
\ No newline at end of file diff --git a/dev/containers/CCCanonical_sexp/index.html b/dev/containers/CCCanonical_sexp/index.html index 7e4a001c..803fbd7d 100644 --- a/dev/containers/CCCanonical_sexp/index.html +++ b/dev/containers/CCCanonical_sexp/index.html @@ -1,2 +1,2 @@ -CCCanonical_sexp (containers.CCCanonical_sexp)

Module CCCanonical_sexp

Canonical S-expressions

See wikipedia. These S-expressions are binary safe.

  • since 3.3
type 'a or_error = ('a, string) Stdlib.result
type 'a gen = unit -> 'a option
module type SEXP = CCSexp_intf.BASIC_SEXP
module type S = CCSexp_intf.S0
module Make (Sexp : SEXP) : S with type t = Sexp.t

Basics

type t = [
| `Atom of string
| `List of t list
]

A simple, structural representation of S-expressions. Compatible with CCSexp.

include S with type t := t
type sexp = t

Re-exports

val list : t list -> t

Make a Sexpr of this list.

  • since 2.8

Constructors

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

Reverse the list.

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

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

val of_field : string -> t -> t

Used to represent one record field.

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

Represent a record by its named fields.

Printing

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

Print the given iter of expressions to a file.

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

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

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

Raw, direct printing as compact as possible.

Parsing

val parse_string : string -> t CCSexp_intf.or_error

Parse a string.

val parse_string_list : string -> t list CCSexp_intf.or_error

Parse a string into a list of S-exprs.

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

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

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

Parse a channel into a generator of S-expressions.

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

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

val parse_file_list : string -> t list CCSexp_intf.or_error

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

val equal : t -> t -> bool
val compare : t -> t -> int
val atom : string -> t
\ No newline at end of file +CCCanonical_sexp (containers.CCCanonical_sexp)

Module CCCanonical_sexp

Canonical S-expressions

See wikipedia. These S-expressions are binary safe.

  • since 3.3
type 'a or_error = ('a, string) Stdlib.result
type 'a gen = unit -> 'a option
module type SEXP = CCSexp_intf.BASIC_SEXP
module type S = CCSexp_intf.S0
module Make (Sexp : SEXP) : S with type t = Sexp.t

Basics

type t = [
| `Atom of string
| `List of t list
]

A simple, structural representation of S-expressions. Compatible with CCSexp.

include S with type t := t
type sexp = t

Re-exports

val list : t list -> t

Make a Sexpr of this list.

  • since 2.8

Constructors

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

Reverse the list.

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

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

val of_field : string -> t -> t

Used to represent one record field.

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

Represent a record by its named fields.

Printing

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

Print the given iter of expressions to a file.

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

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

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

Raw, direct printing as compact as possible.

Parsing

val parse_string : string -> t CCSexp_intf.or_error

Parse a string.

val parse_string_list : string -> t list CCSexp_intf.or_error

Parse a string into a list of S-exprs.

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

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

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

Parse a channel into a generator of S-expressions.

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

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

val parse_file_list : string -> t list CCSexp_intf.or_error

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

val equal : t -> t -> bool
val compare : t -> t -> int
val atom : string -> t
\ No newline at end of file diff --git a/dev/containers/CCChar/index.html b/dev/containers/CCChar/index.html index 4606f20c..3e207133 100644 --- a/dev/containers/CCChar/index.html +++ b/dev/containers/CCChar/index.html @@ -1,2 +1,2 @@ -CCChar (containers.CCChar)

Module CCChar

Utils around char

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

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

val of_int_exn : int -> t

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

  • raises Invalid_argument

    if the int is not within 0 … 255.

  • since 1.0
val of_int : int -> t option

Safe version of of_int_exn.

  • since 1.0
val to_int : t -> int

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

  • since 1.0
val to_string : t -> string

to_string c returns a string containing c

  • since 2.7
val pp_buf : Stdlib.Buffer.t -> t -> unit

Renamed from pp since 2.0.

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

Renamed from print since 2.0.

Infix Operators

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

Module CCChar

Utils around char

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

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

val of_int_exn : int -> t

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

  • raises Invalid_argument

    if the int is not within 0 … 255.

  • since 1.0
val of_int : int -> t option

Safe version of of_int_exn.

  • since 1.0
val to_int : t -> int

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

  • since 1.0
val to_string : t -> string

to_string c returns a string containing c

  • since 2.7
val pp_buf : Stdlib.Buffer.t -> t -> unit

Renamed from pp since 2.0.

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

Renamed from print since 2.0.

Infix Operators

  • since 3.3
module Infix : sig ... end
include module type of Infix
val (=) : t -> t -> bool
  • since 3.3
val (<>) : t -> t -> bool
  • since 3.3
val (<) : t -> t -> bool
  • since 3.3
val (>) : t -> t -> bool
  • since 3.3
val (<=) : t -> t -> bool
  • since 3.3
val (>=) : t -> t -> bool
  • since 3.3
\ No newline at end of file diff --git a/dev/containers/CCEither/index.html b/dev/containers/CCEither/index.html index 388feba8..e0fe2ee2 100644 --- a/dev/containers/CCEither/index.html +++ b/dev/containers/CCEither/index.html @@ -1,4 +1,4 @@ -CCEither (containers.CCEither)

Module CCEither

Either Monad

Module that is compatible with Either form OCaml 4.12 but can be use with any ocaml version compatible with container

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

Basics

type ('a, 'b) t = ('a'b) Either.t =
| Left of 'a
| Right of 'b
val left : 'a -> ('a'b) t

left l is Left l

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

right r is Right r

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

is_left x checks if x = Left _

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

is_right x checks if x = Right _

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

find_left x returns l if x = Left l and None otherwise.

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

find_right x returns r if x = Left r and None otherwise.

val map_left : ('a1 -> 'a2) -> ('a1'b) t -> ('a2'b) t

Map of the Left variant.

val map_right : ('b1 -> 'b2) -> ('a'b1) t -> ('a'b2) t

Map of the Right variant.

val map : left:('a1 -> 'a2) -> right:('b1 -> 'b2) -> ('a1'b1) t -> ('a2'b2) t

Map using left or right.

val fold : left:('a -> 'c) -> right:('b -> 'c) -> ('a'b) t -> 'c

Fold using left or right.

val iter : left:('a -> unit) -> right:('b -> unit) -> ('a'b) t -> unit

Iter using left or right.

val for_all : left:('a -> bool) -> right:('b -> bool) -> ('a'b) t -> bool

Check some property on Left or Right variant.

val equal : left:('a -> 'a -> bool) -> right:('b -> 'b -> bool) -> +CCEither (containers.CCEither)

Module CCEither

Either Monad

Module that is compatible with Either form OCaml 4.12 but can be use with any ocaml version compatible with container

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

Basics

type ('a, 'b) t = ('a'b) Either.t =
| Left of 'a
| Right of 'b
val left : 'a -> ('a'b) t

left l is Left l

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

right r is Right r

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

is_left x checks if x = Left _

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

is_right x checks if x = Right _

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

find_left x returns l if x = Left l and None otherwise.

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

find_right x returns r if x = Left r and None otherwise.

val map_left : ('a1 -> 'a2) -> ('a1'b) t -> ('a2'b) t

Map of the Left variant.

val map_right : ('b1 -> 'b2) -> ('a'b1) t -> ('a'b2) t

Map of the Right variant.

val map : left:('a1 -> 'a2) -> right:('b1 -> 'b2) -> ('a1'b1) t -> ('a2'b2) t

Map using left or right.

val fold : left:('a -> 'c) -> right:('b -> 'c) -> ('a'b) t -> 'c

Fold using left or right.

val iter : left:('a -> unit) -> right:('b -> unit) -> ('a'b) t -> unit

Iter using left or right.

val for_all : left:('a -> bool) -> right:('b -> bool) -> ('a'b) t -> bool

Check some property on Left or Right variant.

val equal : left:('a -> 'a -> bool) -> right:('b -> 'b -> bool) -> ('a'b) t -> ('a'b) t -> bool
val compare : left:('a -> 'a -> int) -> right:('b -> 'b -> int) -> ('a'b) t -> ('a'b) t -> int

IO

val pp : left:'a printer -> right:'b printer -> ('a'b) t printer

Pretty printer.

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

Module CCEqual

Equality Combinators

  • since 1.2
type 'a t = 'a -> 'a -> bool

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

val poly : 'a t

Standard polymorphic equality.

val physical : 'a t

Standard physical equality.

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

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

val always_eq : _ t

Always returns true. All values are equal.

  • since 3.0
val never_eq : _ t

Always returns false. No values are, so this is not even reflexive (i.e. x=x is false). Be careful!

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

Infix equivalent of map.

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

Module CCEqual

Equality Combinators

  • since 1.2
type 'a t = 'a -> 'a -> bool

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

val poly : 'a t

Standard polymorphic equality.

val physical : 'a t

Standard physical equality.

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

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

val always_eq : _ t

Always returns true. All values are equal.

  • since 3.0
val never_eq : _ t

Always returns false. No values are, so this is not even reflexive (i.e. x=x is false). Be careful!

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

Infix equivalent of map.

\ No newline at end of file diff --git a/dev/containers/CCEqualLabels/index.html b/dev/containers/CCEqualLabels/index.html index c759b88c..87b8f461 100644 --- a/dev/containers/CCEqualLabels/index.html +++ b/dev/containers/CCEqualLabels/index.html @@ -1,2 +1,2 @@ -CCEqualLabels (containers.CCEqualLabels)

Module CCEqualLabels

Equality Combinators

  • since 1.2
type 'a t = 'a -> 'a -> bool

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

val poly : 'a t

Standard polymorphic equality.

val physical : 'a t

Standard physical equality.

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

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

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

Infix equivalent of map.

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

Module CCEqualLabels

Equality Combinators (Labeled version of CCEqual)

  • since 1.2
type 'a t = 'a -> 'a -> bool

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

val poly : 'a t

Standard polymorphic equality.

val physical : 'a t

Standard physical equality.

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

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

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

Infix equivalent of map.

\ No newline at end of file diff --git a/dev/containers/CCFloat/index.html b/dev/containers/CCFloat/index.html index 82164faf..cf8f8014 100644 --- a/dev/containers/CCFloat/index.html +++ b/dev/containers/CCFloat/index.html @@ -1,2 +1,2 @@ -CCFloat (containers.CCFloat)

Module CCFloat

Basic operations on floating-point numbers

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

nan is Not a Number (NaN). Equal to Stdlib.nan.

val max_value : t

max_value is Positive infinity. Equal to Stdlib.infinity.

val min_value : t

min_value is Negative infinity. Equal to Stdlib.neg_infinity.

val max_finite_value : t

max_finite_value is the largest finite float value. Equal to Stdlib.max_float.

val epsilon : t

epsilon is the smallest positive float x such that 1.0 +. x <> 1.0. Equal to Stdlib.epsilon_float.

val pi : t

pi is the constant pi. The ratio of a circumference to its diameter.

  • since 3.0
val is_nan : t -> bool

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

val add : t -> t -> t

add x y is equal to x +. y.

val sub : t -> t -> t

sub x y is equal to x -. y.

val neg : t -> t

neg x is equal to ~-. x.

val abs : t -> t

abs x is the absolute value of the floating-point number x. Equal to Stdlib.abs_float.

val scale : t -> t -> t

scale x y is equal to x *. y.

val min : t -> t -> t

min x y returns the min of the two given values x and y.

val max : t -> t -> t

max x y returns the max of the two given values x and y.

val equal : t -> t -> bool

equal x y is true if x and y are the same.

val compare : t -> t -> int

compare x y is Stdlib.compare x y.

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

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

  • since 0.7
val round : t -> t

round x returns the closest integer value, either above or below. For n + 0.5, round returns n.

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

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

  • since 0.7
val to_int : t -> int

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

val of_int : int -> t

Alias to float_of_int.

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

Alias to float_of_string.

  • raises Failure

    in case of failure.

  • since 1.2
val of_string_opt : string -> t option
  • since 3.0
val equal_precision : epsilon:t -> t -> t -> bool

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

val classify : t -> fpclass

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

Infix Operators

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

Addition.

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

Subtraction.

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

Unary negation.

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

Multiplication.

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

Division.

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

Module CCFloat

Basic operations on floating-point numbers

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

nan is Not a Number (NaN). Equal to Stdlib.nan.

val max_value : t

max_value is Positive infinity. Equal to Stdlib.infinity.

val min_value : t

min_value is Negative infinity. Equal to Stdlib.neg_infinity.

val max_finite_value : t

max_finite_value is the largest finite float value. Equal to Stdlib.max_float.

val epsilon : t

epsilon is the smallest positive float x such that 1.0 +. x <> 1.0. Equal to Stdlib.epsilon_float.

val pi : t

pi is the constant pi. The ratio of a circumference to its diameter.

  • since 3.0
val is_nan : t -> bool

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

val add : t -> t -> t

add x y is equal to x +. y.

val sub : t -> t -> t

sub x y is equal to x -. y.

val neg : t -> t

neg x is equal to ~-. x.

val abs : t -> t

abs x is the absolute value of the floating-point number x. Equal to Stdlib.abs_float.

val scale : t -> t -> t

scale x y is equal to x *. y.

val min : t -> t -> t

min x y returns the min of the two given values x and y.

val max : t -> t -> t

max x y returns the max of the two given values x and y.

val equal : t -> t -> bool

equal x y is true if x and y are the same.

val compare : t -> t -> int

compare x y is Stdlib.compare x y.

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

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

  • since 0.7
val round : t -> t

round x returns the closest integer value, either above or below. For n + 0.5, round returns n.

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

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

  • since 0.7
val to_int : t -> int

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

val of_int : int -> t

Alias to float_of_int.

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

Alias to float_of_string.

  • raises Failure

    in case of failure.

  • since 1.2
val of_string_opt : string -> t option
  • since 3.0
val equal_precision : epsilon:t -> t -> t -> bool

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

val classify : t -> fpclass

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

Infix Operators

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

Addition.

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

Subtraction.

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

Unary negation.

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

Multiplication.

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

Division.

  • since 2.1
\ No newline at end of file diff --git a/dev/containers/CCFormat/index.html b/dev/containers/CCFormat/index.html index c7afeb02..806a6dee 100644 --- a/dev/containers/CCFormat/index.html +++ b/dev/containers/CCFormat/index.html @@ -1,5 +1,5 @@ -CCFormat (containers.CCFormat)

Module CCFormat

Helpers for Format

  • since 0.8
type 'a iter = ('a -> unit) -> unit
include module type of struct include Stdlib.Format end
type formatter = Stdlib__format.formatter
val pp_open_box : formatter -> int -> unit
val open_box : int -> unit
val pp_close_box : formatter -> unit -> unit
val close_box : unit -> unit
val pp_open_hbox : formatter -> unit -> unit
val open_hbox : unit -> unit
val pp_open_vbox : formatter -> int -> unit
val open_vbox : int -> unit
val pp_open_hvbox : formatter -> int -> unit
val open_hvbox : int -> unit
val pp_open_hovbox : formatter -> int -> unit
val open_hovbox : int -> unit
val pp_print_string : formatter -> string -> unit
val print_string : string -> unit
val pp_print_as : formatter -> int -> string -> unit
val print_as : int -> string -> unit
val pp_print_int : formatter -> int -> unit
val print_int : int -> unit
val pp_print_float : formatter -> float -> unit
val print_float : float -> unit
val pp_print_char : formatter -> char -> unit
val print_char : char -> unit
val pp_print_bool : formatter -> bool -> unit
val print_bool : bool -> unit
val pp_print_space : formatter -> unit -> unit
val print_space : unit -> unit
val pp_print_cut : formatter -> unit -> unit
val print_cut : unit -> unit
val pp_print_break : formatter -> int -> int -> unit
val print_break : int -> int -> unit
val pp_print_custom_break : formatter -> fits:(string * int * string) -> +CCFormat (containers.CCFormat)

Module CCFormat

Helpers for Format

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

Module CCFun

Basic Functions

include module type of CCShimsFun_
include module type of Stdlib.Fun
val id : 'a -> 'a
val const : 'a -> 'b -> 'a
val flip : ('a -> 'b -> 'c) -> 'b -> 'a -> 'c
val negate : ('a -> bool) -> 'a -> bool
val protect : finally:(unit -> unit) -> (unit -> 'a) -> 'a
exception Finally_raised of exn
val compose : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c

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

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

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

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

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

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

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

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

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

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

Module CCFun

Basic operations on Functions

include module type of CCShimsFun_
include module type of Stdlib.Fun
val id : 'a -> 'a
val const : 'a -> 'b -> 'a
val flip : ('a -> 'b -> 'c) -> 'b -> 'a -> 'c
val negate : ('a -> bool) -> 'a -> bool
val protect : finally:(unit -> unit) -> (unit -> 'a) -> 'a
exception Finally_raised of exn
val compose : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c

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

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

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

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

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

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

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

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

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

CCArray.(1 -- 10)
 |> tap CCArray.shuffle
 |> tap @@ CCArray.sort Stdlib.compare
val lexicographic : ('a -> 'a -> int) -> ('a -> 'a -> int) -> 'a -> 'a -> int

Lexicographic combination of comparison functions.

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

finally ~h f calls f () and returns its result. If it raises, the same exception is raised; in any case, h () is called after f () terminates. If h () raises an exception, then this exception will be passed on and any exception that may have been raised by f () is lost.

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

finally1 ~h f x is the same as f x, but after the computation, h () is called whether f x rose an exception or not. If h () raises an exception, then this exception will be passed on and any exception that may have been raised by f () is lost.

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

finally2 ~h f x y is the same as f x y, but after the computation, h () is called whether f x y rose an exception or not. If h () raises an exception, then this exception will be passed on and any exception that may have been raised by f () is lost.

  • since 0.16
val opaque_identity : 'a -> 'a

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

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

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

  • since 2.1

Infix

Infix operators.

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

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

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

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

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

(f %> g) x or (%>) f g x is g (f x). Alias to compose.

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

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

Monad

Functions with a fixed domain are monads in their codomain.

module Monad (X : sig ... end) : sig ... end
\ No newline at end of file diff --git a/dev/containers/CCHash/index.html b/dev/containers/CCHash/index.html index ef0a5e90..8fe1b9cb 100644 --- a/dev/containers/CCHash/index.html +++ b/dev/containers/CCHash/index.html @@ -1,4 +1,4 @@ -CCHash (containers.CCHash)

Module CCHash

Hash combinators

The API of this module is stable as per semantic versioning, like the rest of containers. However the exact implementation of hashing function can change and should not be relied on (i.e. hashing a value always returns the same integer within a run of a program, not across versions of OCaml and Containers).

Definitions

type hash = int

A hash value is a positive integer.

type 'a t = 'a -> hash

A hash function for values of type 'a.

val const : hash -> _ t

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

val const0 : _ t

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

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

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

val bytes : bytes t

Hash a byte array.

  • since 3.5
val string : string t
val list : 'a t -> 'a list t
val array : 'a t -> 'a array t
val opt : 'a t -> 'a option t
val pair : 'a t -> 'b t -> ('a * 'b) t
val triple : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t
val quad : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) t
val map : ('a -> 'b) -> 'b t -> 'a t

map f h is the hasher that takes x, and uses h to hash f x.

For example:

module Str_set = Set.Make(String)
+CCHash (containers.CCHash)

Module CCHash

Hash combinators

The API of this module is stable as per semantic versioning, like the rest of containers. However the exact implementation of hashing function can change and should not be relied on (i.e. hashing a value always returns the same integer within a run of a program, not across versions of OCaml and Containers).

Definitions

type hash = int

A hash value is a positive integer.

type 'a t = 'a -> hash

A hash function for values of type 'a.

val const : hash -> _ t

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

val const0 : _ t

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

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

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

val bytes : bytes t

Hash a byte array.

  • since 3.5
val string : string t
val list : 'a t -> 'a list t
val array : 'a t -> 'a array t
val opt : 'a t -> 'a option t
val pair : 'a t -> 'b t -> ('a * 'b) t
val triple : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t
val quad : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) t
val map : ('a -> 'b) -> 'b t -> 'a t

map f h is the hasher that takes x, and uses h to hash f x.

For example:

module Str_set = Set.Make(String)
 
 let hash_str_set : Str_set.t CCHash.t = CCHash.(map Str_set.to_seq @@ seq string)
  • since 3.5
val if_ : bool -> 'a t -> 'a t -> 'a t

Decide which hash function to use depending on the boolean.

val poly : 'a t

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

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

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

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

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

  • since 1.0

Base hash combinators

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

Iterators

type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
val seq : 'a t -> 'a Stdlib.Seq.t t
val iter : 'a t -> 'a iter t
val gen : 'a t -> 'a gen t
\ No newline at end of file diff --git a/dev/containers/CCHashtbl/index.html b/dev/containers/CCHashtbl/index.html index ecb23b08..231cd1e3 100644 --- a/dev/containers/CCHashtbl/index.html +++ b/dev/containers/CCHashtbl/index.html @@ -1,5 +1,5 @@ -CCHashtbl (containers.CCHashtbl)

Module CCHashtbl

Extension to the standard Hashtbl

  • since 0.4
type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

  • since 2.8
type 'a eq = 'a -> 'a -> bool
type 'a hash = 'a -> int
type 'a printer = Stdlib.Format.formatter -> 'a -> unit

Polymorphic tables

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

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

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

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

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

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

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

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

values tbl f iterates on values in the table tbl.

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

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

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

values_list tbl is the list of values in tbl.

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

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

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

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

  • parameter by

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

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

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

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

Iterate on bindings in the table.

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

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

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

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

  • since 2.8
val add_iter_with : f:('a -> 'b -> 'b -> 'b) -> +CCHashtbl (containers.CCHashtbl)

Module CCHashtbl

Extension to the standard Hashtbl

  • since 0.4
type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

  • since 2.8
type 'a eq = 'a -> 'a -> bool
type 'a hash = 'a -> int
type 'a printer = Stdlib.Format.formatter -> 'a -> unit

Polymorphic tables

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

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

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

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

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

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

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

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

values tbl f iterates on values in the table tbl.

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

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

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

values_list tbl is the list of values in tbl.

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

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

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

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

  • parameter by

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

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

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

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

Iterate on bindings in the table.

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

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

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

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

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

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

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

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

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

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

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

From the given bindings, added in order.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  • since 0.13

Functor

module type S = sig ... end
module Make (X : Stdlib.Hashtbl.HashedType) : S with type key = X.t and type diff --git a/dev/containers/CCHeap/index.html b/dev/containers/CCHeap/index.html index 05019bf6..6029f84f 100644 --- a/dev/containers/CCHeap/index.html +++ b/dev/containers/CCHeap/index.html @@ -1,2 +1,2 @@ -CCHeap (containers.CCHeap)

Module CCHeap

Leftist Heaps

Implementation following Okasaki's book.

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

Fast internal iterator.

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

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

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

Module CCHeap

Leftist Heaps

Implementation following Okasaki's book.

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

Fast internal iterator.

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

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

\ No newline at end of file diff --git a/dev/containers/CCIO/index.html b/dev/containers/CCIO/index.html index 9ef16dc8..6aa1d257 100644 --- a/dev/containers/CCIO/index.html +++ b/dev/containers/CCIO/index.html @@ -1,5 +1,5 @@ -CCIO (containers.CCIO)

Module CCIO

IO Utils

Simple utilities to deal with basic Input/Output tasks in a resource-safe way. For advanced IO tasks, the user is advised to use something like Lwt or Async, that are far more comprehensive.

Examples:

  • obtain the list of lines of a file:
# let l = CCIO.(with_in "/tmp/some_file" read_lines_l);;
  • transfer one file into another:
# CCIO.(
+CCIO (containers.CCIO)

Module CCIO

1 IO Utils

Simple utilities to deal with basic Input/Output tasks in a resource-safe way. For advanced IO tasks, the user is advised to use something like Lwt or Async, that are far more comprehensive.

Examples:

  • obtain the list of lines of a file:
# let l = CCIO.(with_in "/tmp/some_file" read_lines_l);;
  • transfer one file into another:
# CCIO.(
     with_in "/tmp/input"
       (fun ic ->
          let chunks = read_chunks_gen ic in
@@ -17,7 +17,7 @@
        (fun oc ->
           write_gen oc chunks
        )
-  ) ;;
  • since 0.6
  • before 0.12

    was in 'containers.io', now moved into 'containers'

type 'a or_error = ('a, string) Stdlib.result
type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option

See Gen in the gen library.

Input

val with_in : ?mode:int -> ?flags:Stdlib.open_flag list -> + ) ;;
  • since 0.6
  • before 0.12

    was in 'containers.io', now moved into 'containers'

type 'a or_error = ('a, string) Stdlib.result
type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option

See Gen in the gen library.

Input

val with_in : ?mode:int -> ?flags:Stdlib.open_flag list -> string -> (Stdlib.in_channel -> 'a) -> 'a

Open an input file with the given optional flag list, calls the function on the input channel. When the function raises or returns, the channel is closed.

  • raises Sys_error

    in case of error (same as open_in and close_in).

  • parameter flags

    opening flags (default [Open_text]). Open_rdonly is used in any cases.

val read_chunks_gen : ?size:int -> Stdlib.in_channel -> string gen

Read the channel's content into chunks of size at most size. NOTE the generator must be used within the lifetime of the channel, see warning at the top of the file.

val read_chunks_seq : ?size:int -> Stdlib.in_channel -> string Stdlib.Seq.t

Read the channel's content into chunks of size at most size. NOTE the generator must be used within the lifetime of the channel, see warning at the top of the file.

  • since 3.5
val read_chunks_iter : ?size:int -> Stdlib.in_channel -> string iter

Read the channel's content into chunks of size at most size

  • since 3.6
val read_line : Stdlib.in_channel -> string option

Read a line from the channel. Returns None if the input is terminated. The "\n" is removed from the line.

val read_lines_gen : Stdlib.in_channel -> string gen

Read all lines. The generator should be traversed only once. NOTE the generator must be used within the lifetime of the channel, see warning at the top of the file.

val read_lines_seq : Stdlib.in_channel -> string Stdlib.Seq.t

Read all lines. NOTE the seq must be used within the lifetime of the channel, see warning at the top of the file.

  • since 3.5
val read_lines_iter : Stdlib.in_channel -> string iter

Read all lines.

  • since 3.6
val read_lines_l : Stdlib.in_channel -> string list

Read all lines into a list.

val read_all : ?size:int -> Stdlib.in_channel -> string

Read the whole channel into a buffer, then converted into a string.

  • parameter size

    the internal buffer size.

  • since 0.7
val read_all_bytes : ?size:int -> Stdlib.in_channel -> Stdlib.Bytes.t

Read the whole channel into a mutable byte array.

  • parameter size

    the internal buffer size.

  • since 0.12

Output

val with_out : ?mode:int -> ?flags:Stdlib.open_flag list -> string -> (Stdlib.out_channel -> 'a) -> 'a

Like with_in but for an output channel.

  • parameter flags

    opening flags (default [Open_creat; Open_trunc; Open_text]).

  • raises Sys_error

    in case of error (same as open_out and close_out). Open_wronly is used in any cases.

val with_out_a : ?mode:int -> ?flags:Stdlib.open_flag list -> string -> (Stdlib.out_channel -> 'a) -> 'a

Like with_out but with the [Open_append; Open_creat; Open_wronly] flags activated, to append to the file.

  • raises Sys_error

    in case of error (same as open_out and close_out).

val write_line : Stdlib.out_channel -> string -> unit

Write the given string on the channel, followed by "\n".

val write_gen : ?sep:string -> Stdlib.out_channel -> string gen -> unit

Write the given strings on the output. If provided, add sep between every two strings (but not at the end).

val write_seq : ?sep:string -> Stdlib.out_channel -> string Stdlib.Seq.t -> unit

Write the given strings on the output. If provided, add sep between every two strings (but not at the end).

  • since 3.5
val write_lines : Stdlib.out_channel -> string gen -> unit

Write every string on the output, followed by "\n".

val write_lines_iter : Stdlib.out_channel -> string iter -> unit

Write every string on the output, followed by "\n".

  • since 3.6
val write_lines_seq : Stdlib.out_channel -> string Stdlib.Seq.t -> unit

Write every string on the output, followed by "\n".

  • since 3.5
val write_lines_l : Stdlib.out_channel -> string list -> unit

Both

val with_in_out : ?mode:int -> ?flags:Stdlib.open_flag list -> diff --git a/dev/containers/CCInt/index.html b/dev/containers/CCInt/index.html index 256f7725..0c145b90 100644 --- a/dev/containers/CCInt/index.html +++ b/dev/containers/CCInt/index.html @@ -1,2 +1,2 @@ -CCInt (containers.CCInt)

Module CCInt

Basic Int functions

include module type of CCShimsInt_
include module type of struct include Stdlib.Int end
type t = int
val zero : t

zero is the integer 0.

  • since 3.0
val one : t

one is the integer 1.

  • since 3.0
val minus_one : t

minus_one is the integer -1.

  • since 3.0
val add : t -> t -> t

add x y is x + y.

  • since 3.0
val sub : t -> t -> t

sub x y is x - y.

  • since 3.0
val mul : t -> t -> t

mul x y is x * y.

  • since 3.0
val div : t -> t -> t

div x y is x / y

  • since 3.0
val succ : t -> t

succ x is x + 1.

  • since 3.0
val pred : t -> t

pred x is x - 1.

  • since 3.0
val abs : t -> t

abs x is the absolute value of x. It is x if x is positive and neg x otherwise.

  • since 3.0
val max_int : t

max_int is the maximum integer.

  • since 3.0
val min_int : t

min_int is the minimum integer.

  • since 3.0
val compare : t -> t -> int

compare x y is the comparison function for integers with the same specification as Stdlib.compare.

val equal : t -> t -> bool

equal x y is true iff x and y are equal. Equality function for integers.

val hash : t -> int

hash x computes the hash of x.

val sign : t -> int

sign x return 0 if x = 0, -1 if x < 0 and 1 if x > 0. Same as compare x 0.

val neg : t -> t

neg x is - x. Unary negation.

  • since 0.5
val pow : t -> t -> t

pow base exponent returns base raised to the power of exponent. pow x y = x^y for positive integers x and y. Raises Invalid_argument if x = y = 0 or y < 0.

  • since 0.11
val floor_div : t -> t -> t

floor_div x n is integer division rounding towards negative infinity. It satisfies x = m * floor_div x n + rem x n.

  • since 1.2
val rem : t -> t -> t

rem x n is the remainder of dividing x by n, with the same sign as n.

  • since 1.2
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a random_gen = Stdlib.Random.State.t -> 'a
type 'a iter = ('a -> unit) -> unit
val random : int -> t random_gen
val random_small : t random_gen
val random_range : int -> int -> t random_gen
val pp : t printer

pp ppf x prints the integer x on ppf.

val to_float : t -> float

to_float is the same as float_of_int

  • since 3.0
val to_string : t -> string

to_string x returns the string representation of the integer x, in signed decimal.

  • since 0.13
val of_string : string -> t option

of_string s converts the given string s into an integer. Safe version of of_string_exn.

  • since 0.13
val of_string_exn : string -> t

of_string_exn s converts the given string s to an integer. Alias to int_of_string.

  • raises Failure

    in case of failure.

  • since 3.0
val of_float : float -> t

of_float x converts the given floating-point number x to an integer. Alias to int_of_float.

  • since 3.0
val pp_binary : t printer

pp_binary ppf x prints x on ppf. Print as "0b00101010".

  • since 0.20
val to_string_binary : t -> string

to_string_binary x returns the string representation of the integer x, in binary.

  • since 0.20
val min : t -> t -> t

min x y returns the minimum of the two integers x and y.

  • since 0.17
val max : t -> t -> t

max x y returns the maximum of the two integers x and y.

  • since 0.17
val range_by : step:t -> t -> t -> t iter

range_by ~step i j iterates on integers from i to j included, where the difference between successive elements is step. Use a negative step for a decreasing list.

  • raises Invalid_argument

    if step=0.

  • since 1.2
val range : t -> t -> t iter

range i j iterates on integers from i to j included . It works both for decreasing and increasing ranges.

  • since 1.2
val range' : t -> t -> t iter

range' i j is like range but the second bound j is excluded. For instance range' 0 5 = Iter.of_list [0;1;2;3;4].

  • since 1.2
val popcount : t -> int

Number of bits set to 1

  • since 3.0
val logand : t -> t -> t

logand is the same as (land).

  • since 3.0
val logor : t -> t -> t

logand is the same as (lor).

  • since 3.0
val logxor : t -> t -> t

logxor is the same as (lxor).

  • since 3.0
val lognot : t -> t

logand is the same as lnot.

  • since 3.0
val shift_left : t -> int -> t

shift_left is the same as (lsl).

  • since 3.0
val shift_right : t -> int -> t

shift_right is the same as (asr).

  • since 3.0
val shift_right_logical : t -> int -> t

shift_right_logical is the same as (lsr).

  • since 3.0

Infix Operators

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

Alias to range.

  • since 1.2
val (--^) : t -> t -> t iter

Alias to range'.

  • since 1.2
val (+) : t -> t -> t
  • since 2.1
val (-) : t -> t -> t
  • since 2.1
val (~-) : t -> t
  • since 2.1
val (*) : t -> t -> t
  • since 2.1
val (/) : t -> t -> t
  • since 2.1
val (**) : t -> t -> t
  • since 2.4
val (mod) : t -> t -> t
  • since 2.1
val (land) : t -> t -> t
  • since 2.1
val (lor) : t -> t -> t
  • since 2.1
val (lxor) : t -> t -> t
  • since 2.1
val lnot : t -> t
  • since 2.1
val (lsl) : t -> int -> t
  • since 2.1
val (lsr) : t -> int -> t
  • since 2.1
val (asr) : t -> int -> t
  • since 2.1
\ No newline at end of file +CCInt (containers.CCInt)

Module CCInt

Basic Int functions

include module type of CCShimsInt_
include module type of struct include Stdlib.Int end
type t = int
val zero : t

zero is the integer 0.

  • since 3.0
val one : t

one is the integer 1.

  • since 3.0
val minus_one : t

minus_one is the integer -1.

  • since 3.0
val add : t -> t -> t

add x y is x + y.

  • since 3.0
val sub : t -> t -> t

sub x y is x - y.

  • since 3.0
val mul : t -> t -> t

mul x y is x * y.

  • since 3.0
val div : t -> t -> t

div x y is x / y

  • since 3.0
val succ : t -> t

succ x is x + 1.

  • since 3.0
val pred : t -> t

pred x is x - 1.

  • since 3.0
val abs : t -> t

abs x is the absolute value of x. It is x if x is positive and neg x otherwise.

  • since 3.0
val max_int : t

max_int is the maximum integer.

  • since 3.0
val min_int : t

min_int is the minimum integer.

  • since 3.0
val compare : t -> t -> int

compare x y is the comparison function for integers with the same specification as Stdlib.compare.

val equal : t -> t -> bool

equal x y is true iff x and y are equal. Equality function for integers.

val hash : t -> int

hash x computes the hash of x.

val sign : t -> int

sign x return 0 if x = 0, -1 if x < 0 and 1 if x > 0. Same as compare x 0.

val neg : t -> t

neg x is - x. Unary negation.

  • since 0.5
val pow : t -> t -> t

pow base exponent returns base raised to the power of exponent. pow x y = x^y for positive integers x and y. Raises Invalid_argument if x = y = 0 or y < 0.

  • since 0.11
val floor_div : t -> t -> t

floor_div x n is integer division rounding towards negative infinity. It satisfies x = m * floor_div x n + rem x n.

  • since 1.2
val rem : t -> t -> t

rem x n is the remainder of dividing x by n, with the same sign as n.

  • since 1.2
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a random_gen = Stdlib.Random.State.t -> 'a
type 'a iter = ('a -> unit) -> unit
val random : int -> t random_gen
val random_small : t random_gen
val random_range : int -> int -> t random_gen
val pp : t printer

pp ppf x prints the integer x on ppf.

val to_float : t -> float

to_float is the same as float_of_int

  • since 3.0
val to_string : t -> string

to_string x returns the string representation of the integer x, in signed decimal.

  • since 0.13
val of_string : string -> t option

of_string s converts the given string s into an integer. Safe version of of_string_exn.

  • since 0.13
val of_string_exn : string -> t

of_string_exn s converts the given string s to an integer. Alias to int_of_string.

  • raises Failure

    in case of failure.

  • since 3.0
val of_float : float -> t

of_float x converts the given floating-point number x to an integer. Alias to int_of_float.

  • since 3.0
val pp_binary : t printer

pp_binary ppf x prints x on ppf. Print as "0b00101010".

  • since 0.20
val to_string_binary : t -> string

to_string_binary x returns the string representation of the integer x, in binary.

  • since 0.20
val min : t -> t -> t

min x y returns the minimum of the two integers x and y.

  • since 0.17
val max : t -> t -> t

max x y returns the maximum of the two integers x and y.

  • since 0.17
val range_by : step:t -> t -> t -> t iter

range_by ~step i j iterates on integers from i to j included, where the difference between successive elements is step. Use a negative step for a decreasing list.

  • raises Invalid_argument

    if step=0.

  • since 1.2
val range : t -> t -> t iter

range i j iterates on integers from i to j included . It works both for decreasing and increasing ranges.

  • since 1.2
val range' : t -> t -> t iter

range' i j is like range but the second bound j is excluded. For instance range' 0 5 = Iter.of_list [0;1;2;3;4].

  • since 1.2
val popcount : t -> int

Number of bits set to 1

  • since 3.0
val logand : t -> t -> t

logand is the same as (land).

  • since 3.0
val logor : t -> t -> t

logand is the same as (lor).

  • since 3.0
val logxor : t -> t -> t

logxor is the same as (lxor).

  • since 3.0
val lognot : t -> t

logand is the same as lnot.

  • since 3.0
val shift_left : t -> int -> t

shift_left is the same as (lsl).

  • since 3.0
val shift_right : t -> int -> t

shift_right is the same as (asr).

  • since 3.0
val shift_right_logical : t -> int -> t

shift_right_logical is the same as (lsr).

  • since 3.0

Infix Operators

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

Alias to range.

  • since 1.2
val (--^) : t -> t -> t iter

Alias to range'.

  • since 1.2
val (+) : t -> t -> t
  • since 2.1
val (-) : t -> t -> t
  • since 2.1
val (~-) : t -> t
  • since 2.1
val (*) : t -> t -> t
  • since 2.1
val (/) : t -> t -> t
  • since 2.1
val (**) : t -> t -> t
  • since 2.4
val (mod) : t -> t -> t
  • since 2.1
val (land) : t -> t -> t
  • since 2.1
val (lor) : t -> t -> t
  • since 2.1
val (lxor) : t -> t -> t
  • since 2.1
val lnot : t -> t
  • since 2.1
val (lsl) : t -> int -> t
  • since 2.1
val (lsr) : t -> int -> t
  • since 2.1
val (asr) : t -> int -> t
  • since 2.1
\ No newline at end of file diff --git a/dev/containers/CCInt32/index.html b/dev/containers/CCInt32/index.html index 7c91f325..32134e3e 100644 --- a/dev/containers/CCInt32/index.html +++ b/dev/containers/CCInt32/index.html @@ -1,2 +1,2 @@ -CCInt32 (containers.CCInt32)

Module CCInt32

Int32

Helpers for 32-bit integers.

This module provides operations on the type int32 of signed 32-bit integers. Unlike the built-in int type, the type int32 is guaranteed to be exactly 32-bit wide on all platforms. All arithmetic operations over int32 are taken modulo 232.

Performance notice: values of type int32 occupy more memory space than values of type int, and arithmetic operations on int32 are generally slower than those on int. Use int32 only when the application requires exact 32-bit arithmetic.

  • since 2.1
include module type of struct include Stdlib.Int32 end
val zero : int32
val one : int32
val minus_one : int32
val neg : int32 -> int32
val add : int32 -> int32 -> int32
val sub : int32 -> int32 -> int32
val mul : int32 -> int32 -> int32
val div : int32 -> int32 -> int32
val unsigned_div : int32 -> int32 -> int32
val rem : int32 -> int32 -> int32
val unsigned_rem : int32 -> int32 -> int32
val succ : int32 -> int32
val pred : int32 -> int32
val abs : int32 -> int32
val max_int : int32
val min_int : int32
val logand : int32 -> int32 -> int32
val logor : int32 -> int32 -> int32
val logxor : int32 -> int32 -> int32
val lognot : int32 -> int32
val shift_left : int32 -> int -> int32
val shift_right : int32 -> int -> int32
val shift_right_logical : int32 -> int -> int32
val of_int : int -> int32
val to_int : int32 -> int
val unsigned_to_int : int32 -> int option
val of_float : float -> int32
val to_float : int32 -> float
val to_string : int32 -> string
val bits_of_float : float -> int32
val float_of_bits : int32 -> float
type t = int32
val compare : t -> t -> int
val unsigned_compare : t -> t -> int
val equal : t -> t -> bool
val format : string -> int32 -> string
val min : t -> t -> t

min x y returns the minimum of the two integers x and y.

  • since 3.0
val max : t -> t -> t

max x y returns the maximum of the two integers x and y.

  • since 3.0
val hash : t -> int

hash x computes the hash of x. Like Stdlib.abs (to_int x).

val sign : t -> int

sign x return 0 if x = 0, -1 if x < 0 and 1 if x > 0. Same as compare x zero.

  • since 3.0
val pow : t -> t -> t

pow base exponent returns base raised to the power of exponent. pow x y = x^y for positive integers x and y. Raises Invalid_argument if x = y = 0 or y < 0.

  • since 0.11
val floor_div : t -> t -> t

floor_div x n is integer division rounding towards negative infinity. It satisfies x = m * floor_div x n + rem x n.

  • since 3.0
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a random_gen = Stdlib.Random.State.t -> 'a
type 'a iter = ('a -> unit) -> unit
val range_by : step:t -> t -> t -> t iter

range_by ~step i j iterates on integers from i to j included, where the difference between successive elements is step. Use a negative step for a decreasing list.

  • raises Invalid_argument

    if step=0.

  • since 3.0
val range : t -> t -> t iter

range i j iterates on integers from i to j included . It works both for decreasing and increasing ranges.

  • since 3.0
val range' : t -> t -> t iter

range' i j is like range but the second bound j is excluded. For instance range' 0 5 = Iter.of_list [0;1;2;3;4].

  • since 3.0
val random : t -> t random_gen
val random_small : t random_gen
val random_range : t -> t -> t random_gen

Conversion

val of_string : string -> t option

of_string s is the safe version of of_string_exn. Like of_string_exn, but return None instead of raising.

val of_string_opt : string -> t option

of_string_opt s is an alias to of_string.

val of_string_exn : string -> t

of_string_exn s converts the given string s into a 32-bit integer. Alias to Int32.of_string. 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 to_string_binary : t -> string

to_string_binary x returns the string representation of the integer x, in binary.

  • since 3.0

Printing

val pp : t printer

pp ppf x prints the integer x on ppf.

  • since 3.0
val pp_binary : t printer

pp_binary ppf x prints x on ppf. Print as "0b00101010".

  • since 3.0

Infix Operators

module Infix : sig ... end
include module type of Infix
val (+) : t -> t -> t

x + y is the sum of x and y. Addition.

val (-) : t -> t -> t

x - y is the difference of x and y. Subtraction.

val (~-) : t -> t

~- x is the negation of x. Unary negation.

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

x * y is the product of x and y. Multiplication.

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

x / y is the integer quotient of x and y. Integer division. Raise Division_by_zero if the second argument y is zero. This division rounds the real quotient of its arguments towards zero, as specified for Stdlib.(/).

val (mod) : t -> t -> t

x mod y is the integer remainder of x / y. If y <> zero, the result of x mod y satisfies the following properties: zero <= x mod y < abs y and x = ((x / y) * y) + (x mod y). If y = 0, x mod y raises Division_by_zero.

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

Alias to pow

  • since 3.0
val (--) : t -> t -> t iter

Alias to range.

  • since 3.0
val (--^) : t -> t -> t iter

Alias to range'.

  • since 3.0
val (land) : t -> t -> t

x land y is the bitwise logical and of x and y.

val (lor) : t -> t -> t

x lor y is the bitwise logical or of x and y.

val (lxor) : t -> t -> t

x lxor y is the bitwise logical exclusive or of x and y.

val lnot : t -> t

lnot x is the bitwise logical negation of x (the bits of x are inverted).

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

x lsl y shifts x to the left by y bits, filling in with zeroes. The result is unspecified if y < 0 or y >= 32.

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

x lsr y shifts x to the right by y bits. This is a logical shift: zeroes are inserted in the vacated bits regardless of the sign of x. The result is unspecified if y < 0 or y >= 32.

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

x asr y shifts x to the right by y bits. This is an arithmetic shift: the sign bit of x is replicated and inserted in the vacated bits. The result is unspecified if y < 0 or y >= 32.

val (=) : t -> t -> bool
val (<>) : t -> t -> bool
val (>) : t -> t -> bool
val (>=) : t -> t -> bool
val (<=) : t -> t -> bool
val (<) : t -> t -> bool
\ No newline at end of file +CCInt32 (containers.CCInt32)

Module CCInt32

Helpers for 32-bit integers.

This module provides operations on the type int32 of signed 32-bit integers. Unlike the built-in int type, the type int32 is guaranteed to be exactly 32-bit wide on all platforms. All arithmetic operations over int32 are taken modulo 232.

Performance notice: values of type int32 occupy more memory space than values of type int, and arithmetic operations on int32 are generally slower than those on int. Use int32 only when the application requires exact 32-bit arithmetic.

  • since 2.1
include module type of struct include Stdlib.Int32 end
val zero : int32
val one : int32
val minus_one : int32
val neg : int32 -> int32
val add : int32 -> int32 -> int32
val sub : int32 -> int32 -> int32
val mul : int32 -> int32 -> int32
val div : int32 -> int32 -> int32
val unsigned_div : int32 -> int32 -> int32
val rem : int32 -> int32 -> int32
val unsigned_rem : int32 -> int32 -> int32
val succ : int32 -> int32
val pred : int32 -> int32
val abs : int32 -> int32
val max_int : int32
val min_int : int32
val logand : int32 -> int32 -> int32
val logor : int32 -> int32 -> int32
val logxor : int32 -> int32 -> int32
val lognot : int32 -> int32
val shift_left : int32 -> int -> int32
val shift_right : int32 -> int -> int32
val shift_right_logical : int32 -> int -> int32
val of_int : int -> int32
val to_int : int32 -> int
val unsigned_to_int : int32 -> int option
val of_float : float -> int32
val to_float : int32 -> float
val to_string : int32 -> string
val bits_of_float : float -> int32
val float_of_bits : int32 -> float
type t = int32
val compare : t -> t -> int
val unsigned_compare : t -> t -> int
val equal : t -> t -> bool
val format : string -> int32 -> string
val min : t -> t -> t

min x y returns the minimum of the two integers x and y.

  • since 3.0
val max : t -> t -> t

max x y returns the maximum of the two integers x and y.

  • since 3.0
val hash : t -> int

hash x computes the hash of x. Like Stdlib.abs (to_int x).

val sign : t -> int

sign x return 0 if x = 0, -1 if x < 0 and 1 if x > 0. Same as compare x zero.

  • since 3.0
val pow : t -> t -> t

pow base exponent returns base raised to the power of exponent. pow x y = x^y for positive integers x and y. Raises Invalid_argument if x = y = 0 or y < 0.

  • since 0.11
val floor_div : t -> t -> t

floor_div x n is integer division rounding towards negative infinity. It satisfies x = m * floor_div x n + rem x n.

  • since 3.0
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a random_gen = Stdlib.Random.State.t -> 'a
type 'a iter = ('a -> unit) -> unit
val range_by : step:t -> t -> t -> t iter

range_by ~step i j iterates on integers from i to j included, where the difference between successive elements is step. Use a negative step for a decreasing list.

  • raises Invalid_argument

    if step=0.

  • since 3.0
val range : t -> t -> t iter

range i j iterates on integers from i to j included . It works both for decreasing and increasing ranges.

  • since 3.0
val range' : t -> t -> t iter

range' i j is like range but the second bound j is excluded. For instance range' 0 5 = Iter.of_list [0;1;2;3;4].

  • since 3.0
val random : t -> t random_gen
val random_small : t random_gen
val random_range : t -> t -> t random_gen

Conversion

val of_string : string -> t option

of_string s is the safe version of of_string_exn. Like of_string_exn, but return None instead of raising.

val of_string_opt : string -> t option

of_string_opt s is an alias to of_string.

val of_string_exn : string -> t

of_string_exn s converts the given string s into a 32-bit integer. Alias to Int32.of_string. 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 to_string_binary : t -> string

to_string_binary x returns the string representation of the integer x, in binary.

  • since 3.0

Printing

val pp : t printer

pp ppf x prints the integer x on ppf.

  • since 3.0
val pp_binary : t printer

pp_binary ppf x prints x on ppf. Print as "0b00101010".

  • since 3.0

Infix Operators

module Infix : sig ... end
include module type of Infix
val (+) : t -> t -> t

x + y is the sum of x and y. Addition.

val (-) : t -> t -> t

x - y is the difference of x and y. Subtraction.

val (~-) : t -> t

~- x is the negation of x. Unary negation.

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

x * y is the product of x and y. Multiplication.

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

x / y is the integer quotient of x and y. Integer division. Raise Division_by_zero if the second argument y is zero. This division rounds the real quotient of its arguments towards zero, as specified for Stdlib.(/).

val (mod) : t -> t -> t

x mod y is the integer remainder of x / y. If y <> zero, the result of x mod y satisfies the following properties: zero <= x mod y < abs y and x = ((x / y) * y) + (x mod y). If y = 0, x mod y raises Division_by_zero.

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

Alias to pow

  • since 3.0
val (--) : t -> t -> t iter

Alias to range.

  • since 3.0
val (--^) : t -> t -> t iter

Alias to range'.

  • since 3.0
val (land) : t -> t -> t

x land y is the bitwise logical and of x and y.

val (lor) : t -> t -> t

x lor y is the bitwise logical or of x and y.

val (lxor) : t -> t -> t

x lxor y is the bitwise logical exclusive or of x and y.

val lnot : t -> t

lnot x is the bitwise logical negation of x (the bits of x are inverted).

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

x lsl y shifts x to the left by y bits, filling in with zeroes. The result is unspecified if y < 0 or y >= 32.

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

x lsr y shifts x to the right by y bits. This is a logical shift: zeroes are inserted in the vacated bits regardless of the sign of x. The result is unspecified if y < 0 or y >= 32.

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

x asr y shifts x to the right by y bits. This is an arithmetic shift: the sign bit of x is replicated and inserted in the vacated bits. The result is unspecified if y < 0 or y >= 32.

val (=) : t -> t -> bool
val (<>) : t -> t -> bool
val (>) : t -> t -> bool
val (>=) : t -> t -> bool
val (<=) : t -> t -> bool
val (<) : t -> t -> bool
\ No newline at end of file diff --git a/dev/containers/CCInt64/index.html b/dev/containers/CCInt64/index.html index 6645fb32..0f692135 100644 --- a/dev/containers/CCInt64/index.html +++ b/dev/containers/CCInt64/index.html @@ -1,2 +1,2 @@ -CCInt64 (containers.CCInt64)

Module CCInt64

Int64

Helpers for 64-bit integers.

This module provides operations on the type int64 of signed 64-bit integers. Unlike the built-in int type, the type int64 is guaranteed to be exactly 64-bit wide on all platforms. All arithmetic operations over int64 are taken modulo 264.

Performance notice: values of type int64 occupy more memory space than values of type int, and arithmetic operations on int64 are generally slower than those on int. Use int64 only when the application requires exact 64-bit arithmetic.

  • since 0.13
include module type of struct include Stdlib.Int64 end
val zero : int64
val one : int64
val minus_one : int64
val neg : int64 -> int64
val add : int64 -> int64 -> int64
val sub : int64 -> int64 -> int64
val mul : int64 -> int64 -> int64
val div : int64 -> int64 -> int64
val unsigned_div : int64 -> int64 -> int64
val rem : int64 -> int64 -> int64
val unsigned_rem : int64 -> int64 -> int64
val succ : int64 -> int64
val pred : int64 -> int64
val abs : int64 -> int64
val max_int : int64
val min_int : int64
val logand : int64 -> int64 -> int64
val logor : int64 -> int64 -> int64
val logxor : int64 -> int64 -> int64
val lognot : int64 -> int64
val shift_left : int64 -> int -> int64
val shift_right : int64 -> int -> int64
val shift_right_logical : int64 -> int -> int64
val of_int : int -> int64
val to_int : int64 -> int
val unsigned_to_int : int64 -> int option
val of_float : float -> int64
val to_float : int64 -> float
val of_int32 : int32 -> int64
val to_int32 : int64 -> int32
val of_nativeint : nativeint -> int64
val to_nativeint : int64 -> nativeint
val to_string : int64 -> string
val bits_of_float : float -> int64
val float_of_bits : int64 -> float
type t = int64
val compare : t -> t -> int
val unsigned_compare : t -> t -> int
val equal : t -> t -> bool
val format : string -> int64 -> string
val min : t -> t -> t

min x y returns the minimum of the two integers x and y.

  • since 3.0
val max : t -> t -> t

max x y returns the maximum of the two integers x and y.

  • since 3.0
val hash : t -> int

hash x computes the hash of x. Like Stdlib.abs (to_int x).

val sign : t -> int

sign x return 0 if x = 0, -1 if x < 0 and 1 if x > 0. Same as compare x zero.

  • since 3.0
val pow : t -> t -> t

pow base exponent returns base raised to the power of exponent. pow x y = x^y for positive integers x and y. Raises Invalid_argument if x = y = 0 or y < 0.

  • since 0.11
val floor_div : t -> t -> t

floor_div x n is integer division rounding towards negative infinity. It satisfies x = m * floor_div x n + rem x n.

  • since 3.0
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a random_gen = Stdlib.Random.State.t -> 'a
type 'a iter = ('a -> unit) -> unit
val range_by : step:t -> t -> t -> t iter

range_by ~step i j iterates on integers from i to j included, where the difference between successive elements is step. Use a negative step for a decreasing list.

  • raises Invalid_argument

    if step=0.

  • since 3.0
val range : t -> t -> t iter

range i j iterates on integers from i to j included . It works both for decreasing and increasing ranges.

  • since 3.0
val range' : t -> t -> t iter

range' i j is like range but the second bound j is excluded. For instance range' 0 5 = Iter.of_list [0;1;2;3;4].

  • since 3.0
val random : t -> t random_gen
val random_small : t random_gen
val random_range : t -> t -> t random_gen

Conversion

val of_string : string -> t option

of_string s is the safe version of of_string_exn. Like of_string_exn, but return None instead of raising.

val of_string_opt : string -> t option

of_string_opt s is an alias to of_string.

  • since 2.1
val of_string_exn : string -> t

of_string_exn s converts the given string s into a 64-bit integer. Alias to Int64.of_string. 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 to_string_binary : t -> string

to_string_binary x returns the string representation of the integer x, in binary.

  • since 3.0

Printing

val pp : t printer

pp ppf x prints the integer x on ppf.

  • since 3.0
val pp_binary : t printer

pp_binary ppf x prints x on ppf. Print as "0b00101010".

  • since 3.0

Infix Operators

Infix operators

  • since 2.1
module Infix : sig ... end
include module type of Infix
val (+) : t -> t -> t

x + y is the sum of x and y. Addition.

val (-) : t -> t -> t

x - y is the difference of x and y. Subtraction.

val (~-) : t -> t

~- x is the negation of x. Unary negation.

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

x * y is the product of x and y. Multiplication.

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

x / y is the integer quotient of x and y. Integer division. Raise Division_by_zero if the second argument y is zero. This division rounds the real quotient of its arguments towards zero, as specified for Stdlib.(/).

val (mod) : t -> t -> t

x mod y is the integer remainder of x / y. If y <> zero, the result of x mod y satisfies the following properties: zero <= x mod y < abs y and x = ((x / y) * y) + (x mod y). If y = 0, x mod y raises Division_by_zero.

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

Alias to pow

  • since 3.0
val (--) : t -> t -> t iter

Alias to range.

  • since 3.0
val (--^) : t -> t -> t iter

Alias to range'.

  • since 3.0
val (land) : t -> t -> t

x land y is the bitwise logical and of x and y.

val (lor) : t -> t -> t

x lor y is the bitwise logical or of x and y.

val (lxor) : t -> t -> t

x lxor y is the bitwise logical exclusive or of x and y.

val lnot : t -> t

lnot x is the bitwise logical negation of x (the bits of x are inverted).

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

x lsl y shifts x to the left by y bits, filling in with zeroes. The result is unspecified if y < 0 or y >= 64.

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

x lsr y shifts x to the right by y bits. This is a logical shift: zeroes are inserted in the vacated bits regardless of the sign of x. The result is unspecified if y < 0 or y >= 64.

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

x asr y shifts x to the right by y bits. This is an arithmetic shift: the sign bit of x is replicated and inserted in the vacated bits. The result is unspecified if y < 0 or y >= 64.

val (=) : t -> t -> bool
val (<>) : t -> t -> bool
val (>) : t -> t -> bool
val (>=) : t -> t -> bool
val (<=) : t -> t -> bool
val (<) : t -> t -> bool
\ No newline at end of file +CCInt64 (containers.CCInt64)

Module CCInt64

Helpers for 64-bit integers.

This module provides operations on the type int64 of signed 64-bit integers. Unlike the built-in int type, the type int64 is guaranteed to be exactly 64-bit wide on all platforms. All arithmetic operations over int64 are taken modulo 264.

Performance notice: values of type int64 occupy more memory space than values of type int, and arithmetic operations on int64 are generally slower than those on int. Use int64 only when the application requires exact 64-bit arithmetic.

  • since 0.13
include module type of struct include Stdlib.Int64 end
val zero : int64
val one : int64
val minus_one : int64
val neg : int64 -> int64
val add : int64 -> int64 -> int64
val sub : int64 -> int64 -> int64
val mul : int64 -> int64 -> int64
val div : int64 -> int64 -> int64
val unsigned_div : int64 -> int64 -> int64
val rem : int64 -> int64 -> int64
val unsigned_rem : int64 -> int64 -> int64
val succ : int64 -> int64
val pred : int64 -> int64
val abs : int64 -> int64
val max_int : int64
val min_int : int64
val logand : int64 -> int64 -> int64
val logor : int64 -> int64 -> int64
val logxor : int64 -> int64 -> int64
val lognot : int64 -> int64
val shift_left : int64 -> int -> int64
val shift_right : int64 -> int -> int64
val shift_right_logical : int64 -> int -> int64
val of_int : int -> int64
val to_int : int64 -> int
val unsigned_to_int : int64 -> int option
val of_float : float -> int64
val to_float : int64 -> float
val of_int32 : int32 -> int64
val to_int32 : int64 -> int32
val of_nativeint : nativeint -> int64
val to_nativeint : int64 -> nativeint
val to_string : int64 -> string
val bits_of_float : float -> int64
val float_of_bits : int64 -> float
type t = int64
val compare : t -> t -> int
val unsigned_compare : t -> t -> int
val equal : t -> t -> bool
val format : string -> int64 -> string
val min : t -> t -> t

min x y returns the minimum of the two integers x and y.

  • since 3.0
val max : t -> t -> t

max x y returns the maximum of the two integers x and y.

  • since 3.0
val hash : t -> int

hash x computes the hash of x. Like Stdlib.abs (to_int x).

val sign : t -> int

sign x return 0 if x = 0, -1 if x < 0 and 1 if x > 0. Same as compare x zero.

  • since 3.0
val pow : t -> t -> t

pow base exponent returns base raised to the power of exponent. pow x y = x^y for positive integers x and y. Raises Invalid_argument if x = y = 0 or y < 0.

  • since 0.11
val floor_div : t -> t -> t

floor_div x n is integer division rounding towards negative infinity. It satisfies x = m * floor_div x n + rem x n.

  • since 3.0
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a random_gen = Stdlib.Random.State.t -> 'a
type 'a iter = ('a -> unit) -> unit
val range_by : step:t -> t -> t -> t iter

range_by ~step i j iterates on integers from i to j included, where the difference between successive elements is step. Use a negative step for a decreasing list.

  • raises Invalid_argument

    if step=0.

  • since 3.0
val range : t -> t -> t iter

range i j iterates on integers from i to j included . It works both for decreasing and increasing ranges.

  • since 3.0
val range' : t -> t -> t iter

range' i j is like range but the second bound j is excluded. For instance range' 0 5 = Iter.of_list [0;1;2;3;4].

  • since 3.0
val random : t -> t random_gen
val random_small : t random_gen
val random_range : t -> t -> t random_gen

Conversion

val of_string : string -> t option

of_string s is the safe version of of_string_exn. Like of_string_exn, but return None instead of raising.

val of_string_opt : string -> t option

of_string_opt s is an alias to of_string.

  • since 2.1
val of_string_exn : string -> t

of_string_exn s converts the given string s into a 64-bit integer. Alias to Int64.of_string. 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 to_string_binary : t -> string

to_string_binary x returns the string representation of the integer x, in binary.

  • since 3.0

Printing

val pp : t printer

pp ppf x prints the integer x on ppf.

  • since 3.0
val pp_binary : t printer

pp_binary ppf x prints x on ppf. Print as "0b00101010".

  • since 3.0

Infix Operators

Infix operators

  • since 2.1
module Infix : sig ... end
include module type of Infix
val (+) : t -> t -> t

x + y is the sum of x and y. Addition.

val (-) : t -> t -> t

x - y is the difference of x and y. Subtraction.

val (~-) : t -> t

~- x is the negation of x. Unary negation.

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

x * y is the product of x and y. Multiplication.

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

x / y is the integer quotient of x and y. Integer division. Raise Division_by_zero if the second argument y is zero. This division rounds the real quotient of its arguments towards zero, as specified for Stdlib.(/).

val (mod) : t -> t -> t

x mod y is the integer remainder of x / y. If y <> zero, the result of x mod y satisfies the following properties: zero <= x mod y < abs y and x = ((x / y) * y) + (x mod y). If y = 0, x mod y raises Division_by_zero.

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

Alias to pow

  • since 3.0
val (--) : t -> t -> t iter

Alias to range.

  • since 3.0
val (--^) : t -> t -> t iter

Alias to range'.

  • since 3.0
val (land) : t -> t -> t

x land y is the bitwise logical and of x and y.

val (lor) : t -> t -> t

x lor y is the bitwise logical or of x and y.

val (lxor) : t -> t -> t

x lxor y is the bitwise logical exclusive or of x and y.

val lnot : t -> t

lnot x is the bitwise logical negation of x (the bits of x are inverted).

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

x lsl y shifts x to the left by y bits, filling in with zeroes. The result is unspecified if y < 0 or y >= 64.

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

x lsr y shifts x to the right by y bits. This is a logical shift: zeroes are inserted in the vacated bits regardless of the sign of x. The result is unspecified if y < 0 or y >= 64.

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

x asr y shifts x to the right by y bits. This is an arithmetic shift: the sign bit of x is replicated and inserted in the vacated bits. The result is unspecified if y < 0 or y >= 64.

val (=) : t -> t -> bool
val (<>) : t -> t -> bool
val (>) : t -> t -> bool
val (>=) : t -> t -> bool
val (<=) : t -> t -> bool
val (<) : t -> t -> bool
\ No newline at end of file diff --git a/dev/containers/CCList/index.html b/dev/containers/CCList/index.html index c168ccfe..5fa46640 100644 --- a/dev/containers/CCList/index.html +++ b/dev/containers/CCList/index.html @@ -1,5 +1,5 @@ -CCList (containers.CCList)

Module CCList

Complements to list

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

Fast internal iterator.

  • since 2.8
type 'a gen = unit -> 'a option
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a random_gen = Stdlib.Random.State.t -> 'a
include module type of Stdlib.List
val length : 'a list -> int
val cons : 'a -> 'a list -> 'a list
val hd : 'a list -> 'a
val tl : 'a list -> 'a list
val nth : 'a list -> int -> 'a
val rev : 'a list -> 'a list
val rev_append : 'a list -> 'a list -> 'a list
val concat : 'a list list -> 'a list
val iter : ('a -> unit) -> 'a list -> unit
val rev_map : ('a -> 'b) -> 'a list -> 'b list
val concat_map : ('a -> 'b list) -> 'a list -> 'b list
val fold_left_map : ('a -> 'b -> 'a * 'c) -> 'a -> 'b list -> 'a * 'c list
val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a
val iter2 : ('a -> 'b -> unit) -> 'a list -> 'b list -> unit
val map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
val rev_map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
val fold_left2 : ('a -> 'b -> 'c -> 'a) -> 'a -> 'b list -> 'c list -> 'a
val fold_right2 : ('a -> 'b -> 'c -> 'c) -> 'a list -> 'b list -> 'c -> 'c
val for_all : ('a -> bool) -> 'a list -> bool
val exists : ('a -> bool) -> 'a list -> bool
val for_all2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
val exists2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
val memq : 'a -> 'a list -> bool
val find : ('a -> bool) -> 'a list -> 'a
val find_all : ('a -> bool) -> 'a list -> 'a list
val filteri : (int -> 'a -> bool) -> 'a list -> 'a list
val partition : ('a -> bool) -> 'a list -> 'a list * 'a list
val assq : 'a -> ('a * 'b) list -> 'b
val mem_assq : 'a -> ('a * 'b) list -> bool
val remove_assq : 'a -> ('a * 'b) list -> ('a * 'b) list
val sort : ('a -> 'a -> int) -> 'a list -> 'a list
val stable_sort : ('a -> 'a -> int) -> 'a list -> 'a list
val fast_sort : ('a -> 'a -> int) -> 'a list -> 'a list
val merge : ('a -> 'a -> int) -> 'a list -> 'a list -> 'a list
type 'a t = 'a list
val empty : 'a t

empty is [].

val is_empty : _ t -> bool

is_empty l returns true iff l = [].

  • since 0.11
val map : ('a -> 'b) -> 'a t -> 'b t

map f [a0; a1; …; an] applies function f in turn to a0; a1; …; an. Safe version of List.map.

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

l >|= f is the infix version of map with reversed arguments.

  • since 0.5
val append : 'a t -> 'a t -> 'a t

append l1 l2 returns the list that is the concatenation of l1 and l2. Safe version of List.append.

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

cons_maybe (Some x) l is x :: l. cons_maybe None l is l.

  • since 0.13
val cons' : 'a t -> 'a -> 'a t

cons' l x is the same as x :: l. This is convenient for fold functions such as List.fold_left or Array.fold_left.

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

l1 @ l2 is like append l1 l2. Concatenate the two lists l1 and l2.

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

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 l is preserved. Safe version of List.filter.

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

fold_right f [a1; …; an] b is f a1 (f a2 ( … (f an b) … )). Safe version of List.fold_right.

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

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

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

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

  • since 0.14
val fold_map_i : ('acc -> int -> 'a -> 'acc * 'b) -> 'acc -> 'a list -> 'acc * 'b list

fold_map_i f init l is a foldi-like function, but it also maps the list to another list.

  • since 2.8
val fold_on_map : f:('a -> 'b) -> reduce:('acc -> 'b -> 'acc) -> 'acc -> 'a list -> 'acc

fold_on_map ~f ~reduce init l combines map f and fold_left reduce init in one operation.

  • since 2.8
val scan_left : ('acc -> 'a -> 'acc) -> 'acc -> 'a list -> 'acc list

scan_left f init l returns the list [init; f init x0; f (f init x0) x1; …] where x0, x1, etc. are the elements of l.

  • since 1.2, but only
  • since 2.2 with labels
val reduce : ('a -> 'a -> 'a) -> 'a list -> 'a option

reduce f (hd::tl) returns Some (fold_left f hd tl). If l is empty, then None is returned.

  • since 3.2
val reduce_exn : ('a -> 'a -> 'a) -> 'a list -> 'a

reduce_exn is the unsafe version of reduce.

  • raises Invalid_argument

    if the given list is empty.

  • since 3.2
val fold_map2 : ('acc -> 'a -> 'b -> 'acc * 'c) -> 'acc -> 'a list -> 'b list -> 'acc * 'c list

fold_map2 f init l1 l2 is to fold_map what List.map2 is to List.map.

  • raises Invalid_argument

    if the lists do not have the same length.

  • since 0.16
val fold_filter_map : ('acc -> 'a -> 'acc * 'b option) -> 'acc -> 'a list -> 'acc * 'b list

fold_filter_map f init l is a fold_left-like function, but also generates a list of output in a way similar to filter_map.

  • since 0.17
val fold_filter_map_i : ('acc -> int -> 'a -> 'acc * 'b option) -> 'acc -> 'a list -> 'acc * 'b list

fold_filter_map_i f init l is a foldi-like function, but also generates a list of output in a way similar to filter_map.

  • since 2.8
val fold_flat_map : ('acc -> 'a -> 'acc * 'b list) -> 'acc -> 'a list -> 'acc * 'b list

fold_flat_map f init l is a fold_left-like function, but it also maps the list to a list of lists that is then flatten'd.

  • since 0.14
val fold_flat_map_i : ('acc -> int -> 'a -> 'acc * 'b list) -> 'acc -> 'a list -> 'acc * 'b list

fold_flat_map_i f init l is a fold_left-like function, but it also maps the list to a list of lists that is then flatten'd.

  • since 2.8
val count : ('a -> bool) -> 'a list -> int

count p l counts how many elements of l satisfy predicate p.

  • since 1.5, but only
  • since 2.2 with labels
val count_true_false : ('a -> bool) -> 'a list -> int * int

count_true_false p l returns a pair (int1,int2) where int1 is the number of elements in l that satisfy the predicate p, and int2 the number of elements that do not satisfy p.

  • since 2.4
val init : int -> (int -> 'a) -> 'a t

init len f is f 0; f 1; …; f (len-1).

  • raises Invalid_argument

    if len < 0.

  • since 0.6
val combine : 'a list -> 'b list -> ('a * 'b) list

combine [a1; …; an] [b1; …; bn] is [(a1,b1); …; (an,bn)]. Transform two lists into a list of pairs. Like List.combine but tail-recursive.

  • raises Invalid_argument

    if the lists have distinct lengths.

  • since 1.2, but only
  • since 2.2 with labels
val combine_gen : 'a list -> 'b list -> ('a * 'b) gen

combine_gen l1 l2 transforms two lists into a gen of pairs. Lazy version of combine. Unlike combine, it does not fail if the lists have different lengths; instead, the output has as many pairs as the smallest input list.

  • since 1.2, but only
  • since 2.2 with labels
val combine_shortest : 'a list -> 'b list -> ('a * 'b) list

combine_shortest [a1; …; am] [b1; …; bn] is [(a1,b1); …; (am,bm)] if m <= n. Like combine but stops at the shortest list rather than raising.

  • since 3.1
val split : ('a * 'b) t -> 'a t * 'b t

split [(a1,b1); …; (an,bn)] is ([a1; …; an], [b1; …; bn]). Transform a list of pairs into a pair of lists. A tail-recursive version of List.split.

  • since 1.2, but only
  • since 2.2 with labels
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int

compare cmp l1 l2 compares the two lists l1 and l2 using the given comparison function cmp.

val compare_lengths : 'a t -> 'b t -> int

compare_lengths l1 l2 compare the lengths of the two lists l1 and l2. Equivalent to compare (length l1) (length l2) but more efficient.

  • since 1.5, but only
  • since 2.2 with labels
val compare_length_with : 'a t -> int -> int

compare_length_with l x compares the length of the list l to an integer x. Equivalent to compare (length l) x but more efficient.

  • since 1.5, but only
  • since 2.2 with labels
val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool

equal p l1 l2 returns true if l1 and l2 are equal.

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

flat_map f l maps and flattens at the same time (safe). Evaluation order is not guaranteed.

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

flat_map_i f l maps with index and flattens at the same time (safe). Evaluation order is not guaranteed.

  • since 2.8
val flatten : 'a t t -> 'a t

flatten [l1]; [l2]; … concatenates a list of lists. Safe version of List.flatten.

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

product comb l1 l2 computes the cartesian product of the two lists, with the given combinator comb.

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

fold_product f init l1 l2 applies the function f with the accumulator init on all the pair of elements of l1 and l2. Fold on the cartesian product.

val cartesian_product : 'a t t -> 'a t t

cartesian_product [[l1]; [l2]; …; [ln]] produces 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 =
+CCList (containers.CCList)

Module CCList

Complements to List

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

Fast internal iterator.

  • since 2.8
type 'a gen = unit -> 'a option
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a random_gen = Stdlib.Random.State.t -> 'a
include module type of Stdlib.List
val length : 'a list -> int
val cons : 'a -> 'a list -> 'a list
val hd : 'a list -> 'a
val tl : 'a list -> 'a list
val nth : 'a list -> int -> 'a
val rev : 'a list -> 'a list
val rev_append : 'a list -> 'a list -> 'a list
val concat : 'a list list -> 'a list
val iter : ('a -> unit) -> 'a list -> unit
val rev_map : ('a -> 'b) -> 'a list -> 'b list
val concat_map : ('a -> 'b list) -> 'a list -> 'b list
val fold_left_map : ('a -> 'b -> 'a * 'c) -> 'a -> 'b list -> 'a * 'c list
val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a
val iter2 : ('a -> 'b -> unit) -> 'a list -> 'b list -> unit
val map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
val rev_map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
val fold_left2 : ('a -> 'b -> 'c -> 'a) -> 'a -> 'b list -> 'c list -> 'a
val fold_right2 : ('a -> 'b -> 'c -> 'c) -> 'a list -> 'b list -> 'c -> 'c
val for_all : ('a -> bool) -> 'a list -> bool
val exists : ('a -> bool) -> 'a list -> bool
val for_all2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
val exists2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
val memq : 'a -> 'a list -> bool
val find : ('a -> bool) -> 'a list -> 'a
val find_all : ('a -> bool) -> 'a list -> 'a list
val filteri : (int -> 'a -> bool) -> 'a list -> 'a list
val partition : ('a -> bool) -> 'a list -> 'a list * 'a list
val assq : 'a -> ('a * 'b) list -> 'b
val mem_assq : 'a -> ('a * 'b) list -> bool
val remove_assq : 'a -> ('a * 'b) list -> ('a * 'b) list
val sort : ('a -> 'a -> int) -> 'a list -> 'a list
val stable_sort : ('a -> 'a -> int) -> 'a list -> 'a list
val fast_sort : ('a -> 'a -> int) -> 'a list -> 'a list
val merge : ('a -> 'a -> int) -> 'a list -> 'a list -> 'a list
type 'a t = 'a list
val empty : 'a t

empty is [].

val is_empty : _ t -> bool

is_empty l returns true iff l = [].

  • since 0.11
val map : ('a -> 'b) -> 'a t -> 'b t

map f [a0; a1; …; an] applies function f in turn to a0; a1; …; an. Safe version of List.map.

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

l >|= f is the infix version of map with reversed arguments.

  • since 0.5
val append : 'a t -> 'a t -> 'a t

append l1 l2 returns the list that is the concatenation of l1 and l2. Safe version of List.append.

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

cons_maybe (Some x) l is x :: l. cons_maybe None l is l.

  • since 0.13
val cons' : 'a t -> 'a -> 'a t

cons' l x is the same as x :: l. This is convenient for fold functions such as List.fold_left or Array.fold_left.

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

l1 @ l2 is like append l1 l2. Concatenate the two lists l1 and l2.

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

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 l is preserved. Safe version of List.filter.

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

fold_right f [a1; …; an] b is f a1 (f a2 ( … (f an b) … )). Safe version of List.fold_right.

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

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

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

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

  • since 0.14
val fold_map_i : ('acc -> int -> 'a -> 'acc * 'b) -> 'acc -> 'a list -> 'acc * 'b list

fold_map_i f init l is a foldi-like function, but it also maps the list to another list.

  • since 2.8
val fold_on_map : f:('a -> 'b) -> reduce:('acc -> 'b -> 'acc) -> 'acc -> 'a list -> 'acc

fold_on_map ~f ~reduce init l combines map f and fold_left reduce init in one operation.

  • since 2.8
val scan_left : ('acc -> 'a -> 'acc) -> 'acc -> 'a list -> 'acc list

scan_left f init l returns the list [init; f init x0; f (f init x0) x1; …] where x0, x1, etc. are the elements of l.

  • since 1.2, but only
  • since 2.2 with labels
val reduce : ('a -> 'a -> 'a) -> 'a list -> 'a option

reduce f (hd::tl) returns Some (fold_left f hd tl). If l is empty, then None is returned.

  • since 3.2
val reduce_exn : ('a -> 'a -> 'a) -> 'a list -> 'a

reduce_exn is the unsafe version of reduce.

  • raises Invalid_argument

    if the given list is empty.

  • since 3.2
val fold_map2 : ('acc -> 'a -> 'b -> 'acc * 'c) -> 'acc -> 'a list -> 'b list -> 'acc * 'c list

fold_map2 f init l1 l2 is to fold_map what List.map2 is to List.map.

  • raises Invalid_argument

    if the lists do not have the same length.

  • since 0.16
val fold_filter_map : ('acc -> 'a -> 'acc * 'b option) -> 'acc -> 'a list -> 'acc * 'b list

fold_filter_map f init l is a fold_left-like function, but also generates a list of output in a way similar to filter_map.

  • since 0.17
val fold_filter_map_i : ('acc -> int -> 'a -> 'acc * 'b option) -> 'acc -> 'a list -> 'acc * 'b list

fold_filter_map_i f init l is a foldi-like function, but also generates a list of output in a way similar to filter_map.

  • since 2.8
val fold_flat_map : ('acc -> 'a -> 'acc * 'b list) -> 'acc -> 'a list -> 'acc * 'b list

fold_flat_map f init l is a fold_left-like function, but it also maps the list to a list of lists that is then flatten'd.

  • since 0.14
val fold_flat_map_i : ('acc -> int -> 'a -> 'acc * 'b list) -> 'acc -> 'a list -> 'acc * 'b list

fold_flat_map_i f init l is a fold_left-like function, but it also maps the list to a list of lists that is then flatten'd.

  • since 2.8
val count : ('a -> bool) -> 'a list -> int

count p l counts how many elements of l satisfy predicate p.

  • since 1.5, but only
  • since 2.2 with labels
val count_true_false : ('a -> bool) -> 'a list -> int * int

count_true_false p l returns a pair (int1,int2) where int1 is the number of elements in l that satisfy the predicate p, and int2 the number of elements that do not satisfy p.

  • since 2.4
val init : int -> (int -> 'a) -> 'a t

init len f is f 0; f 1; …; f (len-1).

  • raises Invalid_argument

    if len < 0.

  • since 0.6
val combine : 'a list -> 'b list -> ('a * 'b) list

combine [a1; …; an] [b1; …; bn] is [(a1,b1); …; (an,bn)]. Transform two lists into a list of pairs. Like List.combine but tail-recursive.

  • raises Invalid_argument

    if the lists have distinct lengths.

  • since 1.2, but only
  • since 2.2 with labels
val combine_gen : 'a list -> 'b list -> ('a * 'b) gen

combine_gen l1 l2 transforms two lists into a gen of pairs. Lazy version of combine. Unlike combine, it does not fail if the lists have different lengths; instead, the output has as many pairs as the smallest input list.

  • since 1.2, but only
  • since 2.2 with labels
val combine_shortest : 'a list -> 'b list -> ('a * 'b) list

combine_shortest [a1; …; am] [b1; …; bn] is [(a1,b1); …; (am,bm)] if m <= n. Like combine but stops at the shortest list rather than raising.

  • since 3.1
val split : ('a * 'b) t -> 'a t * 'b t

split [(a1,b1); …; (an,bn)] is ([a1; …; an], [b1; …; bn]). Transform a list of pairs into a pair of lists. A tail-recursive version of List.split.

  • since 1.2, but only
  • since 2.2 with labels
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int

compare cmp l1 l2 compares the two lists l1 and l2 using the given comparison function cmp.

val compare_lengths : 'a t -> 'b t -> int

compare_lengths l1 l2 compare the lengths of the two lists l1 and l2. Equivalent to compare (length l1) (length l2) but more efficient.

  • since 1.5, but only
  • since 2.2 with labels
val compare_length_with : 'a t -> int -> int

compare_length_with l x compares the length of the list l to an integer x. Equivalent to compare (length l) x but more efficient.

  • since 1.5, but only
  • since 2.2 with labels
val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool

equal p l1 l2 returns true if l1 and l2 are equal.

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

flat_map f l maps and flattens at the same time (safe). Evaluation order is not guaranteed.

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

flat_map_i f l maps with index and flattens at the same time (safe). Evaluation order is not guaranteed.

  • since 2.8
val flatten : 'a t t -> 'a t

flatten [l1]; [l2]; … concatenates a list of lists. Safe version of List.flatten.

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

product comb l1 l2 computes the cartesian product of the two lists, with the given combinator comb.

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

fold_product f init l1 l2 applies the function f with the accumulator init on all the pair of elements of l1 and l2. Fold on the cartesian product.

val cartesian_product : 'a t t -> 'a t t

cartesian_product [[l1]; [l2]; …; [ln]] produces 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 =
diff --git a/dev/containers/CCListLabels/index.html b/dev/containers/CCListLabels/index.html
index af6dde92..531cb256 100644
--- a/dev/containers/CCListLabels/index.html
+++ b/dev/containers/CCListLabels/index.html
@@ -1,5 +1,5 @@
 
-CCListLabels (containers.CCListLabels)

Module CCListLabels

Complements to list

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

Fast internal iterator.

  • since 2.8
type 'a gen = unit -> 'a option
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a random_gen = Stdlib.Random.State.t -> 'a
include module type of Stdlib.ListLabels
val length : 'a list -> int
val hd : 'a list -> 'a
val tl : 'a list -> 'a list
val nth : 'a list -> int -> 'a
val rev : 'a list -> 'a list
val rev_append : 'a list -> 'a list -> 'a list
val concat : 'a list list -> 'a list
val iter : f:('a -> unit) -> 'a list -> unit
val rev_map : f:('a -> 'b) -> 'a list -> 'b list
val concat_map : f:('a -> 'b list) -> 'a list -> 'b list
val fold_left_map : f:('a -> 'b -> 'a * 'c) -> init:'a -> 'b list -> 'a * 'c list
val fold_left : f:('a -> 'b -> 'a) -> init:'a -> 'b list -> 'a
val iter2 : f:('a -> 'b -> unit) -> 'a list -> 'b list -> unit
val map2 : f:('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
val rev_map2 : f:('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
val fold_left2 : f:('a -> 'b -> 'c -> 'a) -> init:'a -> 'b list -> 'c list -> 'a
val fold_right2 : f:('a -> 'b -> 'c -> 'c) -> 'a list -> 'b list -> init:'c -> 'c
val for_all : f:('a -> bool) -> 'a list -> bool
val exists : f:('a -> bool) -> 'a list -> bool
val for_all2 : f:('a -> 'b -> bool) -> 'a list -> 'b list -> bool
val exists2 : f:('a -> 'b -> bool) -> 'a list -> 'b list -> bool
val memq : 'a -> set:'a list -> bool
val find : f:('a -> bool) -> 'a list -> 'a
val find_all : f:('a -> bool) -> 'a list -> 'a list
val filteri : f:(int -> 'a -> bool) -> 'a list -> 'a list
val partition : f:('a -> bool) -> 'a list -> 'a list * 'a list
val assq : 'a -> ('a * 'b) list -> 'b
val mem_assq : 'a -> map:('a * 'b) list -> bool
val remove_assq : 'a -> ('a * 'b) list -> ('a * 'b) list
val sort : cmp:('a -> 'a -> int) -> 'a list -> 'a list
val stable_sort : cmp:('a -> 'a -> int) -> 'a list -> 'a list
val fast_sort : cmp:('a -> 'a -> int) -> 'a list -> 'a list
val merge : cmp:('a -> 'a -> int) -> 'a list -> 'a list -> 'a list
type 'a t = 'a list
val empty : 'a t

empty is [].

val is_empty : _ t -> bool

is_empty l returns true iff l = [].

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

map ~f [a0; a1; …; an] applies function f in turn to [a0; a1; …; an]. Safe version of List.map.

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

l >|= f is the infix version of map with reversed arguments.

  • since 0.5
val cons : 'a -> 'a t -> 'a t

cons x l is x::l.

  • since 0.12
val append : 'a t -> 'a t -> 'a t

append l1 l2 returns the list that is the concatenation of l1 and l2. Safe version of List.append.

val cons' : 'a t -> 'a -> 'a t

cons' l x is the same as x :: l. This is convenient for fold functions such as List.fold_left or Array.fold_left.

  • since 3.3
val cons_maybe : 'a option -> 'a t -> 'a t

cons_maybe (Some x) l is x :: l. cons_maybe None l is l.

  • since 0.13
val (@) : 'a t -> 'a t -> 'a t

l1 @ l2 is like append l1 l2. Concatenate the two lists l1 and l2.

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

filter ~f l returns all the elements of the list l that satisfy the predicate f. The order of the elements in the input list l is preserved. Safe version of List.filter.

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

fold_right ~f [a1; …; an] ~init is f a1 (f a2 ( … (f an init) … )). Safe version of List.fold_right.

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

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

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

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

  • since 0.14
val fold_map_i : f:('acc -> int -> 'a -> 'acc * 'b) -> init:'acc -> +CCListLabels (containers.CCListLabels)

Module CCListLabels

Complements to ListLabels

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

Fast internal iterator.

  • since 2.8
type 'a gen = unit -> 'a option
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a random_gen = Stdlib.Random.State.t -> 'a
include module type of Stdlib.ListLabels
val length : 'a list -> int
val hd : 'a list -> 'a
val tl : 'a list -> 'a list
val nth : 'a list -> int -> 'a
val rev : 'a list -> 'a list
val rev_append : 'a list -> 'a list -> 'a list
val concat : 'a list list -> 'a list
val iter : f:('a -> unit) -> 'a list -> unit
val rev_map : f:('a -> 'b) -> 'a list -> 'b list
val concat_map : f:('a -> 'b list) -> 'a list -> 'b list
val fold_left_map : f:('a -> 'b -> 'a * 'c) -> init:'a -> 'b list -> 'a * 'c list
val fold_left : f:('a -> 'b -> 'a) -> init:'a -> 'b list -> 'a
val iter2 : f:('a -> 'b -> unit) -> 'a list -> 'b list -> unit
val map2 : f:('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
val rev_map2 : f:('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
val fold_left2 : f:('a -> 'b -> 'c -> 'a) -> init:'a -> 'b list -> 'c list -> 'a
val fold_right2 : f:('a -> 'b -> 'c -> 'c) -> 'a list -> 'b list -> init:'c -> 'c
val for_all : f:('a -> bool) -> 'a list -> bool
val exists : f:('a -> bool) -> 'a list -> bool
val for_all2 : f:('a -> 'b -> bool) -> 'a list -> 'b list -> bool
val exists2 : f:('a -> 'b -> bool) -> 'a list -> 'b list -> bool
val memq : 'a -> set:'a list -> bool
val find : f:('a -> bool) -> 'a list -> 'a
val find_all : f:('a -> bool) -> 'a list -> 'a list
val filteri : f:(int -> 'a -> bool) -> 'a list -> 'a list
val partition : f:('a -> bool) -> 'a list -> 'a list * 'a list
val assq : 'a -> ('a * 'b) list -> 'b
val mem_assq : 'a -> map:('a * 'b) list -> bool
val remove_assq : 'a -> ('a * 'b) list -> ('a * 'b) list
val sort : cmp:('a -> 'a -> int) -> 'a list -> 'a list
val stable_sort : cmp:('a -> 'a -> int) -> 'a list -> 'a list
val fast_sort : cmp:('a -> 'a -> int) -> 'a list -> 'a list
val merge : cmp:('a -> 'a -> int) -> 'a list -> 'a list -> 'a list
type 'a t = 'a list
val empty : 'a t

empty is [].

val is_empty : _ t -> bool

is_empty l returns true iff l = [].

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

map ~f [a0; a1; …; an] applies function f in turn to [a0; a1; …; an]. Safe version of List.map.

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

l >|= f is the infix version of map with reversed arguments.

  • since 0.5
val cons : 'a -> 'a t -> 'a t

cons x l is x::l.

  • since 0.12
val append : 'a t -> 'a t -> 'a t

append l1 l2 returns the list that is the concatenation of l1 and l2. Safe version of List.append.

val cons' : 'a t -> 'a -> 'a t

cons' l x is the same as x :: l. This is convenient for fold functions such as List.fold_left or Array.fold_left.

  • since 3.3
val cons_maybe : 'a option -> 'a t -> 'a t

cons_maybe (Some x) l is x :: l. cons_maybe None l is l.

  • since 0.13
val (@) : 'a t -> 'a t -> 'a t

l1 @ l2 is like append l1 l2. Concatenate the two lists l1 and l2.

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

filter ~f l returns all the elements of the list l that satisfy the predicate f. The order of the elements in the input list l is preserved. Safe version of List.filter.

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

fold_right ~f [a1; …; an] ~init is f a1 (f a2 ( … (f an init) … )). Safe version of List.fold_right.

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

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

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

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

  • since 0.14
val fold_map_i : f:('acc -> int -> 'a -> 'acc * 'b) -> init:'acc -> 'a list -> 'acc * 'b list

fold_map_i ~f ~init l is a foldi-like function, but it also maps the list to another list.

  • since 2.8
val fold_on_map : f:('a -> 'b) -> reduce:('acc -> 'b -> 'acc) -> init:'acc -> 'a list -> 'acc

fold_on_map ~f ~reduce ~init l combines map ~f and fold_left ~reduce ~init in one operation.

  • since 2.8
val scan_left : f:('acc -> 'a -> 'acc) -> init:'acc -> 'a list -> 'acc list

scan_left ~f ~init l returns the list [init; f init x0; f (f init x0) x1; …] where x0, x1, etc. are the elements of l.

  • since 1.2, but only
  • since 2.2 with labels
val reduce : f:('a -> 'a -> 'a) -> 'a list -> 'a option

reduce f (hd::tl) returns Some (fold_left f hd tl). If l is empty, then None is returned.

  • since 3.2
val reduce_exn : f:('a -> 'a -> 'a) -> 'a list -> 'a

reduce_exn is the unsafe version of reduce.

  • raises Invalid_argument

    if the given list is empty.

  • since 3.2
val fold_map2 : f:('acc -> 'a -> 'b -> 'acc * 'c) -> init:'acc -> 'a list -> 'b list -> 'acc * 'c list

fold_map2 ~f ~init l1 l2 is to fold_map what List.map2 is to List.map.

  • raises Invalid_argument

    if the lists do not have the same length.

  • since 0.16
val fold_filter_map : f:('acc -> 'a -> 'acc * 'b option) -> init:'acc -> diff --git a/dev/containers/CCMap/index.html b/dev/containers/CCMap/index.html index 8e4b0fa6..c7971ed5 100644 --- a/dev/containers/CCMap/index.html +++ b/dev/containers/CCMap/index.html @@ -1,2 +1,2 @@ -CCMap (containers.CCMap)

Module CCMap

Extensions of Standard Map

Provide useful functions and iterators on Map.S

  • since 0.5
type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

  • since 2.8
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
module type OrderedType = Stdlib.Map.OrderedType
module type S = sig ... end
module Make (O : Stdlib.Map.OrderedType) : S with type 'a t = 'a Stdlib.Map.Make(O).t and type key = O.t
\ No newline at end of file +CCMap (containers.CCMap)

Module CCMap

Extensions of Standard Map

Provide useful functions and iterators on Map.S

  • since 0.5
type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

  • since 2.8
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
module type OrderedType = Stdlib.Map.OrderedType
module type S = sig ... end
module Make (O : Stdlib.Map.OrderedType) : S with type 'a t = 'a Stdlib.Map.Make(O).t and type key = O.t
\ No newline at end of file diff --git a/dev/containers/CCNativeint/index.html b/dev/containers/CCNativeint/index.html index f479b308..934bb196 100644 --- a/dev/containers/CCNativeint/index.html +++ b/dev/containers/CCNativeint/index.html @@ -1,2 +1,2 @@ -CCNativeint (containers.CCNativeint)

Module CCNativeint

Nativeint

Helpers for processor-native integers

This module provides operations on the type nativeint of signed 32-bit integers (on 32-bit platforms) or signed 64-bit integers (on 64-bit platforms). This integer type has exactly the same width as that of a pointer type in the C compiler. All arithmetic operations over nativeint are taken modulo 232 or 264 depending on the word size of the architecture.

Performance notice: values of type nativeint occupy more memory space than values of type int, and arithmetic operations on nativeint are generally slower than those on int. Use nativeint only when the application requires the extra bit of precision over the int type.

  • since 2.1
include module type of struct include Stdlib.Nativeint end
val zero : nativeint
val one : nativeint
val minus_one : nativeint
val neg : nativeint -> nativeint
val add : nativeint -> nativeint -> nativeint
val sub : nativeint -> nativeint -> nativeint
val mul : nativeint -> nativeint -> nativeint
val div : nativeint -> nativeint -> nativeint
val unsigned_div : nativeint -> nativeint -> nativeint
val rem : nativeint -> nativeint -> nativeint
val unsigned_rem : nativeint -> nativeint -> nativeint
val succ : nativeint -> nativeint
val pred : nativeint -> nativeint
val abs : nativeint -> nativeint
val size : int
val max_int : nativeint
val min_int : nativeint
val logand : nativeint -> nativeint -> nativeint
val logor : nativeint -> nativeint -> nativeint
val logxor : nativeint -> nativeint -> nativeint
val lognot : nativeint -> nativeint
val shift_left : nativeint -> int -> nativeint
val shift_right : nativeint -> int -> nativeint
val shift_right_logical : nativeint -> int -> nativeint
val of_int : int -> nativeint
val to_int : nativeint -> int
val unsigned_to_int : nativeint -> int option
val of_float : float -> nativeint
val to_float : nativeint -> float
val of_int32 : int32 -> nativeint
val to_int32 : nativeint -> int32
val to_string : nativeint -> string
type t = nativeint
val compare : t -> t -> int
val unsigned_compare : t -> t -> int
val equal : t -> t -> bool
val format : string -> nativeint -> string
val min : t -> t -> t

min x y returns the minimum of the two integers x and y.

  • since 3.0
val max : t -> t -> t

max x y returns the maximum of the two integers x and y.

  • since 3.0
val hash : t -> int

hash x computes the hash of x. Like Stdlib.abs (to_int x).

val sign : t -> int

sign x return 0 if x = 0, -1 if x < 0 and 1 if x > 0. Same as compare x zero.

  • since 3.0
val pow : t -> t -> t

pow base exponent returns base raised to the power of exponent. pow x y = x^y for positive integers x and y. Raises Invalid_argument if x = y = 0 or y < 0.

  • since 0.11
val floor_div : t -> t -> t

floor_div x n is integer division rounding towards negative infinity. It satisfies x = m * floor_div x n + rem x n.

  • since 3.0
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a random_gen = Stdlib.Random.State.t -> 'a
type 'a iter = ('a -> unit) -> unit
val range_by : step:t -> t -> t -> t iter

range_by ~step i j iterates on integers from i to j included, where the difference between successive elements is step. Use a negative step for a decreasing list.

  • raises Invalid_argument

    if step=0.

  • since 3.0
val range : t -> t -> t iter

range i j iterates on integers from i to j included . It works both for decreasing and increasing ranges.

  • since 3.0
val range' : t -> t -> t iter

range' i j is like range but the second bound j is excluded. For instance range' 0 5 = Iter.of_list [0;1;2;3;4].

  • since 3.0
val random : t -> t random_gen
val random_small : t random_gen
val random_range : t -> t -> t random_gen

Conversion

val of_string : string -> t option

of_string s is the safe version of of_string_exn. Like of_string_exn, but return None instead of raising.

val of_string_opt : string -> t option

of_string_opt s is an alias to of_string.

val of_string_exn : string -> t

of_string_exn s converts the given string s into a native integer. Alias to Nativeint.of_string. Convert the given string to a native integer. The string is read in decimal (by default, or if the string begins with 0u) or in hexadecimal, octal or binary if the string begins with 0x, 0o or 0b respectively.

The 0u prefix reads the input as an unsigned integer in the range [0, 2*CCNativeint.max_int+1]. If the input exceeds CCNativeint.max_int it is converted to the signed integer CCInt64.min_int + input - CCNativeint.max_int - 1.

Raise Failure "Nativeint.of_string" if the given string is not a valid representation of an integer, or if the integer represented exceeds the range of integers representable in type nativeint.

val to_string_binary : t -> string

to_string_binary x returns the string representation of the integer x, in binary.

  • since 3.0

Printing

val pp : t printer

pp ppf x prints the integer x on ppf.

  • since 3.0
val pp_binary : t printer

pp_binary ppf x prints x on ppf. Print as "0b00101010".

  • since 3.0

Infix Operators

module Infix : sig ... end
include module type of Infix
val (+) : t -> t -> t

x + y is the sum of x and y. Addition.

val (-) : t -> t -> t

x - y is the difference of x and y. Subtraction.

val (~-) : t -> t

~- x is the negation of x. Unary negation.

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

x * y is the product of x and y. Multiplication.

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

x / y is the integer quotient of x and y. Integer division. Raise Division_by_zero if the second argument y is zero. This division rounds the real quotient of its arguments towards zero, as specified for Stdlib.(/).

val (mod) : t -> t -> t

x mod y is the integer remainder of x / y. If y <> zero, the result of x mod y satisfies the following properties: zero <= x mod y < abs y and x = ((x / y) * y) + (x mod y). If y = 0, x mod y raises Division_by_zero.

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

Alias to pow

  • since 3.0
val (--) : t -> t -> t iter

Alias to range.

  • since 3.0
val (--^) : t -> t -> t iter

Alias to range'.

  • since 3.0
val (land) : t -> t -> t

x land y is the bitwise logical and of x and y.

val (lor) : t -> t -> t

x lor y is the bitwise logical or of x and y.

val (lxor) : t -> t -> t

x lxor y is the bitwise logical exclusive or of x and y.

val lnot : t -> t

lnot x is the bitwise logical negation of x (the bits of x are inverted).

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

x lsl y shifts x to the left by y bits. The result is unspecified if y < 0 or y >= bitsize, where bitsize is 32 on a 32-bit platform and 64 on a 64-bit platform.

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

x lsr y shifts x to the right by y bits. This is a logical shift: zeroes are inserted in the vacated bits regardless of the sign of x. The result is unspecified if y < 0 or y >= bitsize.

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

x asr y shifts x to the right by y bits. This is an arithmetic shift: the sign bit of x is replicated and inserted in the vacated bits. The result is unspecified if y < 0 or y >= bitsize.

val (=) : t -> t -> bool
val (<>) : t -> t -> bool
val (>) : t -> t -> bool
val (>=) : t -> t -> bool
val (<=) : t -> t -> bool
val (<) : t -> t -> bool
\ No newline at end of file +CCNativeint (containers.CCNativeint)

Module CCNativeint

Helpers for processor-native integers

This module provides operations on the type nativeint of signed 32-bit integers (on 32-bit platforms) or signed 64-bit integers (on 64-bit platforms). This integer type has exactly the same width as that of a pointer type in the C compiler. All arithmetic operations over nativeint are taken modulo 232 or 264 depending on the word size of the architecture.

Performance notice: values of type nativeint occupy more memory space than values of type int, and arithmetic operations on nativeint are generally slower than those on int. Use nativeint only when the application requires the extra bit of precision over the int type.

  • since 2.1
include module type of struct include Stdlib.Nativeint end
val zero : nativeint
val one : nativeint
val minus_one : nativeint
val neg : nativeint -> nativeint
val add : nativeint -> nativeint -> nativeint
val sub : nativeint -> nativeint -> nativeint
val mul : nativeint -> nativeint -> nativeint
val div : nativeint -> nativeint -> nativeint
val unsigned_div : nativeint -> nativeint -> nativeint
val rem : nativeint -> nativeint -> nativeint
val unsigned_rem : nativeint -> nativeint -> nativeint
val succ : nativeint -> nativeint
val pred : nativeint -> nativeint
val abs : nativeint -> nativeint
val size : int
val max_int : nativeint
val min_int : nativeint
val logand : nativeint -> nativeint -> nativeint
val logor : nativeint -> nativeint -> nativeint
val logxor : nativeint -> nativeint -> nativeint
val lognot : nativeint -> nativeint
val shift_left : nativeint -> int -> nativeint
val shift_right : nativeint -> int -> nativeint
val shift_right_logical : nativeint -> int -> nativeint
val of_int : int -> nativeint
val to_int : nativeint -> int
val unsigned_to_int : nativeint -> int option
val of_float : float -> nativeint
val to_float : nativeint -> float
val of_int32 : int32 -> nativeint
val to_int32 : nativeint -> int32
val to_string : nativeint -> string
type t = nativeint
val compare : t -> t -> int
val unsigned_compare : t -> t -> int
val equal : t -> t -> bool
val format : string -> nativeint -> string
val min : t -> t -> t

min x y returns the minimum of the two integers x and y.

  • since 3.0
val max : t -> t -> t

max x y returns the maximum of the two integers x and y.

  • since 3.0
val hash : t -> int

hash x computes the hash of x. Like Stdlib.abs (to_int x).

val sign : t -> int

sign x return 0 if x = 0, -1 if x < 0 and 1 if x > 0. Same as compare x zero.

  • since 3.0
val pow : t -> t -> t

pow base exponent returns base raised to the power of exponent. pow x y = x^y for positive integers x and y. Raises Invalid_argument if x = y = 0 or y < 0.

  • since 0.11
val floor_div : t -> t -> t

floor_div x n is integer division rounding towards negative infinity. It satisfies x = m * floor_div x n + rem x n.

  • since 3.0
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a random_gen = Stdlib.Random.State.t -> 'a
type 'a iter = ('a -> unit) -> unit
val range_by : step:t -> t -> t -> t iter

range_by ~step i j iterates on integers from i to j included, where the difference between successive elements is step. Use a negative step for a decreasing list.

  • raises Invalid_argument

    if step=0.

  • since 3.0
val range : t -> t -> t iter

range i j iterates on integers from i to j included . It works both for decreasing and increasing ranges.

  • since 3.0
val range' : t -> t -> t iter

range' i j is like range but the second bound j is excluded. For instance range' 0 5 = Iter.of_list [0;1;2;3;4].

  • since 3.0
val random : t -> t random_gen
val random_small : t random_gen
val random_range : t -> t -> t random_gen

Conversion

val of_string : string -> t option

of_string s is the safe version of of_string_exn. Like of_string_exn, but return None instead of raising.

val of_string_opt : string -> t option

of_string_opt s is an alias to of_string.

val of_string_exn : string -> t

of_string_exn s converts the given string s into a native integer. Alias to Nativeint.of_string. Convert the given string to a native integer. The string is read in decimal (by default, or if the string begins with 0u) or in hexadecimal, octal or binary if the string begins with 0x, 0o or 0b respectively.

The 0u prefix reads the input as an unsigned integer in the range [0, 2*CCNativeint.max_int+1]. If the input exceeds CCNativeint.max_int it is converted to the signed integer CCInt64.min_int + input - CCNativeint.max_int - 1.

Raise Failure "Nativeint.of_string" if the given string is not a valid representation of an integer, or if the integer represented exceeds the range of integers representable in type nativeint.

val to_string_binary : t -> string

to_string_binary x returns the string representation of the integer x, in binary.

  • since 3.0

Printing

val pp : t printer

pp ppf x prints the integer x on ppf.

  • since 3.0
val pp_binary : t printer

pp_binary ppf x prints x on ppf. Print as "0b00101010".

  • since 3.0

Infix Operators

module Infix : sig ... end
include module type of Infix
val (+) : t -> t -> t

x + y is the sum of x and y. Addition.

val (-) : t -> t -> t

x - y is the difference of x and y. Subtraction.

val (~-) : t -> t

~- x is the negation of x. Unary negation.

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

x * y is the product of x and y. Multiplication.

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

x / y is the integer quotient of x and y. Integer division. Raise Division_by_zero if the second argument y is zero. This division rounds the real quotient of its arguments towards zero, as specified for Stdlib.(/).

val (mod) : t -> t -> t

x mod y is the integer remainder of x / y. If y <> zero, the result of x mod y satisfies the following properties: zero <= x mod y < abs y and x = ((x / y) * y) + (x mod y). If y = 0, x mod y raises Division_by_zero.

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

Alias to pow

  • since 3.0
val (--) : t -> t -> t iter

Alias to range.

  • since 3.0
val (--^) : t -> t -> t iter

Alias to range'.

  • since 3.0
val (land) : t -> t -> t

x land y is the bitwise logical and of x and y.

val (lor) : t -> t -> t

x lor y is the bitwise logical or of x and y.

val (lxor) : t -> t -> t

x lxor y is the bitwise logical exclusive or of x and y.

val lnot : t -> t

lnot x is the bitwise logical negation of x (the bits of x are inverted).

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

x lsl y shifts x to the left by y bits. The result is unspecified if y < 0 or y >= bitsize, where bitsize is 32 on a 32-bit platform and 64 on a 64-bit platform.

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

x lsr y shifts x to the right by y bits. This is a logical shift: zeroes are inserted in the vacated bits regardless of the sign of x. The result is unspecified if y < 0 or y >= bitsize.

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

x asr y shifts x to the right by y bits. This is an arithmetic shift: the sign bit of x is replicated and inserted in the vacated bits. The result is unspecified if y < 0 or y >= bitsize.

val (=) : t -> t -> bool
val (<>) : t -> t -> bool
val (>) : t -> t -> bool
val (>=) : t -> t -> bool
val (<=) : t -> t -> bool
val (<) : t -> t -> bool
\ No newline at end of file diff --git a/dev/containers/CCOpt/index.html b/dev/containers/CCOpt/index.html index 48940ae4..081e9fb0 100644 --- a/dev/containers/CCOpt/index.html +++ b/dev/containers/CCOpt/index.html @@ -1,2 +1,2 @@ -CCOpt (containers.CCOpt)

Module CCOpt

Option module

  • deprecated

    use `CCOption` instead.

include module type of CCOption
type +'a t = 'a option
val map : ('a -> 'b) -> 'a t -> 'b t

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

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

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

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

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

  • since 1.2
val is_some : _ t -> bool

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

val is_none : _ t -> bool

is_none None returns true otherwise it returns false.

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

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

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

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

val return : 'a -> 'a t

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

val some : 'a -> 'a t

Alias to return.

  • since 3.5
val none : 'a t

Alias to None.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  • raises Invalid_argument

    if the option is None.

  • deprecated

    use get_exn_or instead

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

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

  • raises Invalid_argument

    if the option is None.

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

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

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

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

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

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

  • parameter handler

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

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

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

Applicative

val pure : 'a -> 'a t

pure x is an alias to return.

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

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

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

f <$> o is like map f o.

Alternatives

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

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

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

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

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

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

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

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

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

flatten oo transforms Some x into x.

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

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

  • since 2.2

Infix Operators

  • since 0.16
module Infix : sig ... end

Let operators on OCaml >= 4.08.0, nothing otherwise

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

Conversion and IO

val to_list : 'a t -> 'a list

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

val of_list : 'a list -> 'a t

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

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

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

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

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

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

of_result result returns an option from a result.

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

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

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

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

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

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

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

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

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

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

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

pp ppf o pretty-prints option o using ppf.

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

Module CCOpt

Previous Option module

  • deprecated

    use `CCOption` instead.

include module type of CCOption
type +'a t = 'a option
val map : ('a -> 'b) -> 'a t -> 'b t

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

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

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

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

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

  • since 1.2
val is_some : _ t -> bool

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

val is_none : _ t -> bool

is_none None returns true otherwise it returns false.

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

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

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

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

val return : 'a -> 'a t

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

val some : 'a -> 'a t

Alias to return.

  • since 3.5
val none : 'a t

Alias to None.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

value o ~default is similar to the Stdlib's Option.value and to get_or.

  • since 2.8
val get_exn : 'a t -> 'a

get_exn o returns x if o is Some x or fails if o is None.

  • raises Invalid_argument

    if the option is None.

  • deprecated

    use get_exn_or instead

val get_exn_or : string -> 'a t -> 'a

get_exn_or msg o returns x if o is Some x or fails with Invalid_argument msg if o is None.

  • raises Invalid_argument

    if the option is None.

  • since 3.4
val get_lazy : (unit -> 'a) -> 'a t -> 'a

get_lazy default_fn o unwraps o, but if o is None it returns default_fn () instead.

  • since 0.6.1
val sequence_l : 'a t list -> 'a list t

sequence_l [x1; x2; …; xn] returns Some [y1; y2; …; yn] if every xi is Some yi. Otherwise, if the list contains at least one None, the result is None.

val wrap : ?handler:(exn -> bool) -> ('a -> 'b) -> 'a -> 'b option

wrap ?handler f x calls f x and returns Some y if f x = y. If f x raises any exception, the result is None. This can be useful to wrap functions such as Map.S.find.

  • parameter handler

    the exception handler, which returns true if the exception is to be caught.

val wrap2 : ?handler:(exn -> bool) -> ('a -> 'b -> 'c) -> 'a -> 'b -> 'c option

wrap2 ?handler f x y is similar to wrap but for binary functions.

Applicative

val pure : 'a -> 'a t

pure x is an alias to return.

val (<*>) : ('a -> 'b) t -> 'a t -> 'b t

f <*> (Some x) returns Some (f x) and f <*> None returns None.

val (<$>) : ('a -> 'b) -> 'a t -> 'b t

f <$> o is like map f o.

Alternatives

val or_ : else_:'a t -> 'a t -> 'a t

or_ ~else_ o is o if o is Some _, else_ if o is None.

  • since 1.2
val or_lazy : else_:(unit -> 'a t) -> 'a t -> 'a t

or_lazy ~else_ o is o if o is Some _, else_ () if o is None.

  • since 1.2
val (<+>) : 'a t -> 'a t -> 'a t

o1 <+> o2 is o1 if o1 is Some _, o2 if o1 is None.

val choice : 'a t list -> 'a t

choice lo returns the first non-None element of the list lo, or None.

val flatten : 'a t t -> 'a t

flatten oo transforms Some x into x.

  • since 2.2
val return_if : bool -> 'a -> 'a t

return_if b x applies Some or None depending on the boolean b. More precisely, return_if false x is None, and return_if true x is Some x.

  • since 2.2

Infix Operators

  • since 0.16
module Infix : sig ... end

Let operators on OCaml >= 4.08.0, nothing otherwise

  • since 2.8
include CCShimsMkLet_.S with type 'a t_let := 'a option
val let+ : 'a option -> ('a -> 'b) -> 'b option
val and+ : 'a option -> 'b option -> ('a * 'b) option
val let* : 'a option -> ('a -> 'b option) -> 'b option
val and* : 'a option -> 'b option -> ('a * 'b) option

Conversion and IO

val to_list : 'a t -> 'a list

to_list o returns [x] if o is Some x or the empty list [] if o is None.

val of_list : 'a list -> 'a t

of_list l returns Some x (x being the head of the list l), or None if l is the empty list.

val to_result : 'e -> 'a t -> ('a'e) Stdlib.result

to_result e o returns Ok x if o is Some x, or Error e if o is None.

  • since 1.2
val to_result_lazy : (unit -> 'e) -> 'a t -> ('a'e) Stdlib.result

to_result_lazy f o returns Ok x if o is Some x or Error f if o is None.

  • since 1.2
val of_result : ('a_) Stdlib.result -> 'a t

of_result result returns an option from a result.

  • since 1.2
type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a random_gen = Stdlib.Random.State.t -> 'a
val random : 'a random_gen -> 'a t random_gen
val choice_iter : 'a t iter -> 'a t

choice_iter iter is similar to choice, but works on iter. It returns the first Some x occurring in iter, or None otherwise.

  • since 3.0
val choice_seq : 'a t Stdlib.Seq.t -> 'a t

choice_seq seq works on Seq.t. It returns the first Some x occurring in seq, or None otherwise.

  • since 3.0
val to_gen : 'a t -> 'a gen

to_gen o is o as a gen. Some x is the singleton gen containing x and None is the empty gen.

val to_seq : 'a t -> 'a Stdlib.Seq.t

to_seq o is o as a sequence Seq.t. Some x is the singleton sequence containing x and None is the empty sequence. Same as Stdlib.Option.to_seq Renamed from to_std_seq since 3.0.

  • since 3.0
val to_iter : 'a t -> 'a iter

to_iter o returns an internal iterator, like in the library Iter.

  • since 2.8
val pp : 'a printer -> 'a t printer

pp ppf o pretty-prints option o using ppf.

\ No newline at end of file diff --git a/dev/containers/CCOption/index.html b/dev/containers/CCOption/index.html index b2e05402..216f5292 100644 --- a/dev/containers/CCOption/index.html +++ b/dev/containers/CCOption/index.html @@ -1,2 +1,2 @@ -CCOption (containers.CCOption)

Module CCOption

Options

This module replaces `CCOpt`.

  • since 3.6
type +'a t = 'a option
val map : ('a -> 'b) -> 'a t -> 'b t

map f o applies the function f to the element inside o, if any.

val map_or : default:'b -> ('a -> 'b) -> 'a t -> 'b

map_or ~default f o is f x if o = Some x, default otherwise.

  • since 0.16
val map_lazy : (unit -> 'b) -> ('a -> 'b) -> 'a t -> 'b

map_lazy default_fn f o if f o if o = Some x, default_fn () otherwise.

  • since 1.2
val is_some : _ t -> bool

is_some (Some x) returns true otherwise it returns false.

val is_none : _ t -> bool

is_none None returns true otherwise it returns false.

  • since 0.11
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int

compare comp o1 o2 compares two options o1 and o2, using custom comparators comp for the value. None is always assumed to be less than Some _.

val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool

equal p o1 o2 tests for equality between option types o1 and o2, using a custom equality predicate p.

val return : 'a -> 'a t

return x is a monadic return, that is return x = Some x.

val some : 'a -> 'a t

Alias to return.

  • since 3.5
val none : 'a t

Alias to None.

  • since 3.5
val (>|=) : 'a t -> ('a -> 'b) -> 'b t

o >|= f is the infix version of map.

val flat_map : ('a -> 'b t) -> 'a t -> 'b t

flat_map f o is equivalent to map followed by flatten. Flip version of >>=.

val bind : 'a t -> ('a -> 'b t) -> 'b t

bind o f is f v if o is Some v, None otherwise. Monadic bind.

  • since 3.0
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t

o >>= f is the infix version of bind.

val map2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t

map2 f o1 o2 maps 'a option and 'b option to a 'c option using f.

val iter : ('a -> unit) -> 'a t -> unit

iter f o applies f to o. Iterate on 0 or 1 element.

val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a

fold f init o is f init x if o is Some x, or init if o is None. Fold on 0 or 1 element.

val filter : ('a -> bool) -> 'a t -> 'a t

filter f o returns Some x if o is Some x and f x is true, or None if f x is false or if o is None. Filter on 0 or 1 element.

  • since 0.5
val if_ : ('a -> bool) -> 'a -> 'a option

if_ f x is Some x if f x, None otherwise.

  • since 0.17
val exists : ('a -> bool) -> 'a t -> bool

exists f o returns true iff there exists an element for which the provided function f evaluates to true.

  • since 0.17
val for_all : ('a -> bool) -> 'a t -> bool

for_all f o returns true iff the provided function f evaluates to true for all elements.

  • since 0.17
val get_or : default:'a -> 'a t -> 'a

get_or ~default o extracts the value from o, or returns default if o is None.

  • since 0.18
val value : 'a t -> default:'a -> 'a

value o ~default is similar to the Stdlib's Option.value and to get_or.

  • since 2.8
val get_exn : 'a t -> 'a

get_exn o returns x if o is Some x or fails if o is None.

  • raises Invalid_argument

    if the option is None.

  • deprecated

    use get_exn_or instead

val get_exn_or : string -> 'a t -> 'a

get_exn_or msg o returns x if o is Some x or fails with Invalid_argument msg if o is None.

  • raises Invalid_argument

    if the option is None.

  • since 3.4
val get_lazy : (unit -> 'a) -> 'a t -> 'a

get_lazy default_fn o unwraps o, but if o is None it returns default_fn () instead.

  • since 0.6.1
val sequence_l : 'a t list -> 'a list t

sequence_l [x1; x2; …; xn] returns Some [y1; y2; …; yn] if every xi is Some yi. Otherwise, if the list contains at least one None, the result is None.

val wrap : ?handler:(exn -> bool) -> ('a -> 'b) -> 'a -> 'b option

wrap ?handler f x calls f x and returns Some y if f x = y. If f x raises any exception, the result is None. This can be useful to wrap functions such as Map.S.find.

  • parameter handler

    the exception handler, which returns true if the exception is to be caught.

val wrap2 : ?handler:(exn -> bool) -> ('a -> 'b -> 'c) -> 'a -> 'b -> 'c option

wrap2 ?handler f x y is similar to wrap but for binary functions.

Applicative

val pure : 'a -> 'a t

pure x is an alias to return.

val (<*>) : ('a -> 'b) t -> 'a t -> 'b t

f <*> (Some x) returns Some (f x) and f <*> None returns None.

val (<$>) : ('a -> 'b) -> 'a t -> 'b t

f <$> o is like map f o.

Alternatives

val or_ : else_:'a t -> 'a t -> 'a t

or_ ~else_ o is o if o is Some _, else_ if o is None.

  • since 1.2
val or_lazy : else_:(unit -> 'a t) -> 'a t -> 'a t

or_lazy ~else_ o is o if o is Some _, else_ () if o is None.

  • since 1.2
val (<+>) : 'a t -> 'a t -> 'a t

o1 <+> o2 is o1 if o1 is Some _, o2 if o1 is None.

val choice : 'a t list -> 'a t

choice lo returns the first non-None element of the list lo, or None.

val flatten : 'a t t -> 'a t

flatten oo transforms Some x into x.

  • since 2.2
val return_if : bool -> 'a -> 'a t

return_if b x applies Some or None depending on the boolean b. More precisely, return_if false x is None, and return_if true x is Some x.

  • since 2.2

Infix Operators

  • since 0.16
module Infix : sig ... end

Let operators on OCaml >= 4.08.0, nothing otherwise

  • since 2.8
include CCShimsMkLet_.S with type 'a t_let := 'a option
val let+ : 'a option -> ('a -> 'b) -> 'b option
val and+ : 'a option -> 'b option -> ('a * 'b) option
val let* : 'a option -> ('a -> 'b option) -> 'b option
val and* : 'a option -> 'b option -> ('a * 'b) option

Conversion and IO

val to_list : 'a t -> 'a list

to_list o returns [x] if o is Some x or the empty list [] if o is None.

val of_list : 'a list -> 'a t

of_list l returns Some x (x being the head of the list l), or None if l is the empty list.

val to_result : 'e -> 'a t -> ('a'e) Stdlib.result

to_result e o returns Ok x if o is Some x, or Error e if o is None.

  • since 1.2
val to_result_lazy : (unit -> 'e) -> 'a t -> ('a'e) Stdlib.result

to_result_lazy f o returns Ok x if o is Some x or Error f if o is None.

  • since 1.2
val of_result : ('a_) Stdlib.result -> 'a t

of_result result returns an option from a result.

  • since 1.2
type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a random_gen = Stdlib.Random.State.t -> 'a
val random : 'a random_gen -> 'a t random_gen
val choice_iter : 'a t iter -> 'a t

choice_iter iter is similar to choice, but works on iter. It returns the first Some x occurring in iter, or None otherwise.

  • since 3.0
val choice_seq : 'a t Stdlib.Seq.t -> 'a t

choice_seq seq works on Seq.t. It returns the first Some x occurring in seq, or None otherwise.

  • since 3.0
val to_gen : 'a t -> 'a gen

to_gen o is o as a gen. Some x is the singleton gen containing x and None is the empty gen.

val to_seq : 'a t -> 'a Stdlib.Seq.t

to_seq o is o as a sequence Seq.t. Some x is the singleton sequence containing x and None is the empty sequence. Same as Stdlib.Option.to_seq Renamed from to_std_seq since 3.0.

  • since 3.0
val to_iter : 'a t -> 'a iter

to_iter o returns an internal iterator, like in the library Iter.

  • since 2.8
val pp : 'a printer -> 'a t printer

pp ppf o pretty-prints option o using ppf.

\ No newline at end of file +CCOption (containers.CCOption)

Module CCOption

Basic operations on the option type.

This module replaces `CCOpt`.

  • since 3.6
type +'a t = 'a option
val map : ('a -> 'b) -> 'a t -> 'b t

map f o applies the function f to the element inside o, if any.

val map_or : default:'b -> ('a -> 'b) -> 'a t -> 'b

map_or ~default f o is f x if o = Some x, default otherwise.

  • since 0.16
val map_lazy : (unit -> 'b) -> ('a -> 'b) -> 'a t -> 'b

map_lazy default_fn f o if f o if o = Some x, default_fn () otherwise.

  • since 1.2
val is_some : _ t -> bool

is_some (Some x) returns true otherwise it returns false.

val is_none : _ t -> bool

is_none None returns true otherwise it returns false.

  • since 0.11
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int

compare comp o1 o2 compares two options o1 and o2, using custom comparators comp for the value. None is always assumed to be less than Some _.

val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool

equal p o1 o2 tests for equality between option types o1 and o2, using a custom equality predicate p.

val return : 'a -> 'a t

return x is a monadic return, that is return x = Some x.

val some : 'a -> 'a t

Alias to return.

  • since 3.5
val none : 'a t

Alias to None.

  • since 3.5
val (>|=) : 'a t -> ('a -> 'b) -> 'b t

o >|= f is the infix version of map.

val flat_map : ('a -> 'b t) -> 'a t -> 'b t

flat_map f o is equivalent to map followed by flatten. Flip version of >>=.

val bind : 'a t -> ('a -> 'b t) -> 'b t

bind o f is f v if o is Some v, None otherwise. Monadic bind.

  • since 3.0
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t

o >>= f is the infix version of bind.

val map2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t

map2 f o1 o2 maps 'a option and 'b option to a 'c option using f.

val iter : ('a -> unit) -> 'a t -> unit

iter f o applies f to o. Iterate on 0 or 1 element.

val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a

fold f init o is f init x if o is Some x, or init if o is None. Fold on 0 or 1 element.

val filter : ('a -> bool) -> 'a t -> 'a t

filter f o returns Some x if o is Some x and f x is true, or None if f x is false or if o is None. Filter on 0 or 1 element.

  • since 0.5
val if_ : ('a -> bool) -> 'a -> 'a option

if_ f x is Some x if f x, None otherwise.

  • since 0.17
val exists : ('a -> bool) -> 'a t -> bool

exists f o returns true iff there exists an element for which the provided function f evaluates to true.

  • since 0.17
val for_all : ('a -> bool) -> 'a t -> bool

for_all f o returns true iff the provided function f evaluates to true for all elements.

  • since 0.17
val get_or : default:'a -> 'a t -> 'a

get_or ~default o extracts the value from o, or returns default if o is None.

  • since 0.18
val value : 'a t -> default:'a -> 'a

value o ~default is similar to the Stdlib's Option.value and to get_or.

  • since 2.8
val get_exn : 'a t -> 'a

get_exn o returns x if o is Some x or fails if o is None.

  • raises Invalid_argument

    if the option is None.

  • deprecated

    use get_exn_or instead

val get_exn_or : string -> 'a t -> 'a

get_exn_or msg o returns x if o is Some x or fails with Invalid_argument msg if o is None.

  • raises Invalid_argument

    if the option is None.

  • since 3.4
val get_lazy : (unit -> 'a) -> 'a t -> 'a

get_lazy default_fn o unwraps o, but if o is None it returns default_fn () instead.

  • since 0.6.1
val sequence_l : 'a t list -> 'a list t

sequence_l [x1; x2; …; xn] returns Some [y1; y2; …; yn] if every xi is Some yi. Otherwise, if the list contains at least one None, the result is None.

val wrap : ?handler:(exn -> bool) -> ('a -> 'b) -> 'a -> 'b option

wrap ?handler f x calls f x and returns Some y if f x = y. If f x raises any exception, the result is None. This can be useful to wrap functions such as Map.S.find.

  • parameter handler

    the exception handler, which returns true if the exception is to be caught.

val wrap2 : ?handler:(exn -> bool) -> ('a -> 'b -> 'c) -> 'a -> 'b -> 'c option

wrap2 ?handler f x y is similar to wrap but for binary functions.

Applicative

val pure : 'a -> 'a t

pure x is an alias to return.

val (<*>) : ('a -> 'b) t -> 'a t -> 'b t

f <*> (Some x) returns Some (f x) and f <*> None returns None.

val (<$>) : ('a -> 'b) -> 'a t -> 'b t

f <$> o is like map f o.

Alternatives

val or_ : else_:'a t -> 'a t -> 'a t

or_ ~else_ o is o if o is Some _, else_ if o is None.

  • since 1.2
val or_lazy : else_:(unit -> 'a t) -> 'a t -> 'a t

or_lazy ~else_ o is o if o is Some _, else_ () if o is None.

  • since 1.2
val (<+>) : 'a t -> 'a t -> 'a t

o1 <+> o2 is o1 if o1 is Some _, o2 if o1 is None.

val choice : 'a t list -> 'a t

choice lo returns the first non-None element of the list lo, or None.

val flatten : 'a t t -> 'a t

flatten oo transforms Some x into x.

  • since 2.2
val return_if : bool -> 'a -> 'a t

return_if b x applies Some or None depending on the boolean b. More precisely, return_if false x is None, and return_if true x is Some x.

  • since 2.2

Infix Operators

  • since 0.16
module Infix : sig ... end

Let operators on OCaml >= 4.08.0, nothing otherwise

  • since 2.8
include CCShimsMkLet_.S with type 'a t_let := 'a option
val let+ : 'a option -> ('a -> 'b) -> 'b option
val and+ : 'a option -> 'b option -> ('a * 'b) option
val let* : 'a option -> ('a -> 'b option) -> 'b option
val and* : 'a option -> 'b option -> ('a * 'b) option

Conversion and IO

val to_list : 'a t -> 'a list

to_list o returns [x] if o is Some x or the empty list [] if o is None.

val of_list : 'a list -> 'a t

of_list l returns Some x (x being the head of the list l), or None if l is the empty list.

val to_result : 'e -> 'a t -> ('a'e) Stdlib.result

to_result e o returns Ok x if o is Some x, or Error e if o is None.

  • since 1.2
val to_result_lazy : (unit -> 'e) -> 'a t -> ('a'e) Stdlib.result

to_result_lazy f o returns Ok x if o is Some x or Error f if o is None.

  • since 1.2
val of_result : ('a_) Stdlib.result -> 'a t

of_result result returns an option from a result.

  • since 1.2
type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a random_gen = Stdlib.Random.State.t -> 'a
val random : 'a random_gen -> 'a t random_gen
val choice_iter : 'a t iter -> 'a t

choice_iter iter is similar to choice, but works on iter. It returns the first Some x occurring in iter, or None otherwise.

  • since 3.0
val choice_seq : 'a t Stdlib.Seq.t -> 'a t

choice_seq seq works on Seq.t. It returns the first Some x occurring in seq, or None otherwise.

  • since 3.0
val to_gen : 'a t -> 'a gen

to_gen o is o as a gen. Some x is the singleton gen containing x and None is the empty gen.

val to_seq : 'a t -> 'a Stdlib.Seq.t

to_seq o is o as a sequence Seq.t. Some x is the singleton sequence containing x and None is the empty sequence. Same as Stdlib.Option.to_seq Renamed from to_std_seq since 3.0.

  • since 3.0
val to_iter : 'a t -> 'a iter

to_iter o returns an internal iterator, like in the library Iter.

  • since 2.8
val pp : 'a printer -> 'a t printer

pp ppf o pretty-prints option o using ppf.

\ No newline at end of file diff --git a/dev/containers/CCOrd/index.html b/dev/containers/CCOrd/index.html index af4f0c40..58518de6 100644 --- a/dev/containers/CCOrd/index.html +++ b/dev/containers/CCOrd/index.html @@ -1,5 +1,5 @@ -CCOrd (containers.CCOrd)

Module CCOrd

Comparisons

type 'a t = 'a -> 'a -> int

Comparison (total ordering) between two elements, that returns an int.

val poly : 'a t

Polymorphic "magic" comparison. Use with care, as it will fail on some types.

  • since 3.6
val compare : 'a t

Polymorphic "magic" comparison.

  • deprecated

    since 3.6 in favor of poly. The reason is that compare is easily shadowed, can shadow other comparators, and is just generally not very descriptive.

val opp : 'a t -> 'a t

Opposite order. For example, opp cmp a b < 0 iff cmp b a > 0. This can be used to sort values in the opposite order, among other things.

val equiv : int -> int -> bool

Returns true iff the two comparison results are the same.

val int : int t
val string : string t
val bool : bool t
val float : float t

Lexicographic Combination

val (<?>) : int -> ('a t * 'a * 'a) -> int

c1 <?> (ord, x, y) returns the same as c1 if c1 is not 0; otherwise it uses ord to compare the two values x and y, of type 'a.

Example:

CCInt.compare 1 3
+CCOrd (containers.CCOrd)

Module CCOrd

Order combinators

Comparisons

type 'a t = 'a -> 'a -> int

Comparison (total ordering) between two elements, that returns an int.

val poly : 'a t

Polymorphic "magic" comparison. Use with care, as it will fail on some types.

  • since 3.6
val compare : 'a t

Polymorphic "magic" comparison.

  • deprecated

    since 3.6 in favor of poly. The reason is that compare is easily shadowed, can shadow other comparators, and is just generally not very descriptive.

val opp : 'a t -> 'a t

Opposite order. For example, opp cmp a b < 0 iff cmp b a > 0. This can be used to sort values in the opposite order, among other things.

val equiv : int -> int -> bool

Returns true iff the two comparison results are the same.

val int : int t
val string : string t
val bool : bool t
val float : float t

Lexicographic Combination

val (<?>) : int -> ('a t * 'a * 'a) -> int

c1 <?> (ord, x, y) returns the same as c1 if c1 is not 0; otherwise it uses ord to compare the two values x and y, of type 'a.

Example:

CCInt.compare 1 3
 <?> (String.compare, "a", "b")
 <?> (CCBool.compare, true, false)

Same example, using only CCOrd::

CCOrd.(int 1 3
   <?> (string, "a", "b")
diff --git a/dev/containers/CCPair/index.html b/dev/containers/CCPair/index.html
index 06197420..cf3a7175 100644
--- a/dev/containers/CCPair/index.html
+++ b/dev/containers/CCPair/index.html
@@ -1,2 +1,2 @@
 
-CCPair (containers.CCPair)

Module CCPair

Tuple Functions

type ('a, 'b) t = 'a * 'b
val make : 'a -> 'b -> ('a'b) t

Make a tuple from its components.

  • since 0.16
val map_fst : ('a -> 'b) -> ('a * 'c) -> 'b * 'c

map_fst f (x, y) returns (f x, y). Renamed from map1 since 3.0.

val map_snd : ('a -> 'b) -> ('c * 'a) -> 'c * 'b

map_snd f (x, y) returns (x, f y). Renamed from map2 since 3.0.

val map : ('a -> 'c) -> ('b -> 'd) -> ('a * 'b) -> 'c * 'd

Synonym to ( *** ). Map on both sides of a tuple.

val map_same : ('a -> 'b) -> ('a * 'a) -> 'b * 'b

Like map but specialized for pairs with elements of the same type.

val map2 : ('a1 -> 'b1 -> 'c1) -> ('a2 -> 'b2 -> 'c2) -> ('a1 * 'a2) -> ('b1 * 'b2) -> 'c1 * 'c2

map2 f g (a,b) (x,y) return (f a x, g b y).

  • since 3.0
val map_same2 : ('a -> 'b -> 'c) -> ('a * 'a) -> ('b * 'b) -> 'c * 'c

map_same2 f (a,b) (x,y) return (f a x, f b y).

  • since 3.0
val fst_map : ('a -> 'b) -> ('a * _) -> 'b

Compose the given function with fst. Rename from map_fst since 3.0.

  • since 0.3.3
val snd_map : ('a -> 'b) -> (_ * 'a) -> 'b

Compose the given function with snd. Rename from map_snd since 3.0.

  • since 0.3.3
val iter : ('a -> 'b -> unit) -> ('a * 'b) -> unit
val swap : ('a * 'b) -> 'b * 'a

Swap the components of the tuple.

val (<<<) : ('a -> 'b) -> ('a * 'c) -> 'b * 'c

Map on the left side of the tuple.

val (>>>) : ('a -> 'b) -> ('c * 'a) -> 'c * 'b

Map on the right side of the tuple.

val (***) : ('a -> 'c) -> ('b -> 'd) -> ('a * 'b) -> 'c * 'd

Map on both sides of a tuple.

val (&&&) : ('a -> 'b) -> ('a -> 'c) -> 'a -> 'b * 'c

f &&& g is fun x -> f x, g x. It splits the computations into two parts.

val merge : ('a -> 'b -> 'c) -> ('a * 'b) -> 'c

Uncurrying (merges the two components of a tuple).

val fold : ('a -> 'b -> 'c) -> ('a * 'b) -> 'c

Synonym to merge.

  • since 0.3.3
val dup : 'a -> 'a * 'a

dup x = (x,x) (duplicate the value).

  • since 0.3.3
val dup_map : ('a -> 'b) -> 'a -> 'a * 'b

dup_map f x = (x, f x). Duplicates the value and applies the function to the second copy.

  • since 0.3.3
val equal : ('a -> 'a -> bool) -> ('b -> 'b -> bool) -> ('a * 'b) -> ('a * 'b) -> bool
val compare : ('a -> 'a -> int) -> ('b -> 'b -> int) -> ('a * 'b) -> ('a * 'b) -> int
val to_string : ?sep:string -> ('a -> string) -> ('b -> string) -> ('a * 'b) -> string

Print tuple in a string

  • since 2.7
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
val pp : ?pp_start:unit printer -> ?pp_stop:unit printer -> ?pp_sep:unit printer -> 'a printer -> 'b printer -> ('a * 'b) printer

Print a pair given an optional separator, an optional start and stop and a method for printing each of its elements.

\ No newline at end of file +CCPair (containers.CCPair)

Module CCPair

Tuple Functions

type ('a, 'b) t = 'a * 'b
val make : 'a -> 'b -> ('a'b) t

Make a tuple from its components.

  • since 0.16
val map_fst : ('a -> 'b) -> ('a * 'c) -> 'b * 'c

map_fst f (x, y) returns (f x, y). Renamed from map1 since 3.0.

val map_snd : ('a -> 'b) -> ('c * 'a) -> 'c * 'b

map_snd f (x, y) returns (x, f y). Renamed from map2 since 3.0.

val map : ('a -> 'c) -> ('b -> 'd) -> ('a * 'b) -> 'c * 'd

Synonym to ( *** ). Map on both sides of a tuple.

val map_same : ('a -> 'b) -> ('a * 'a) -> 'b * 'b

Like map but specialized for pairs with elements of the same type.

val map2 : ('a1 -> 'b1 -> 'c1) -> ('a2 -> 'b2 -> 'c2) -> ('a1 * 'a2) -> ('b1 * 'b2) -> 'c1 * 'c2

map2 f g (a,b) (x,y) return (f a x, g b y).

  • since 3.0
val map_same2 : ('a -> 'b -> 'c) -> ('a * 'a) -> ('b * 'b) -> 'c * 'c

map_same2 f (a,b) (x,y) return (f a x, f b y).

  • since 3.0
val fst_map : ('a -> 'b) -> ('a * _) -> 'b

Compose the given function with fst. Rename from map_fst since 3.0.

  • since 0.3.3
val snd_map : ('a -> 'b) -> (_ * 'a) -> 'b

Compose the given function with snd. Rename from map_snd since 3.0.

  • since 0.3.3
val iter : ('a -> 'b -> unit) -> ('a * 'b) -> unit
val swap : ('a * 'b) -> 'b * 'a

Swap the components of the tuple.

val (<<<) : ('a -> 'b) -> ('a * 'c) -> 'b * 'c

Map on the left side of the tuple.

val (>>>) : ('a -> 'b) -> ('c * 'a) -> 'c * 'b

Map on the right side of the tuple.

val (***) : ('a -> 'c) -> ('b -> 'd) -> ('a * 'b) -> 'c * 'd

Map on both sides of a tuple.

val (&&&) : ('a -> 'b) -> ('a -> 'c) -> 'a -> 'b * 'c

f &&& g is fun x -> f x, g x. It splits the computations into two parts.

val merge : ('a -> 'b -> 'c) -> ('a * 'b) -> 'c

Uncurrying (merges the two components of a tuple).

val fold : ('a -> 'b -> 'c) -> ('a * 'b) -> 'c

Synonym to merge.

  • since 0.3.3
val dup : 'a -> 'a * 'a

dup x = (x,x) (duplicate the value).

  • since 0.3.3
val dup_map : ('a -> 'b) -> 'a -> 'a * 'b

dup_map f x = (x, f x). Duplicates the value and applies the function to the second copy.

  • since 0.3.3
val equal : ('a -> 'a -> bool) -> ('b -> 'b -> bool) -> ('a * 'b) -> ('a * 'b) -> bool
val compare : ('a -> 'a -> int) -> ('b -> 'b -> int) -> ('a * 'b) -> ('a * 'b) -> int
val to_string : ?sep:string -> ('a -> string) -> ('b -> string) -> ('a * 'b) -> string

Print tuple in a string

  • since 2.7
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
val pp : ?pp_start:unit printer -> ?pp_stop:unit printer -> ?pp_sep:unit printer -> 'a printer -> 'b printer -> ('a * 'b) printer

Print a pair given an optional separator, an optional start and stop and a method for printing each of its elements.

\ No newline at end of file diff --git a/dev/containers/CCParse/index.html b/dev/containers/CCParse/index.html index 7eef1fce..7c9b2306 100644 --- a/dev/containers/CCParse/index.html +++ b/dev/containers/CCParse/index.html @@ -1,5 +1,5 @@ -CCParse (containers.CCParse)

Module CCParse

Very Simple Parser Combinators

These combinators can be used to write very simple parsers, for example to extract data from a line-oriented file, or as a replacement to Scanf.

A few examples

Some more advanced example(s) can be found in the /examples directory.

Parse a tree
open CCParse;;
+CCParse (containers.CCParse)

Module CCParse

Very Simple Parser Combinators

These combinators can be used to write very simple parsers, for example to extract data from a line-oriented file, or as a replacement to Scanf.

A few examples

Some more advanced example(s) can be found in the /examples directory.

Parse a tree
open CCParse;;
 
 type tree = L of int | N of tree * tree;;
 
diff --git a/dev/containers/CCRandom/index.html b/dev/containers/CCRandom/index.html
index c2874751..9a6fd392 100644
--- a/dev/containers/CCRandom/index.html
+++ b/dev/containers/CCRandom/index.html
@@ -1,5 +1,5 @@
 
-CCRandom (containers.CCRandom)

Module CCRandom

Random Generators

include module type of struct include Stdlib.Random end
val init : int -> unit
val full_init : int array -> unit
val self_init : unit -> unit
val bits : unit -> int
val int32 : Stdlib.Int32.t -> Stdlib.Int32.t
val nativeint : Stdlib.Nativeint.t -> Stdlib.Nativeint.t
val int64 : Stdlib.Int64.t -> Stdlib.Int64.t
val bool : unit -> bool
module State = Stdlib__random.State
val get_state : unit -> State.t
val set_state : State.t -> unit
type state = Stdlib.Random.State.t
type 'a t = state -> 'a

Random generator for values of type 'a.

type 'a random_gen = 'a t
val return : 'a -> 'a t

return x is the generator that always returns x. Example: let random_int = return 4 (* fair dice roll *).

val flat_map : ('a -> 'b t) -> 'a t -> 'b t

flat_map f g st is f (g st) st.

val (>>=) : 'a t -> ('a -> 'b t) -> 'b t

Monadic bind.

val map : ('a -> 'b) -> 'a t -> 'b t

map f g st is f (g st).

val (>|=) : 'a t -> ('a -> 'b) -> 'b t
val delay : (unit -> 'a t) -> 'a t

Delay evaluation. Useful for side-effectful generators that need some code to run for every call. Example:

let gensym = let r = ref 0 in fun () -> incr r; !r ;;
+CCRandom (containers.CCRandom)

Module CCRandom

Random Generators

include module type of struct include Stdlib.Random end
val init : int -> unit
val full_init : int array -> unit
val self_init : unit -> unit
val bits : unit -> int
val int32 : Stdlib.Int32.t -> Stdlib.Int32.t
val nativeint : Stdlib.Nativeint.t -> Stdlib.Nativeint.t
val int64 : Stdlib.Int64.t -> Stdlib.Int64.t
val bool : unit -> bool
module State = Stdlib__random.State
val get_state : unit -> State.t
val set_state : State.t -> unit
type state = Stdlib.Random.State.t
type 'a t = state -> 'a

Random generator for values of type 'a.

type 'a random_gen = 'a t
val return : 'a -> 'a t

return x is the generator that always returns x. Example: let random_int = return 4 (* fair dice roll *).

val flat_map : ('a -> 'b t) -> 'a t -> 'b t

flat_map f g st is f (g st) st.

val (>>=) : 'a t -> ('a -> 'b t) -> 'b t

Monadic bind.

val map : ('a -> 'b) -> 'a t -> 'b t

map f g st is f (g st).

val (>|=) : 'a t -> ('a -> 'b) -> 'b t
val delay : (unit -> 'a t) -> 'a t

Delay evaluation. Useful for side-effectful generators that need some code to run for every call. Example:

let gensym = let r = ref 0 in fun () -> incr r; !r ;;
 
 delay (fun () ->
   let name = gensym() in
diff --git a/dev/containers/CCRef/index.html b/dev/containers/CCRef/index.html
index 52c45b31..9e503b45 100644
--- a/dev/containers/CCRef/index.html
+++ b/dev/containers/CCRef/index.html
@@ -1,2 +1,2 @@
 
-CCRef (containers.CCRef)

Module CCRef

References

  • since 0.9
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a ord = 'a -> 'a -> int
type 'a eq = 'a -> 'a -> bool
type 'a iter = ('a -> unit) -> unit
type 'a t = 'a Stdlib.ref
val map : ('a -> 'b) -> 'a t -> 'b t

Transform the value.

val create : 'a -> 'a t

Alias to ref.

val iter : ('a -> unit) -> 'a t -> unit

Call the function on the content of the reference.

val update : ('a -> 'a) -> 'a t -> unit

Update the reference's content with the given function.

val incr_then_get : int t -> int

incr_then_get r increments r and returns its new value, think ++r.

  • since 0.17
val get_then_incr : int t -> int

get_then_incr r increments r and returns its old value, think r++.

  • since 0.17
val swap : 'a t -> 'a t -> unit

swap t1 t2 puts !t2 in t1 and !t1 in t2.

  • since 1.4
val compare : 'a ord -> 'a t ord
val equal : 'a eq -> 'a t eq
val to_list : 'a t -> 'a list
val to_iter : 'a t -> 'a iter
  • since 3.0
val pp : 'a printer -> 'a t printer
\ No newline at end of file +CCRef (containers.CCRef)

Module CCRef

Helpers for references

  • since 0.9
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a ord = 'a -> 'a -> int
type 'a eq = 'a -> 'a -> bool
type 'a iter = ('a -> unit) -> unit
type 'a t = 'a Stdlib.ref
val map : ('a -> 'b) -> 'a t -> 'b t

Transform the value.

val create : 'a -> 'a t

Alias to ref.

val iter : ('a -> unit) -> 'a t -> unit

Call the function on the content of the reference.

val update : ('a -> 'a) -> 'a t -> unit

Update the reference's content with the given function.

val incr_then_get : int t -> int

incr_then_get r increments r and returns its new value, think ++r.

  • since 0.17
val get_then_incr : int t -> int

get_then_incr r increments r and returns its old value, think r++.

  • since 0.17
val swap : 'a t -> 'a t -> unit

swap t1 t2 puts !t2 in t1 and !t1 in t2.

  • since 1.4
val compare : 'a ord -> 'a t ord
val equal : 'a eq -> 'a t eq
val to_list : 'a t -> 'a list
val to_iter : 'a t -> 'a iter
  • since 3.0
val pp : 'a printer -> 'a t printer
\ No newline at end of file diff --git a/dev/containers/CCResult/index.html b/dev/containers/CCResult/index.html index 02187a42..5895a1d3 100644 --- a/dev/containers/CCResult/index.html +++ b/dev/containers/CCResult/index.html @@ -1,2 +1,2 @@ -CCResult (containers.CCResult)

Module CCResult

Error Monad

Uses the new "result" type from OCaml 4.03.

  • since 0.16
type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

  • since 2.8
type 'a equal = 'a -> 'a -> bool
type 'a ord = 'a -> 'a -> int
type 'a printer = Stdlib.Format.formatter -> 'a -> unit

Basics

type nonrec (+'good, +'bad) result = ('good'bad) Stdlib.result =
| Ok of 'good
| Error of 'bad
type (+'good, +'bad) t = ('good'bad) result =
| Ok of 'good
| Error of 'bad
val return : 'a -> ('a'err) t

Successfully return a value.

val fail : 'err -> ('a'err) t

Fail with an error.

val of_exn : exn -> ('a, string) t

of_exn e uses Printexc to print the exception as a string.

val of_exn_trace : exn -> ('a, string) t

of_exn_trace e is similar to of_exn e, but it adds the stacktrace to the error message.

Remember to call Printexc.record_backtrace true and compile with the debug flag for this to work.

val fail_printf : ('aStdlib.Buffer.t, unit, ('b, string) t) Stdlib.format4 -> 'a

fail_printf format uses format to obtain an error message and then returns Error msg.

val fail_fprintf : ('aStdlib.Format.formatter, unit, ('b, string) t) Stdlib.format4 -> 'a

fail_fprintf format uses format to obtain an error message and then returns Error msg.

val add_ctx : string -> ('a, string) t -> ('a, string) t

add_ctx msg leaves Ok x untouched, but transforms Error s into Error s' where s' contains the additional context given by msg.

  • since 1.2
val add_ctxf : ('aStdlib.Format.formatter, unit, ('b, string) t -> ('b, string) t) Stdlib.format4 -> 'a

add_ctxf format_message is similar to add_ctx but with Format for printing the message (eagerly). Example:

add_ctxf "message(number %d, foo: %B)" 42 true (Error "error)"
  • since 1.2
val map : ('a -> 'b) -> ('a'err) t -> ('b'err) t

Map on success.

val map_err : ('err1 -> 'err2) -> ('a'err1) t -> ('a'err2) t

Map on the error variant.

val map2 : ('a -> 'b) -> ('err1 -> 'err2) -> ('a'err1) t -> ('b'err2) t

Like map, but also with a function that can transform the error message in case of failure.

val iter : ('a -> unit) -> ('a_) t -> unit

Apply the function only in case of Ok.

val iter_err : ('err -> unit) -> (_'err) t -> unit

Apply the function in case of Error.

  • since 2.4
exception Get_error
val get_exn : ('a_) t -> 'a

Extract the value x from Ok x, fails otherwise. You should be careful with this function, and favor other combinators whenever possible.

  • raises Get_error

    if the value is an error.

val get_or : ('a_) t -> default:'a -> 'a

get_or e ~default returns x if e = Ok x, default otherwise.

val get_or_failwith : ('a, string) t -> 'a

get_or_failwith e returns x if e = Ok x, fails otherwise.

  • raises Failure

    with msg if e = Error msg.

  • since 2.4
val get_lazy : ('b -> 'a) -> ('a'b) t -> 'a

get_lazy default_fn x unwraps x, but if x = Error e it returns default_fr e instead.

  • since 3.0
val map_or : ('a -> 'b) -> ('a'c) t -> default:'b -> 'b

map_or f e ~default returns f x if e = Ok x, default otherwise.

val catch : ('a'err) t -> ok:('a -> 'b) -> err:('err -> 'b) -> 'b

catch e ~ok ~err calls either ok or err depending on the value of e.

val flat_map : ('a -> ('b'err) t) -> ('a'err) t -> ('b'err) t
val equal : err:'err equal -> 'a equal -> ('a'err) t equal
val compare : err:'err ord -> 'a ord -> ('a'err) t ord
val fold : ok:('a -> 'b) -> error:('err -> 'b) -> ('a'err) t -> 'b

fold ~ok ~error e opens e and, if e = Ok x, returns ok x, otherwise e = Error s and it returns error s.

val fold_ok : ('a -> 'b -> 'a) -> 'a -> ('b_) t -> 'a

fold_ok f acc r will compute f acc x if r=Ok x, and return acc otherwise, as if the result were a mere option.

  • since 1.2
val is_ok : ('a'err) t -> bool

Return true if Ok.

  • since 1.0
val is_error : ('a'err) t -> bool

Return true if Error.

  • since 1.0

Wrappers

val guard : (unit -> 'a) -> ('a, exn) t

guard f runs f () and returns its result wrapped in Ok. If f () raises some exception e, then it fails with Error e.

val guard_str : (unit -> 'a) -> ('a, string) t

Like guard but uses of_exn to print the exception.

val guard_str_trace : (unit -> 'a) -> ('a, string) t

Like guard_str but uses of_exn_trace instead of of_exn so that the stack trace is printed.

val wrap1 : ('a -> 'b) -> 'a -> ('b, exn) t

Like guard but gives the function one argument.

val wrap2 : ('a -> 'b -> 'c) -> 'a -> 'b -> ('c, exn) t

Like guard but gives the function two arguments.

val wrap3 : ('a -> 'b -> 'c -> 'd) -> 'a -> 'b -> 'c -> ('d, exn) t

Like guard but gives the function three arguments.

Applicative

val pure : 'a -> ('a'err) t

Synonym of return.

val join : (('a'err) t'err) t -> ('a'err) t

join t, in case of success, returns Ok o from Ok (Ok o). Otherwise, it fails with Error e where e is the unwrapped error of t.

val both : ('a'err) t -> ('b'err) t -> ('a * 'b'err) t

both a b, in case of success, returns Ok (o, o') with the ok values of a and b. Otherwise, it fails, and the error of a is chosen over the error of b if both fail.

Infix

module Infix : sig ... end
include module type of Infix
val (<$>) : ('a -> 'b) -> ('a'err) t -> ('b'err) t

Infix version of map.

  • since 3.0
val (>|=) : ('a'err) t -> ('a -> 'b) -> ('b'err) t

Infix version of map with reversed arguments.

val (>>=) : ('a'err) t -> ('a -> ('b'err) t) -> ('b'err) t

Monadic composition. e >>= f proceeds as f x if e is Ok x or returns e if e is an Error.

val (<*>) : ('a -> 'b'err) t -> ('a'err) t -> ('b'err) t

a <*> b evaluates a and b, and, in case of success, returns Ok (a b). Otherwise, it fails, and the error of a is chosen over the error of b if both fail.

Let operators on OCaml >= 4.08.0, nothing otherwise

  • since 2.8
include CCShimsMkLet_.S2 with type ('a, 'e) t_let2 := ('a'e) result
val let+ : ('a'e) result -> ('a -> 'b) -> ('b'e) result
val and+ : ('a'e) result -> ('b'e) result -> ('a * 'b'e) result
val let* : ('a'e) result -> ('a -> ('b'e) result) -> ('b'e) result
val and* : ('a'e) result -> ('b'e) result -> ('a * 'b'e) result

Let operators on OCaml >= 4.08.0, nothing otherwise

  • since 2.8
include CCShimsMkLet_.S2 with type ('a, 'e) t_let2 := ('a'e) result
val let+ : ('a'e) result -> ('a -> 'b) -> ('b'e) result
val and+ : ('a'e) result -> ('b'e) result -> ('a * 'b'e) result
val let* : ('a'e) result -> ('a -> ('b'e) result) -> ('b'e) result
val and* : ('a'e) result -> ('b'e) result -> ('a * 'b'e) result

Collections

val flatten_l : ('a'err) t list -> ('a list'err) t

Same as map_l id: returns Ok [x1;…;xn] if l=[Ok x1; …; Ok xn], or the first error otherwise.

  • since 2.7
val map_l : ('a -> ('b'err) t) -> 'a list -> ('b list'err) t

map_l f [a1; …; an] applies the function f to a1, …, an ,and, in case of success for every element, returns the list of Ok-value. Otherwise, it fails and returns the first error encountered. Tail-recursive.

val fold_l : ('b -> 'a -> ('b'err) t) -> 'b -> 'a list -> ('b'err) t
val fold_iter : ('b -> 'a -> ('b'err) t) -> 'b -> 'a iter -> ('b'err) t
  • since 3.0

Misc

val choose : ('a'err) t list -> ('a'err list) t

choose l selects a member of l that is a Ok _ value, or returns Error l otherwise, where l is the list of errors.

val retry : int -> (unit -> ('a'err) t) -> ('a'err list) t

retry n f calls f at most n times, returning the first result of f () that doesn't fail. If f fails n times, retry n f fails with the list of successive errors.

module type MONAD = sig ... end
module Traverse (M : MONAD) : sig ... end

Conversions

val to_opt : ('a_) t -> 'a option

Convert a result to an option.

val of_opt : 'a option -> ('a, string) t

Convert an option to a result.

val to_iter : ('a_) t -> 'a iter
  • since 2.8
val to_seq : ('a_) t -> 'a Stdlib.Seq.t

Renamed from to_std_seq since 3.0.

  • since 3.0
type ('a, 'b) error = [
| `Ok of 'a
| `Error of 'b
]
val of_err : ('a'b) error -> ('a'b) t
  • since 0.17
val to_err : ('a'b) t -> ('a'b) error
  • since 0.17

IO

val pp : 'a printer -> ('a, string) t printer
val pp' : 'a printer -> 'e printer -> ('a'e) t printer

Printer that is generic on the error type.

\ No newline at end of file +CCResult (containers.CCResult)

Module CCResult

Error Monad

Uses the new "result" type from OCaml 4.03.

  • since 0.16
type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

  • since 2.8
type 'a equal = 'a -> 'a -> bool
type 'a ord = 'a -> 'a -> int
type 'a printer = Stdlib.Format.formatter -> 'a -> unit

Basics

type nonrec (+'good, +'bad) result = ('good'bad) Stdlib.result =
| Ok of 'good
| Error of 'bad
type (+'good, +'bad) t = ('good'bad) result =
| Ok of 'good
| Error of 'bad
val return : 'a -> ('a'err) t

Successfully return a value.

val fail : 'err -> ('a'err) t

Fail with an error.

val of_exn : exn -> ('a, string) t

of_exn e uses Printexc to print the exception as a string.

val of_exn_trace : exn -> ('a, string) t

of_exn_trace e is similar to of_exn e, but it adds the stacktrace to the error message.

Remember to call Printexc.record_backtrace true and compile with the debug flag for this to work.

val fail_printf : ('aStdlib.Buffer.t, unit, ('b, string) t) Stdlib.format4 -> 'a

fail_printf format uses format to obtain an error message and then returns Error msg.

val fail_fprintf : ('aStdlib.Format.formatter, unit, ('b, string) t) Stdlib.format4 -> 'a

fail_fprintf format uses format to obtain an error message and then returns Error msg.

val add_ctx : string -> ('a, string) t -> ('a, string) t

add_ctx msg leaves Ok x untouched, but transforms Error s into Error s' where s' contains the additional context given by msg.

  • since 1.2
val add_ctxf : ('aStdlib.Format.formatter, unit, ('b, string) t -> ('b, string) t) Stdlib.format4 -> 'a

add_ctxf format_message is similar to add_ctx but with Format for printing the message (eagerly). Example:

add_ctxf "message(number %d, foo: %B)" 42 true (Error "error)"
  • since 1.2
val map : ('a -> 'b) -> ('a'err) t -> ('b'err) t

Map on success.

val map_err : ('err1 -> 'err2) -> ('a'err1) t -> ('a'err2) t

Map on the error variant.

val map2 : ('a -> 'b) -> ('err1 -> 'err2) -> ('a'err1) t -> ('b'err2) t

Like map, but also with a function that can transform the error message in case of failure.

val iter : ('a -> unit) -> ('a_) t -> unit

Apply the function only in case of Ok.

val iter_err : ('err -> unit) -> (_'err) t -> unit

Apply the function in case of Error.

  • since 2.4
exception Get_error
val get_exn : ('a_) t -> 'a

Extract the value x from Ok x, fails otherwise. You should be careful with this function, and favor other combinators whenever possible.

  • raises Get_error

    if the value is an error.

val get_or : ('a_) t -> default:'a -> 'a

get_or e ~default returns x if e = Ok x, default otherwise.

val get_or_failwith : ('a, string) t -> 'a

get_or_failwith e returns x if e = Ok x, fails otherwise.

  • raises Failure

    with msg if e = Error msg.

  • since 2.4
val get_lazy : ('b -> 'a) -> ('a'b) t -> 'a

get_lazy default_fn x unwraps x, but if x = Error e it returns default_fr e instead.

  • since 3.0
val map_or : ('a -> 'b) -> ('a'c) t -> default:'b -> 'b

map_or f e ~default returns f x if e = Ok x, default otherwise.

val catch : ('a'err) t -> ok:('a -> 'b) -> err:('err -> 'b) -> 'b

catch e ~ok ~err calls either ok or err depending on the value of e.

val flat_map : ('a -> ('b'err) t) -> ('a'err) t -> ('b'err) t
val equal : err:'err equal -> 'a equal -> ('a'err) t equal
val compare : err:'err ord -> 'a ord -> ('a'err) t ord
val fold : ok:('a -> 'b) -> error:('err -> 'b) -> ('a'err) t -> 'b

fold ~ok ~error e opens e and, if e = Ok x, returns ok x, otherwise e = Error s and it returns error s.

val fold_ok : ('a -> 'b -> 'a) -> 'a -> ('b_) t -> 'a

fold_ok f acc r will compute f acc x if r=Ok x, and return acc otherwise, as if the result were a mere option.

  • since 1.2
val is_ok : ('a'err) t -> bool

Return true if Ok.

  • since 1.0
val is_error : ('a'err) t -> bool

Return true if Error.

  • since 1.0

Wrappers

val guard : (unit -> 'a) -> ('a, exn) t

guard f runs f () and returns its result wrapped in Ok. If f () raises some exception e, then it fails with Error e.

val guard_str : (unit -> 'a) -> ('a, string) t

Like guard but uses of_exn to print the exception.

val guard_str_trace : (unit -> 'a) -> ('a, string) t

Like guard_str but uses of_exn_trace instead of of_exn so that the stack trace is printed.

val wrap1 : ('a -> 'b) -> 'a -> ('b, exn) t

Like guard but gives the function one argument.

val wrap2 : ('a -> 'b -> 'c) -> 'a -> 'b -> ('c, exn) t

Like guard but gives the function two arguments.

val wrap3 : ('a -> 'b -> 'c -> 'd) -> 'a -> 'b -> 'c -> ('d, exn) t

Like guard but gives the function three arguments.

Applicative

val pure : 'a -> ('a'err) t

Synonym of return.

val join : (('a'err) t'err) t -> ('a'err) t

join t, in case of success, returns Ok o from Ok (Ok o). Otherwise, it fails with Error e where e is the unwrapped error of t.

val both : ('a'err) t -> ('b'err) t -> ('a * 'b'err) t

both a b, in case of success, returns Ok (o, o') with the ok values of a and b. Otherwise, it fails, and the error of a is chosen over the error of b if both fail.

Infix

module Infix : sig ... end
include module type of Infix
val (<$>) : ('a -> 'b) -> ('a'err) t -> ('b'err) t

Infix version of map.

  • since 3.0
val (>|=) : ('a'err) t -> ('a -> 'b) -> ('b'err) t

Infix version of map with reversed arguments.

val (>>=) : ('a'err) t -> ('a -> ('b'err) t) -> ('b'err) t

Monadic composition. e >>= f proceeds as f x if e is Ok x or returns e if e is an Error.

val (<*>) : ('a -> 'b'err) t -> ('a'err) t -> ('b'err) t

a <*> b evaluates a and b, and, in case of success, returns Ok (a b). Otherwise, it fails, and the error of a is chosen over the error of b if both fail.

Let operators on OCaml >= 4.08.0, nothing otherwise

  • since 2.8
include CCShimsMkLet_.S2 with type ('a, 'e) t_let2 := ('a'e) result
val let+ : ('a'e) result -> ('a -> 'b) -> ('b'e) result
val and+ : ('a'e) result -> ('b'e) result -> ('a * 'b'e) result
val let* : ('a'e) result -> ('a -> ('b'e) result) -> ('b'e) result
val and* : ('a'e) result -> ('b'e) result -> ('a * 'b'e) result

Let operators on OCaml >= 4.08.0, nothing otherwise

  • since 2.8
include CCShimsMkLet_.S2 with type ('a, 'e) t_let2 := ('a'e) result
val let+ : ('a'e) result -> ('a -> 'b) -> ('b'e) result
val and+ : ('a'e) result -> ('b'e) result -> ('a * 'b'e) result
val let* : ('a'e) result -> ('a -> ('b'e) result) -> ('b'e) result
val and* : ('a'e) result -> ('b'e) result -> ('a * 'b'e) result

Collections

val flatten_l : ('a'err) t list -> ('a list'err) t

Same as map_l id: returns Ok [x1;…;xn] if l=[Ok x1; …; Ok xn], or the first error otherwise.

  • since 2.7
val map_l : ('a -> ('b'err) t) -> 'a list -> ('b list'err) t

map_l f [a1; …; an] applies the function f to a1, …, an ,and, in case of success for every element, returns the list of Ok-value. Otherwise, it fails and returns the first error encountered. Tail-recursive.

val fold_l : ('b -> 'a -> ('b'err) t) -> 'b -> 'a list -> ('b'err) t
val fold_iter : ('b -> 'a -> ('b'err) t) -> 'b -> 'a iter -> ('b'err) t
  • since 3.0

Misc

val choose : ('a'err) t list -> ('a'err list) t

choose l selects a member of l that is a Ok _ value, or returns Error l otherwise, where l is the list of errors.

val retry : int -> (unit -> ('a'err) t) -> ('a'err list) t

retry n f calls f at most n times, returning the first result of f () that doesn't fail. If f fails n times, retry n f fails with the list of successive errors.

module type MONAD = sig ... end
module Traverse (M : MONAD) : sig ... end

Conversions

val to_opt : ('a_) t -> 'a option

Convert a result to an option.

val of_opt : 'a option -> ('a, string) t

Convert an option to a result.

val to_iter : ('a_) t -> 'a iter
  • since 2.8
val to_seq : ('a_) t -> 'a Stdlib.Seq.t

Renamed from to_std_seq since 3.0.

  • since 3.0
type ('a, 'b) error = [
| `Ok of 'a
| `Error of 'b
]
val of_err : ('a'b) error -> ('a'b) t
  • since 0.17
val to_err : ('a'b) t -> ('a'b) error
  • since 0.17

IO

val pp : 'a printer -> ('a, string) t printer
val pp' : 'a printer -> 'e printer -> ('a'e) t printer

Printer that is generic on the error type.

\ No newline at end of file diff --git a/dev/containers/CCSeq/index.html b/dev/containers/CCSeq/index.html index 5edd9f2f..050d5471 100644 --- a/dev/containers/CCSeq/index.html +++ b/dev/containers/CCSeq/index.html @@ -1,2 +1,2 @@ -CCSeq (containers.CCSeq)

Module CCSeq

Helpers for the standard Seq type

See oseq for a richer API.

type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
type 'a equal = 'a -> 'a -> bool
type 'a ord = 'a -> 'a -> int
type 'a printer = Stdlib.Format.formatter -> 'a -> unit

Basics

type +'a t = unit -> 'a node
and +'a node = 'a Stdlib.Seq.node =
| Nil
| Cons of 'a * 'a t
val nil : 'a t
val empty : 'a t
val cons : 'a -> 'a t -> 'a t
val singleton : 'a -> 'a t
val repeat : ?n:int -> 'a -> 'a t

repeat ~n x repeats x n times then stops. If n is omitted, then x is repeated forever.

  • since 0.3.3
val cycle : 'a t -> 'a t

Cycle through the iterator infinitely. The iterator shouldn't be empty.

  • since 0.3.3
val unfold : ('b -> ('a * 'b) option) -> 'b -> 'a t

unfold f acc calls f acc and:

  • if f acc = Some (x, acc'), yield x, continue with unfold f acc'.
  • if f acc = None, stops.
  • since 0.13
val is_empty : 'a t -> bool
val head : 'a t -> 'a option

Head of the list.

  • since 0.13
val head_exn : 'a t -> 'a

Unsafe version of head.

  • raises Not_found

    if the list is empty.

  • since 0.13
val tail : 'a t -> 'a t option

Tail of the list.

  • since 0.13
val tail_exn : 'a t -> 'a t

Unsafe version of tail.

  • raises Not_found

    if the list is empty.

  • since 0.13
val equal : 'a equal -> 'a t equal

Equality step by step. Eager.

val compare : 'a ord -> 'a t ord

Lexicographic comparison. Eager.

val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a

Fold on values.

val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a

Alias for fold

val iter : ('a -> unit) -> 'a t -> unit
val iteri : (int -> 'a -> unit) -> 'a t -> unit

Iterate with index (starts at 0).

  • since 0.13
val length : _ t -> int

Number of elements in the list. Will not terminate if the list if infinite: use (for instance) take to make the list finite if necessary.

val take : int -> 'a t -> 'a t
val take_while : ('a -> bool) -> 'a t -> 'a t
val drop : int -> 'a t -> 'a t
val drop_while : ('a -> bool) -> 'a t -> 'a t
val map : ('a -> 'b) -> 'a t -> 'b t
val mapi : (int -> 'a -> 'b) -> 'a t -> 'b t

Map with index (starts at 0).

  • since 0.13
val fmap : ('a -> 'b option) -> 'a t -> 'b t
val filter : ('a -> bool) -> 'a t -> 'a t
val append : 'a t -> 'a t -> 'a t
val product_with : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t

Fair product of two (possibly infinite) lists into a new list. Lazy. The first parameter is used to combine each pair of elements.

  • since 0.3.3
val product : 'a t -> 'b t -> ('a * 'b) t

Specialization of product_with producing tuples.

  • since 0.3.3
val group : 'a equal -> 'a t -> 'a t t

group eq l groups together consecutive elements that satisfy eq. Lazy. For instance group (=) [1;1;1;2;2;3;3;1] yields [1;1;1]; [2;2]; [3;3]; [1].

  • since 0.3.3
val uniq : 'a equal -> 'a t -> 'a t

uniq eq l returns l but removes consecutive duplicates. Lazy. In other words, if several values that are equal follow one another, only the first of them is kept.

  • since 0.3.3
val for_all : ('a -> bool) -> 'a t -> bool

for_all p [a1; ...; an] checks if all elements of the sequence satisfy the predicate p. That is, it returns (p a1) && ... && (p an) for a non-empty list and true if the sequence is empty. It consumes the sequence until it finds an element not satisfying the predicate.

  • since 3.3
val exists : ('a -> bool) -> 'a t -> bool

exists p [a1; ...; an] checks if at least one element of the sequence satisfies the predicate p. That is, it returns (p a1) || ... || (p an) for a non-empty sequence and false if the list is empty. It consumes the sequence until it finds an element satisfying the predicate.

  • since 3.3
val flat_map : ('a -> 'b t) -> 'a t -> 'b t
val filter_map : ('a -> 'b option) -> 'a t -> 'b t
val flatten : 'a t t -> 'a t
val range : int -> int -> int t
val (--) : int -> int -> int t

a -- b is the range of integers containing a and b (therefore, never empty).

val (--^) : int -> int -> int t

a -- b is the integer range from a to b, where b is excluded.

  • since 0.17

Operations on two Collections

val fold2 : ('acc -> 'a -> 'b -> 'acc) -> 'acc -> 'a t -> 'b t -> 'acc

Fold on two collections at once. Stop at soon as one of them ends.

val map2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t

Map on two collections at once. Stop as soon as one of the arguments is exhausted.

val iter2 : ('a -> 'b -> unit) -> 'a t -> 'b t -> unit

Iterate on two collections at once. Stop as soon as one of them ends.

val for_all2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool
val exists2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool
val merge : 'a ord -> 'a t -> 'a t -> 'a t

Merge two sorted iterators into a sorted iterator.

val zip : 'a t -> 'b t -> ('a * 'b) t

Combine elements pairwise. Stop as soon as one of the lists stops.

  • since 0.13
val unzip : ('a * 'b) t -> 'a t * 'b t

Split each tuple in the list.

  • since 0.13

Misc

val sort : cmp:'a ord -> 'a t -> 'a t

Eager sort. Require the iterator to be finite. O(n ln(n)) time and space.

  • since 0.3.3
val sort_uniq : cmp:'a ord -> 'a t -> 'a t

Eager sort that removes duplicate values. Require the iterator to be finite. O(n ln(n)) time and space.

  • since 0.3.3
val memoize : 'a t -> 'a t

Avoid recomputations by caching intermediate results.

  • since 0.14

Fair Combinations

val interleave : 'a t -> 'a t -> 'a t

Fair interleaving of both streams.

  • since 0.13
val fair_flat_map : ('a -> 'b t) -> 'a t -> 'b t

Fair version of flat_map.

  • since 0.13
val fair_app : ('a -> 'b) t -> 'a t -> 'b t

Fair version of (<*>).

  • since 0.13

Implementations

  • since 0.3.3
val return : 'a -> 'a t
val pure : 'a -> 'a t
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t
val (>|=) : 'a t -> ('a -> 'b) -> 'b t
val (<*>) : ('a -> 'b) t -> 'a t -> 'b t
val (>>-) : 'a t -> ('a -> 'b t) -> 'b t

Infix version of fair_flat_map.

  • since 0.13
val (<.>) : ('a -> 'b) t -> 'a t -> 'b t

Infix version of fair_app.

  • since 0.13

Infix operators

  • since 0.17
module Infix : sig ... end
module type MONAD = sig ... end
module Traverse (M : MONAD) : sig ... end

Conversions

val of_list : 'a list -> 'a t
val to_list : 'a t -> 'a list

Gather all values into a list.

val of_array : 'a array -> 'a t

Iterate on the array.

  • since 0.13
val to_array : 'a t -> 'a array

Convert into array. Iterate twice.

  • since 0.13
val to_rev_list : 'a t -> 'a list

Convert to a list, in reverse order. More efficient than to_list.

val to_iter : 'a t -> 'a iter
val to_gen : 'a t -> 'a gen
val of_gen : 'a gen -> 'a t

of_gen g consumes the generator and caches intermediate results.

  • since 0.13

IO

val pp : ?pp_start:unit printer -> ?pp_stop:unit printer -> ?pp_sep:unit printer -> 'a printer -> 'a t printer

pp ~pp_start ~pp_stop ~pp_sep pp_item ppf s formats the sequence s on ppf. Each element is formatted with pp_item, pp_start is called at the beginning, pp_stop is called at the end, pp_sep is called between each elements. By defaults pp_start and pp_stop does nothing and pp_sep defaults to (fun out -> Format.fprintf out ",@ ").

\ No newline at end of file +CCSeq (containers.CCSeq)

Module CCSeq

Helpers for the standard Seq type

See oseq for a richer API.

type 'a iter = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
type 'a equal = 'a -> 'a -> bool
type 'a ord = 'a -> 'a -> int
type 'a printer = Stdlib.Format.formatter -> 'a -> unit

Basics

type +'a t = unit -> 'a node
and +'a node = 'a Stdlib.Seq.node =
| Nil
| Cons of 'a * 'a t
val nil : 'a t
val empty : 'a t
val cons : 'a -> 'a t -> 'a t
val singleton : 'a -> 'a t
val repeat : ?n:int -> 'a -> 'a t

repeat ~n x repeats x n times then stops. If n is omitted, then x is repeated forever.

  • since 0.3.3
val cycle : 'a t -> 'a t

Cycle through the iterator infinitely. The iterator shouldn't be empty.

  • since 0.3.3
val unfold : ('b -> ('a * 'b) option) -> 'b -> 'a t

unfold f acc calls f acc and:

  • if f acc = Some (x, acc'), yield x, continue with unfold f acc'.
  • if f acc = None, stops.
  • since 0.13
val is_empty : 'a t -> bool
val head : 'a t -> 'a option

Head of the list.

  • since 0.13
val head_exn : 'a t -> 'a

Unsafe version of head.

  • raises Not_found

    if the list is empty.

  • since 0.13
val tail : 'a t -> 'a t option

Tail of the list.

  • since 0.13
val tail_exn : 'a t -> 'a t

Unsafe version of tail.

  • raises Not_found

    if the list is empty.

  • since 0.13
val equal : 'a equal -> 'a t equal

Equality step by step. Eager.

val compare : 'a ord -> 'a t ord

Lexicographic comparison. Eager.

val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a

Fold on values.

val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a

Alias for fold

val iter : ('a -> unit) -> 'a t -> unit
val iteri : (int -> 'a -> unit) -> 'a t -> unit

Iterate with index (starts at 0).

  • since 0.13
val length : _ t -> int

Number of elements in the list. Will not terminate if the list if infinite: use (for instance) take to make the list finite if necessary.

val take : int -> 'a t -> 'a t
val take_while : ('a -> bool) -> 'a t -> 'a t
val drop : int -> 'a t -> 'a t
val drop_while : ('a -> bool) -> 'a t -> 'a t
val map : ('a -> 'b) -> 'a t -> 'b t
val mapi : (int -> 'a -> 'b) -> 'a t -> 'b t

Map with index (starts at 0).

  • since 0.13
val fmap : ('a -> 'b option) -> 'a t -> 'b t
val filter : ('a -> bool) -> 'a t -> 'a t
val append : 'a t -> 'a t -> 'a t
val product_with : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t

Fair product of two (possibly infinite) lists into a new list. Lazy. The first parameter is used to combine each pair of elements.

  • since 0.3.3
val product : 'a t -> 'b t -> ('a * 'b) t

Specialization of product_with producing tuples.

  • since 0.3.3
val group : 'a equal -> 'a t -> 'a t t

group eq l groups together consecutive elements that satisfy eq. Lazy. For instance group (=) [1;1;1;2;2;3;3;1] yields [1;1;1]; [2;2]; [3;3]; [1].

  • since 0.3.3
val uniq : 'a equal -> 'a t -> 'a t

uniq eq l returns l but removes consecutive duplicates. Lazy. In other words, if several values that are equal follow one another, only the first of them is kept.

  • since 0.3.3
val for_all : ('a -> bool) -> 'a t -> bool

for_all p [a1; ...; an] checks if all elements of the sequence satisfy the predicate p. That is, it returns (p a1) && ... && (p an) for a non-empty list and true if the sequence is empty. It consumes the sequence until it finds an element not satisfying the predicate.

  • since 3.3
val exists : ('a -> bool) -> 'a t -> bool

exists p [a1; ...; an] checks if at least one element of the sequence satisfies the predicate p. That is, it returns (p a1) || ... || (p an) for a non-empty sequence and false if the list is empty. It consumes the sequence until it finds an element satisfying the predicate.

  • since 3.3
val flat_map : ('a -> 'b t) -> 'a t -> 'b t
val filter_map : ('a -> 'b option) -> 'a t -> 'b t
val flatten : 'a t t -> 'a t
val range : int -> int -> int t
val (--) : int -> int -> int t

a -- b is the range of integers containing a and b (therefore, never empty).

val (--^) : int -> int -> int t

a -- b is the integer range from a to b, where b is excluded.

  • since 0.17

Operations on two Collections

val fold2 : ('acc -> 'a -> 'b -> 'acc) -> 'acc -> 'a t -> 'b t -> 'acc

Fold on two collections at once. Stop at soon as one of them ends.

val map2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t

Map on two collections at once. Stop as soon as one of the arguments is exhausted.

val iter2 : ('a -> 'b -> unit) -> 'a t -> 'b t -> unit

Iterate on two collections at once. Stop as soon as one of them ends.

val for_all2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool
val exists2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool
val merge : 'a ord -> 'a t -> 'a t -> 'a t

Merge two sorted iterators into a sorted iterator.

val zip : 'a t -> 'b t -> ('a * 'b) t

Combine elements pairwise. Stop as soon as one of the lists stops.

  • since 0.13
val unzip : ('a * 'b) t -> 'a t * 'b t

Split each tuple in the list.

  • since 0.13

Misc

val sort : cmp:'a ord -> 'a t -> 'a t

Eager sort. Require the iterator to be finite. O(n ln(n)) time and space.

  • since 0.3.3
val sort_uniq : cmp:'a ord -> 'a t -> 'a t

Eager sort that removes duplicate values. Require the iterator to be finite. O(n ln(n)) time and space.

  • since 0.3.3
val memoize : 'a t -> 'a t

Avoid recomputations by caching intermediate results.

  • since 0.14

Fair Combinations

val interleave : 'a t -> 'a t -> 'a t

Fair interleaving of both streams.

  • since 0.13
val fair_flat_map : ('a -> 'b t) -> 'a t -> 'b t

Fair version of flat_map.

  • since 0.13
val fair_app : ('a -> 'b) t -> 'a t -> 'b t

Fair version of (<*>).

  • since 0.13

Implementations

  • since 0.3.3
val return : 'a -> 'a t
val pure : 'a -> 'a t
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t
val (>|=) : 'a t -> ('a -> 'b) -> 'b t
val (<*>) : ('a -> 'b) t -> 'a t -> 'b t
val (>>-) : 'a t -> ('a -> 'b t) -> 'b t

Infix version of fair_flat_map.

  • since 0.13
val (<.>) : ('a -> 'b) t -> 'a t -> 'b t

Infix version of fair_app.

  • since 0.13

Infix operators

  • since 0.17
module Infix : sig ... end
module type MONAD = sig ... end
module Traverse (M : MONAD) : sig ... end

Conversions

val of_list : 'a list -> 'a t
val to_list : 'a t -> 'a list

Gather all values into a list.

val of_array : 'a array -> 'a t

Iterate on the array.

  • since 0.13
val to_array : 'a t -> 'a array

Convert into array. Iterate twice.

  • since 0.13
val to_rev_list : 'a t -> 'a list

Convert to a list, in reverse order. More efficient than to_list.

val to_iter : 'a t -> 'a iter
val to_gen : 'a t -> 'a gen
val of_gen : 'a gen -> 'a t

of_gen g consumes the generator and caches intermediate results.

  • since 0.13

IO

val pp : ?pp_start:unit printer -> ?pp_stop:unit printer -> ?pp_sep:unit printer -> 'a printer -> 'a t printer

pp ~pp_start ~pp_stop ~pp_sep pp_item ppf s formats the sequence s on ppf. Each element is formatted with pp_item, pp_start is called at the beginning, pp_stop is called at the end, pp_sep is called between each elements. By defaults pp_start and pp_stop does nothing and pp_sep defaults to (fun out -> Format.fprintf out ",@ ").

\ No newline at end of file diff --git a/dev/containers/CCSet/index.html b/dev/containers/CCSet/index.html index a6f45757..9e783edc 100644 --- a/dev/containers/CCSet/index.html +++ b/dev/containers/CCSet/index.html @@ -1,2 +1,2 @@ -CCSet (containers.CCSet)

Module CCSet

Wrapper around Set

  • since 0.9
type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

  • since 2.8
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
module type OrderedType = Stdlib.Set.OrderedType
module type S = sig ... end
module Make (O : Stdlib.Set.OrderedType) : S with type t = Stdlib.Set.Make(O).t and type elt = O.t
\ No newline at end of file +CCSet (containers.CCSet)

Module CCSet

Wrapper around Set

  • since 0.9
type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

  • since 2.8
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
module type OrderedType = Stdlib.Set.OrderedType
module type S = sig ... end
module Make (O : Stdlib.Set.OrderedType) : S with type t = Stdlib.Set.Make(O).t and type elt = O.t
\ No newline at end of file diff --git a/dev/containers/CCSexp/index.html b/dev/containers/CCSexp/index.html index 42f7da2b..2f1a15e9 100644 --- a/dev/containers/CCSexp/index.html +++ b/dev/containers/CCSexp/index.html @@ -1,2 +1,2 @@ -CCSexp (containers.CCSexp)

Module CCSexp

Handling S-expressions

  • since 3.0 moved into containers-core, previously in [containers.sexp]
type 'a or_error = ('a, string) Stdlib.result
type 'a gen = unit -> 'a option
module type SEXP = CCSexp_intf.SEXP
module type S = CCSexp_intf.S
module Make (Sexp : SEXP) : S with type t = Sexp.t and type loc = Sexp.loc

Basics

type t = [
| `Atom of string
| `List of t list
]

A simple, structural representation of S-expressions.

include S with type t := t
include CCSexp_intf.S0 with type t := t
type sexp = t

Re-exports

val atom : string -> t

Make an atom out of this string.

  • since 2.8
val list : t list -> t

Make a Sexpr of this list.

  • since 2.8

Constructors

val of_int : int -> t
val of_bool : bool -> t
val of_list : t list -> t
val of_rev_list : t list -> t

Reverse the list.

val of_float : float -> t
val of_unit : t
val of_pair : (t * t) -> t
val of_triple : (t * t * t) -> t
val of_quad : (t * t * t * t) -> t
val of_variant : string -> t list -> t

of_variant name args is used to encode algebraic variants into a S-expr. For instance of_variant "some" [of_int 1] represents the value Some 1.

val of_field : string -> t -> t

Used to represent one record field.

val of_record : (string * t) list -> t

Represent a record by its named fields.

Printing

val to_buf : Stdlib.Buffer.t -> t -> unit
val to_string : t -> string
val to_file : string -> t -> unit
val to_file_iter : string -> t CCSexp_intf.iter -> unit

Print the given iter of expressions to a file.

val to_chan : Stdlib.out_channel -> t -> unit
val pp : Stdlib.Format.formatter -> t -> unit

Pretty-printer nice on human eyes (including indentation).

val pp_noindent : Stdlib.Format.formatter -> t -> unit

Raw, direct printing as compact as possible.

Parsing

val parse_string : string -> t CCSexp_intf.or_error

Parse a string.

val parse_string_list : string -> t list CCSexp_intf.or_error

Parse a string into a list of S-exprs.

  • since 2.8
val parse_chan : Stdlib.in_channel -> t CCSexp_intf.or_error

Parse a S-expression from the given channel. Can read more data than necessary, so don't use this if you need finer-grained control (e.g. to read something else after the S-exp).

val parse_chan_gen : Stdlib.in_channel -> t CCSexp_intf.or_error CCSexp_intf.gen

Parse a channel into a generator of S-expressions.

val parse_chan_list : Stdlib.in_channel -> t list CCSexp_intf.or_error
val parse_file : string -> t CCSexp_intf.or_error

Open the file and read a S-exp from it.

val parse_file_list : string -> t list CCSexp_intf.or_error

Open the file and read a S-exp from it.

type loc

Locations for the S-expressions.

  • since 3.3

Parsing

type 'a parse_result =
| Yield of 'a
| Fail of string
| End

A parser of 'a can return Yield x when it parsed a value, or Fail e when a parse error was encountered, or End if the input was empty.

module Decoder : sig ... end
val equal : t -> t -> bool
  • since 3.0
val compare : t -> t -> int
  • since 3.0
val atom : string -> t

Build an atom directly from a string.

\ No newline at end of file +CCSexp (containers.CCSexp)

Module CCSexp

Handling S-expressions

  • since 3.0 moved into containers-core, previously in [containers.sexp]
type 'a or_error = ('a, string) Stdlib.result
type 'a gen = unit -> 'a option
module type SEXP = CCSexp_intf.SEXP
module type S = CCSexp_intf.S
module Make (Sexp : SEXP) : S with type t = Sexp.t and type loc = Sexp.loc

Basics

type t = [
| `Atom of string
| `List of t list
]

A simple, structural representation of S-expressions.

include S with type t := t
include CCSexp_intf.S0 with type t := t
type sexp = t

Re-exports

val atom : string -> t

Make an atom out of this string.

  • since 2.8
val list : t list -> t

Make a Sexpr of this list.

  • since 2.8

Constructors

val of_int : int -> t
val of_bool : bool -> t
val of_list : t list -> t
val of_rev_list : t list -> t

Reverse the list.

val of_float : float -> t
val of_unit : t
val of_pair : (t * t) -> t
val of_triple : (t * t * t) -> t
val of_quad : (t * t * t * t) -> t
val of_variant : string -> t list -> t

of_variant name args is used to encode algebraic variants into a S-expr. For instance of_variant "some" [of_int 1] represents the value Some 1.

val of_field : string -> t -> t

Used to represent one record field.

val of_record : (string * t) list -> t

Represent a record by its named fields.

Printing

val to_buf : Stdlib.Buffer.t -> t -> unit
val to_string : t -> string
val to_file : string -> t -> unit
val to_file_iter : string -> t CCSexp_intf.iter -> unit

Print the given iter of expressions to a file.

val to_chan : Stdlib.out_channel -> t -> unit
val pp : Stdlib.Format.formatter -> t -> unit

Pretty-printer nice on human eyes (including indentation).

val pp_noindent : Stdlib.Format.formatter -> t -> unit

Raw, direct printing as compact as possible.

Parsing

val parse_string : string -> t CCSexp_intf.or_error

Parse a string.

val parse_string_list : string -> t list CCSexp_intf.or_error

Parse a string into a list of S-exprs.

  • since 2.8
val parse_chan : Stdlib.in_channel -> t CCSexp_intf.or_error

Parse a S-expression from the given channel. Can read more data than necessary, so don't use this if you need finer-grained control (e.g. to read something else after the S-exp).

val parse_chan_gen : Stdlib.in_channel -> t CCSexp_intf.or_error CCSexp_intf.gen

Parse a channel into a generator of S-expressions.

val parse_chan_list : Stdlib.in_channel -> t list CCSexp_intf.or_error
val parse_file : string -> t CCSexp_intf.or_error

Open the file and read a S-exp from it.

val parse_file_list : string -> t list CCSexp_intf.or_error

Open the file and read a S-exp from it.

type loc

Locations for the S-expressions.

  • since 3.3

Parsing

type 'a parse_result =
| Yield of 'a
| Fail of string
| End

A parser of 'a can return Yield x when it parsed a value, or Fail e when a parse error was encountered, or End if the input was empty.

module Decoder : sig ... end
val equal : t -> t -> bool
  • since 3.0
val compare : t -> t -> int
  • since 3.0
val atom : string -> t

Build an atom directly from a string.

\ No newline at end of file diff --git a/dev/containers/CCString/index.html b/dev/containers/CCString/index.html index 84e0ea0f..d9d5e844 100644 --- a/dev/containers/CCString/index.html +++ b/dev/containers/CCString/index.html @@ -1,3 +1,3 @@ -CCString (containers.CCString)

Module CCString

Basic String Utils

type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

  • since 2.8
type 'a gen = unit -> 'a option
include module type of struct include Stdlib.String end
type t = string
val make : int -> char -> string
val init : int -> (int -> char) -> string
val get : string -> int -> char
val concat : string -> string list -> string
val equal : t -> t -> bool
val contains_from : string -> int -> char -> bool
val rcontains_from : string -> int -> char -> bool
val contains : string -> char -> bool
val sub : string -> int -> int -> string
val map : (char -> char) -> string -> string
val mapi : (int -> char -> char) -> string -> string
val trim : string -> string
val escaped : string -> string
val uppercase_ascii : string -> string
val lowercase_ascii : string -> string
val capitalize_ascii : string -> string
val uncapitalize_ascii : string -> string
val iteri : (int -> char -> unit) -> string -> unit
val index_from : string -> int -> char -> int
val index_from_opt : string -> int -> char -> int option
val rindex_from : string -> int -> char -> int
val rindex_from_opt : string -> int -> char -> int option
val index : string -> char -> int
val index_opt : string -> char -> int option
val rindex : string -> char -> int
val rindex_opt : string -> char -> int option
val to_seqi : t -> (int * char) Stdlib.Seq.t
val create : int -> bytes
val copy : string -> string
val fill : bytes -> int -> int -> char -> unit
val uppercase : string -> string
val lowercase : string -> string
val capitalize : string -> string
val uncapitalize : string -> string
val unsafe_get : string -> int -> char
val unsafe_set : bytes -> int -> char -> unit
val unsafe_blit : string -> int -> bytes -> int -> int -> unit
val unsafe_fill : bytes -> int -> int -> char -> unit
val length : t -> int

length s returns the length (number of characters) of the given string s.

val blit : t -> int -> Stdlib.Bytes.t -> int -> int -> unit

blit src src_pos dst dst_pos len copies len characters from string src starting at character indice src_pos, to the Bytes sequence dst starting at character indice dst_pos. Like String.blit. Compatible with the -safe-string option.

  • raises Invalid_argument

    if indices are not valid.

val fold : ('a -> char -> 'a) -> 'a -> t -> 'a

fold f init s folds on chars by increasing index. Computes f(… (f (f init s.[0]) s.[1]) …) s.[n-1].

  • since 0.7
val foldi : ('a -> int -> char -> 'a) -> 'a -> t -> 'a

foldi f init s is just like fold, but it also passes in the index of each chars as second argument to the folded function f.

  • since 3.3

Conversions

val to_gen : t -> char gen

to_gen s returns the gen of characters contained in the string s.

val to_iter : t -> char iter

to_iter s returns the iter of characters contained in the string s.

  • since 2.8
val to_seq : t -> char Stdlib.Seq.t

to_seq s returns the Seq.t of characters contained in the string s. Renamed from to std_seq since 3.0.

  • since 3.0
val to_list : t -> char list

to_list s returns the list of characters contained in the string s.

val pp_buf : Stdlib.Buffer.t -> t -> unit

pp_buf buf s prints s to the buffer buf. Renamed from pp since 2.0.

val pp : Stdlib.Format.formatter -> t -> unit

pp f s prints the string s within quotes to the formatter f. Renamed from print since 2.0.

val compare : string -> string -> int

compare s1 s2 compares the strings s1 and s2 and returns an integer that indicates their relative position in the sort order.

val is_empty : string -> bool

is_empty s returns true iff s is empty (i.e. its length is 0).

  • since 1.5
val hash : string -> int

hash s returns the hash value of s.

val rev : string -> string

rev s returns the reverse of s.

  • since 0.17
val pad : ?side:[ `Left | `Right ] -> ?c:char -> int -> string -> string

pad ~side ~c n s ensures that the string s is at least n bytes long, and pads it on the side with c if it's not the case.

  • parameter side

    determines where padding occurs (default: `Left).

  • parameter c

    the char used to pad (default: ' ').

  • since 0.17
val of_char : char -> string

of_char 'a' is "a".

  • since 0.19
val of_gen : char gen -> string

of_gen gen converts a gen of characters to a string.

val of_iter : char iter -> string

of_iter iter converts an iter of characters to a string.

  • since 2.8
val of_seq : char Stdlib.Seq.t -> string

of_seq seq converts a seq of characters to a string. Renamed from of_std_seq since 3.0.

  • since 3.0
val of_list : char list -> string

of_list lc converts a list of characters lc to a string.

val of_array : char array -> string

of_array ac converts an array of characters ac to a string.

val to_array : string -> char array

to_array s returns the array of characters contained in the string s.

val find : ?start:int -> sub:string -> string -> int

find ~start ~sub s returns the starting index of the first occurrence of sub within s or -1.

  • parameter start

    starting position in s.

val find_all : ?start:int -> sub:string -> string -> int gen

find_all ~start ~sub s finds all occurrences of sub in s, even overlapping instances and returns them in a generator gen.

  • parameter start

    starting position in s.

  • since 0.17
val find_all_l : ?start:int -> sub:string -> string -> int list

find_all_l ~sub s finds all occurrences of sub in s and returns them in a list.

  • parameter start

    starting position in s.

  • since 0.17
val mem : ?start:int -> sub:string -> string -> bool

mem ~start ~sub s is true iff sub is a substring of s.

  • since 0.12
val rfind : sub:string -> string -> int

rfind ~sub s finds sub in string s from the right, returns its first index or -1. Should only be used with very small sub.

  • since 0.12
val replace : ?which:[ `Left | `Right | `All ] -> sub:string -> by:string -> +CCString (containers.CCString)

Module CCString

Basic String Utils

type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

  • since 2.8
type 'a gen = unit -> 'a option
include module type of struct include Stdlib.String end
type t = string
val make : int -> char -> string
val init : int -> (int -> char) -> string
val get : string -> int -> char
val concat : string -> string list -> string
val equal : t -> t -> bool
val contains_from : string -> int -> char -> bool
val rcontains_from : string -> int -> char -> bool
val contains : string -> char -> bool
val sub : string -> int -> int -> string
val map : (char -> char) -> string -> string
val mapi : (int -> char -> char) -> string -> string
val trim : string -> string
val escaped : string -> string
val uppercase_ascii : string -> string
val lowercase_ascii : string -> string
val capitalize_ascii : string -> string
val uncapitalize_ascii : string -> string
val iteri : (int -> char -> unit) -> string -> unit
val index_from : string -> int -> char -> int
val index_from_opt : string -> int -> char -> int option
val rindex_from : string -> int -> char -> int
val rindex_from_opt : string -> int -> char -> int option
val index : string -> char -> int
val index_opt : string -> char -> int option
val rindex : string -> char -> int
val rindex_opt : string -> char -> int option
val to_seqi : t -> (int * char) Stdlib.Seq.t
val create : int -> bytes
val copy : string -> string
val fill : bytes -> int -> int -> char -> unit
val uppercase : string -> string
val lowercase : string -> string
val capitalize : string -> string
val uncapitalize : string -> string
val unsafe_get : string -> int -> char
val unsafe_set : bytes -> int -> char -> unit
val unsafe_blit : string -> int -> bytes -> int -> int -> unit
val unsafe_fill : bytes -> int -> int -> char -> unit
val length : t -> int

length s returns the length (number of characters) of the given string s.

val blit : t -> int -> Stdlib.Bytes.t -> int -> int -> unit

blit src src_pos dst dst_pos len copies len characters from string src starting at character indice src_pos, to the Bytes sequence dst starting at character indice dst_pos. Like String.blit. Compatible with the -safe-string option.

  • raises Invalid_argument

    if indices are not valid.

val fold : ('a -> char -> 'a) -> 'a -> t -> 'a

fold f init s folds on chars by increasing index. Computes f(… (f (f init s.[0]) s.[1]) …) s.[n-1].

  • since 0.7
val foldi : ('a -> int -> char -> 'a) -> 'a -> t -> 'a

foldi f init s is just like fold, but it also passes in the index of each chars as second argument to the folded function f.

  • since 3.3

Conversions

val to_gen : t -> char gen

to_gen s returns the gen of characters contained in the string s.

val to_iter : t -> char iter

to_iter s returns the iter of characters contained in the string s.

  • since 2.8
val to_seq : t -> char Stdlib.Seq.t

to_seq s returns the Seq.t of characters contained in the string s. Renamed from to std_seq since 3.0.

  • since 3.0
val to_list : t -> char list

to_list s returns the list of characters contained in the string s.

val pp_buf : Stdlib.Buffer.t -> t -> unit

pp_buf buf s prints s to the buffer buf. Renamed from pp since 2.0.

val pp : Stdlib.Format.formatter -> t -> unit

pp f s prints the string s within quotes to the formatter f. Renamed from print since 2.0.

val compare : string -> string -> int

compare s1 s2 compares the strings s1 and s2 and returns an integer that indicates their relative position in the sort order.

val is_empty : string -> bool

is_empty s returns true iff s is empty (i.e. its length is 0).

  • since 1.5
val hash : string -> int

hash s returns the hash value of s.

val rev : string -> string

rev s returns the reverse of s.

  • since 0.17
val pad : ?side:[ `Left | `Right ] -> ?c:char -> int -> string -> string

pad ~side ~c n s ensures that the string s is at least n bytes long, and pads it on the side with c if it's not the case.

  • parameter side

    determines where padding occurs (default: `Left).

  • parameter c

    the char used to pad (default: ' ').

  • since 0.17
val of_char : char -> string

of_char 'a' is "a".

  • since 0.19
val of_gen : char gen -> string

of_gen gen converts a gen of characters to a string.

val of_iter : char iter -> string

of_iter iter converts an iter of characters to a string.

  • since 2.8
val of_seq : char Stdlib.Seq.t -> string

of_seq seq converts a seq of characters to a string. Renamed from of_std_seq since 3.0.

  • since 3.0
val of_list : char list -> string

of_list lc converts a list of characters lc to a string.

val of_array : char array -> string

of_array ac converts an array of characters ac to a string.

val to_array : string -> char array

to_array s returns the array of characters contained in the string s.

val find : ?start:int -> sub:string -> string -> int

find ~start ~sub s returns the starting index of the first occurrence of sub within s or -1.

  • parameter start

    starting position in s.

val find_all : ?start:int -> sub:string -> string -> int gen

find_all ~start ~sub s finds all occurrences of sub in s, even overlapping instances and returns them in a generator gen.

  • parameter start

    starting position in s.

  • since 0.17
val find_all_l : ?start:int -> sub:string -> string -> int list

find_all_l ~sub s finds all occurrences of sub in s and returns them in a list.

  • parameter start

    starting position in s.

  • since 0.17
val mem : ?start:int -> sub:string -> string -> bool

mem ~start ~sub s is true iff sub is a substring of s.

  • since 0.12
val rfind : sub:string -> string -> int

rfind ~sub s finds sub in string s from the right, returns its first index or -1. Should only be used with very small sub.

  • since 0.12
val replace : ?which:[ `Left | `Right | `All ] -> sub:string -> by:string -> string -> string

replace ~which ~sub ~by s replaces some occurrences of sub by by in s.

  • parameter which

    decides whether the occurrences to replace are:

    • `Left first occurrence from the left (beginning).
    • `Right first occurrence from the right (end).
    • `All all occurrences (default).
  • raises Invalid_argument

    if sub = "".

  • since 0.14
val is_sub : sub:string -> int -> string -> int -> sub_len:int -> bool

is_sub ~sub ~sub_pos s ~pos ~sub_len returns true iff the substring of sub starting at position sub_pos and of length sub_len is a substring of s starting at position pos.

val repeat : string -> int -> string

repeat s n creates a string by repeating the string s n times.

val prefix : pre:string -> string -> bool

prefix ~pre s returns true iff pre is a prefix of s.

val suffix : suf:string -> string -> bool

suffix ~suf s returns true iff suf is a suffix of s.

  • since 0.7
val chop_prefix : pre:string -> string -> string option

chop_prefix ~pre s removes pre from s if pre really is a prefix of s, returns None otherwise.

  • since 0.17
val chop_suffix : suf:string -> string -> string option

chop_suffix ~suf s removes suf from s if suf really is a suffix of s, returns None otherwise.

  • since 0.17
val take : int -> string -> string

take n s keeps only the n first chars of s.

  • since 0.17
val drop : int -> string -> string

drop n s removes the n first chars of s.

  • since 0.17
val take_drop : int -> string -> string * string

take_drop n s is take n s, drop n s.

  • since 0.17
val lines : string -> string list

lines s returns a list of the lines of s (splits along '\n').

  • since 0.10
val lines_gen : string -> string gen

lines_gen s returns the gen of the lines of s (splits along '\n').

  • since 0.10
val lines_iter : string -> string iter

lines_iter s returns the iter of the lines of s (splits along '\n').

  • since 3.2
val lines_seq : string -> string Stdlib.Seq.t

lines_seq s returns the Seq.t of the lines of s (splits along '\n').

  • since 3.2
val concat_gen : sep:string -> string gen -> string

concat_gen ~sep gen concatenates all strings of gen, separated with sep.

  • since 0.10
val concat_seq : sep:string -> string Stdlib.Seq.t -> string

concat_seq ~sep seq concatenates all strings of seq, separated with sep.

  • since 3.2
val concat_iter : sep:string -> string iter -> string

concat_iter ~sep iter concatenates all strings of iter, separated with sep.

  • since 3.2
val unlines : string list -> string

unlines ls concatenates all strings of ls, separated with '\n'.

  • since 0.10
val unlines_gen : string gen -> string

unlines_gen gen concatenates all strings of gen, separated with '\n'.

  • since 0.10
val unlines_iter : string iter -> string

unlines_iter iter concatenates all strings of iter, separated with '\n'.

  • since 3.2
val unlines_seq : string Stdlib.Seq.t -> string

unlines_seq seq concatenates all strings of seq, separated with '\n'.

  • since 3.2
val set : string -> int -> char -> string

set s i c creates a new string which is a copy of s, except for index i, which becomes c.

  • raises Invalid_argument

    if i is an invalid index.

  • since 0.12
val iter : (char -> unit) -> string -> unit

iter f s applies function f on each character of s. Alias to String.iter.

  • since 0.12
val filter_map : (char -> char option) -> string -> string

filter_map f s calls (f a0) (f a1) … (f an) where a0 … an are the characters of s. It returns the string of characters ci such as f ai = Some ci (when f returns None, the corresponding element of s is discarded).

  • since 0.17
val filter : (char -> bool) -> string -> string

filter f s discards characters of s not satisfying f.

  • since 0.17
val uniq : (char -> char -> bool) -> string -> string

uniq eq s remove consecutive duplicate characters in s.

  • since 3.4
val flat_map : ?sep:string -> (char -> string) -> string -> string

flat_map ~sep f s maps each chars of s to a string, then concatenates them all.

  • parameter sep

    optional separator between each generated string.

  • since 0.12
val for_all : (char -> bool) -> string -> bool

for_all f s is true iff all characters of s satisfy the predicate f.

  • since 0.12
val exists : (char -> bool) -> string -> bool

exists f s is true iff some character of s satisfy the predicate f.

  • since 0.12
val drop_while : (char -> bool) -> t -> t

drop_while f s discards any characters of s starting from the left, up to the first character c not satisfying f c.

  • since 2.2
val rdrop_while : (char -> bool) -> t -> t

rdrop_while f s discards any characters of s starting from the right, up to the first character c not satisfying f c.

  • since 2.2
val ltrim : t -> t

ltrim s trims space on the left (see String.trim for more details).

  • since 1.2
val rtrim : t -> t

rtrim s trims space on the right (see String.trim for more details).

  • since 1.2

Operations on 2 strings

val map2 : (char -> char -> char) -> string -> string -> string

map2 f s1 s2 maps pairs of chars.

  • raises Invalid_argument

    if the strings have not the same length.

  • since 0.12
val iter2 : (char -> char -> unit) -> string -> string -> unit

iter2 f s1 s2 iterates on pairs of chars.

  • raises Invalid_argument

    if the strings have not the same length.

  • since 0.12
val iteri2 : (int -> char -> char -> unit) -> string -> string -> unit

iteri2 f s1 s2 iterates on pairs of chars with their index.

  • raises Invalid_argument

    if the strings have not the same length.

  • since 0.12
val fold2 : ('a -> char -> char -> 'a) -> 'a -> string -> string -> 'a

fold2 f init s1 s2 folds on pairs of chars.

  • raises Invalid_argument

    if the strings have not the same length.

  • since 0.12
val for_all2 : (char -> char -> bool) -> string -> string -> bool

for_all2 f s1 s2 returns true iff all pairs of chars satisfy the predicate f.

  • raises Invalid_argument

    if the strings have not the same length.

  • since 0.12
val exists2 : (char -> char -> bool) -> string -> string -> bool

exists2 f s1 s2 returns true iff a pair of chars satisfy the predicate f.

  • raises Invalid_argument

    if the strings have not the same length.

  • since 0.12

Ascii functions

Those functions are deprecated in String since 4.03, so we provide a stable alias for them even in older versions.

val equal_caseless : string -> string -> bool

equal_caseless s1 s2 compares s1 and s2 without respect to ascii lowercase.

  • since 1.2

Finding

A relatively efficient algorithm for finding sub-strings.

  • since 1.0
module Find : sig ... end

Splitting

module Split : sig ... end
val split_on_char : char -> string -> string list

split_on_char by s splits the string s along the given char by.

  • since 1.2
val split : by:string -> string -> string list

split ~by s splits the string s along the given string by. Alias to Split.list_cpy.

  • since 1.2

Utils

val compare_versions : string -> string -> int

compare_versions s1 s2 compares version strings s1 and s2, considering that numbers are above text.

  • since 0.13
val compare_natural : string -> string -> int

compare_natural s1 s2 is the Natural Sort Order, comparing chunks of digits as natural numbers. https://en.wikipedia.org/wiki/Natural_sort_order

  • since 1.3
val edit_distance : ?cutoff:int -> string -> string -> int

edit_distance ~cutoff s1 s2 is the edition distance between the two strings s1 and s2. This satisfies the classical distance axioms: it is always positive, symmetric, and satisfies the formula distance s1 s2 + distance s2 s3 >= distance s1 s3.

  • parameter cutoff

    if provided, it's a cap on the number of iterations. (since 3.0). This is useful if you just want to check whether the edit distance is less or equal than 2 without (use edit_distance s1 s2 ~cutoff:3 <= 2). note that contrary to what was previously documented here, the result can still be higher than cutoff if it's reached in <cutoff iterations. However if the result is < cutoff then it is accurate.

Infix operators

  • since 3.0
module Infix : sig ... end
include module type of Infix
val (=) : t -> t -> bool
  • since 3.0
val (<>) : t -> t -> bool
  • since 3.0
val (<) : t -> t -> bool
  • since 3.0
val (<=) : t -> t -> bool
  • since 3.0
val (>=) : t -> t -> bool
  • since 3.0
val (>) : t -> t -> bool
  • since 3.0
\ No newline at end of file diff --git a/dev/containers/CCStringLabels/index.html b/dev/containers/CCStringLabels/index.html index 3e42645b..a1102f1e 100644 --- a/dev/containers/CCStringLabels/index.html +++ b/dev/containers/CCStringLabels/index.html @@ -1,4 +1,4 @@ -CCStringLabels (containers.CCStringLabels)

Module CCStringLabels

Basic String Utils

type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

  • since 2.8
type 'a gen = unit -> 'a option
include module type of struct include Stdlib.StringLabels end
type t = string
val make : int -> char -> string
val init : int -> f:(int -> char) -> string
val get : string -> int -> char
val concat : sep:string -> string list -> string
val contains_from : string -> int -> char -> bool
val rcontains_from : string -> int -> char -> bool
val contains : string -> char -> bool
val sub : string -> pos:int -> len:int -> string
val map : f:(char -> char) -> string -> string
val mapi : f:(int -> char -> char) -> string -> string
val trim : string -> string
val escaped : string -> string
val iteri : f:(int -> char -> unit) -> string -> unit
val index_from : string -> int -> char -> int
val index_from_opt : string -> int -> char -> int option
val rindex_from : string -> int -> char -> int
val rindex_from_opt : string -> int -> char -> int option
val index : string -> char -> int
val index_opt : string -> char -> int option
val rindex : string -> char -> int
val rindex_opt : string -> char -> int option
val to_seqi : t -> (int * char) Stdlib.Seq.t
val create : int -> bytes
val copy : string -> string
val fill : bytes -> pos:int -> len:int -> char -> unit
val uppercase : string -> string
val lowercase : string -> string
val capitalize : string -> string
val uncapitalize : string -> string
val unsafe_get : string -> int -> char
val unsafe_set : bytes -> int -> char -> unit
val unsafe_blit : src:string -> src_pos:int -> dst:bytes -> dst_pos:int -> len:int -> +CCStringLabels (containers.CCStringLabels)

Module CCStringLabels

Basic String Utils (Labeled version of CCString)

type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

  • since 2.8
type 'a gen = unit -> 'a option
include module type of struct include Stdlib.StringLabels end
type t = string
val make : int -> char -> string
val init : int -> f:(int -> char) -> string
val get : string -> int -> char
val concat : sep:string -> string list -> string
val contains_from : string -> int -> char -> bool
val rcontains_from : string -> int -> char -> bool
val contains : string -> char -> bool
val sub : string -> pos:int -> len:int -> string
val map : f:(char -> char) -> string -> string
val mapi : f:(int -> char -> char) -> string -> string
val trim : string -> string
val escaped : string -> string
val iteri : f:(int -> char -> unit) -> string -> unit
val index_from : string -> int -> char -> int
val index_from_opt : string -> int -> char -> int option
val rindex_from : string -> int -> char -> int
val rindex_from_opt : string -> int -> char -> int option
val index : string -> char -> int
val index_opt : string -> char -> int option
val rindex : string -> char -> int
val rindex_opt : string -> char -> int option
val to_seqi : t -> (int * char) Stdlib.Seq.t
val create : int -> bytes
val copy : string -> string
val fill : bytes -> pos:int -> len:int -> char -> unit
val uppercase : string -> string
val lowercase : string -> string
val capitalize : string -> string
val uncapitalize : string -> string
val unsafe_get : string -> int -> char
val unsafe_set : bytes -> int -> char -> unit
val unsafe_blit : src:string -> src_pos:int -> dst:bytes -> dst_pos:int -> len:int -> unit
val unsafe_fill : bytes -> pos:int -> len:int -> char -> unit
val length : t -> int

length s returns the length (number of characters) of the given string s.

val blit : src:t -> src_pos:int -> dst:Stdlib.Bytes.t -> dst_pos:int -> len:int -> unit

blit ~src ~src_pos ~dst ~dst_pos ~len copies len characters from string src starting at character indice src_pos, to the Bytes sequence dst starting at character indice dst_pos. Like String.blit. Compatible with the -safe-string option.

  • raises Invalid_argument

    if indices are not valid.

val fold : f:('a -> char -> 'a) -> init:'a -> t -> 'a

fold ~f ~init s folds on chars by increasing index. Computes f(… (f (f init s.[0]) s.[1]) …) s.[n-1].

  • since 0.7
val foldi : f:('a -> int -> char -> 'a) -> 'a -> t -> 'a

foldi ~f init s is just like fold, but it also passes in the index of each chars as second argument to the folded function f.

  • since 3.3

Conversions

val to_gen : t -> char gen

to_gen s returns the gen of characters contained in the string s.

val to_iter : t -> char iter

to_iter s returns the iter of characters contained in the string s.

  • since 2.8
val to_seq : t -> char Stdlib.Seq.t

to_seq s returns the Seq.t of characters contained in the string s. Renamed from to std_seq since 3.0.

  • since 3.0
val to_list : t -> char list

to_list s returns the list of characters contained in the string s.

val pp_buf : Stdlib.Buffer.t -> t -> unit

pp_buf buf s prints s to the buffer buf. Renamed from pp since 2.0.

val pp : Stdlib.Format.formatter -> t -> unit

pp f s prints the string s within quotes to the formatter f. Renamed from print since 2.0.

Strings

val equal : string -> string -> bool

equal s1 s2 returns true iff the strings s1 and s2 are equal.

val compare : string -> string -> int

compare s1 s2 compares the strings s1 and s2 and returns an integer that indicates their relative position in the sort order.

val is_empty : string -> bool

is_empty s returns true iff s is empty (i.e. its length is 0).

  • since 1.5
val hash : string -> int

hash s returns the hash value of s.

val rev : string -> string

rev s returns the reverse of s.

  • since 0.17
val pad : ?side:[ `Left | `Right ] -> ?c:char -> int -> string -> string

pad ?side ?c n s ensures that the string s is at least n bytes long, and pads it on the side with c if it's not the case.

  • parameter side

    determines where padding occurs (default: `Left).

  • parameter c

    the char used to pad (default: ' ').

  • since 0.17
val of_char : char -> string

of_char 'a' is "a".

  • since 0.19
val of_gen : char gen -> string

of_gen gen converts a gen of characters to a string.

val of_iter : char iter -> string

of_iter iter converts an iter of characters to a string.

  • since 2.8
val of_seq : char Stdlib.Seq.t -> string

of_seq seq converts a seq of characters to a string. Renamed from of_std_seq since 3.0.

  • since 3.0
val of_list : char list -> string

of_list lc converts a list of characters lc to a string.

val of_array : char array -> string

of_array ac converts an array of characters ac to a string.

val to_array : string -> char array

to_array s returns the array of characters contained in the string s.

val find : ?start:int -> sub:string -> string -> int

find ?start ~sub s returns the starting index of the first occurrence of sub within s or -1.

  • parameter start

    starting position in s.

val find_all : ?start:int -> sub:string -> string -> int gen

find_all ?start ~sub s finds all occurrences of sub in s, even overlapping instances and returns them in a generator gen.

  • parameter start

    starting position in s.

  • since 0.17
val find_all_l : ?start:int -> sub:string -> string -> int list

find_all_l ?start ~sub s finds all occurrences of sub in s and returns them in a list.

  • parameter start

    starting position in s.

  • since 0.17
val mem : ?start:int -> sub:string -> string -> bool

mem ?start ~sub s is true iff sub is a substring of s.

  • since 0.12
val rfind : sub:string -> string -> int

rfind ~sub s finds sub in string s from the right, returns its first index or -1. Should only be used with very small sub.

  • since 0.12
val replace : ?which:[ `Left | `Right | `All ] -> sub:string -> by:string -> string -> string

replace ?which ~sub ~by s replaces some occurrences of sub by by in s.

  • parameter which

    decides whether the occurrences to replace are:

    • `Left first occurrence from the left (beginning).
    • `Right first occurrence from the right (end).
    • `All all occurrences (default).
  • raises Invalid_argument

    if sub = "".

  • since 0.14
val is_sub : sub:string -> sub_pos:int -> string -> pos:int -> sub_len:int -> bool

is_sub ~sub ~sub_pos s ~pos ~sub_len returns true iff the substring of sub starting at position sub_pos and of length sub_len is a substring of s starting at position pos.

val repeat : string -> int -> string

repeat s n creates a string by repeating the string s n times.

val prefix : pre:string -> string -> bool

prefix ~pre s returns true iff pre is a prefix of s.

val suffix : suf:string -> string -> bool

suffix ~suf s returns true iff suf is a suffix of s.

  • since 0.7
val chop_prefix : pre:string -> string -> string option

chop_prefix ~pre s removes pre from s if pre really is a prefix of s, returns None otherwise.

  • since 0.17
val chop_suffix : suf:string -> string -> string option

chop_suffix ~suf s removes suf from s if suf really is a suffix of s, returns None otherwise.

  • since 0.17
val take : int -> string -> string

take n s keeps only the n first chars of s.

  • since 0.17
val drop : int -> string -> string

drop n s removes the n first chars of s.

  • since 0.17
val take_drop : int -> string -> string * string

take_drop n s is take n s, drop n s.

  • since 0.17
val lines : string -> string list

lines s returns a list of the lines of s (splits along '\n').

  • since 0.10
val lines_gen : string -> string gen

lines_gen s returns a generator gen of the lines of s (splits along '\n').

  • since 0.10
val lines_iter : string -> string iter

lines_iter s returns the iter of the lines of s (splits along '\n').

  • since 3.2
val lines_seq : string -> string Stdlib.Seq.t

lines_seq s returns the Seq.t of the lines of s (splits along '\n').

  • since 3.2
val concat_iter : sep:string -> string iter -> string

concat_iter ~sep iter concatenates all strings of iter, separated with sep.

  • since 3.2
val concat_gen : sep:string -> string gen -> string

concat_gen ~sep gen concatenates all strings of gen, separated with sep.

  • since 0.10
val concat_seq : sep:string -> string Stdlib.Seq.t -> string

concat_seq ~sep seq concatenates all strings of seq, separated with sep.

  • since 3.2
val unlines : string list -> string

unlines ls concatenates all strings of ls, separated with '\n'.

  • since 0.10
val unlines_gen : string gen -> string

unlines_gen gen concatenates all strings of gen, separated with '\n'.

  • since 0.10
val unlines_iter : string iter -> string

unlines_iter iter concatenates all strings of iter, separated with '\n'.

  • since 3.2
val unlines_seq : string Stdlib.Seq.t -> string

unlines_seq seq concatenates all strings of seq, separated with '\n'.

  • since 3.2
val set : string -> int -> char -> string

set s i c creates a new string which is a copy of s, except for index i, which becomes c.

  • raises Invalid_argument

    if i is an invalid index.

  • since 0.12
val iter : f:(char -> unit) -> string -> unit

iter ~f s applies function f on each character of s. Alias to String.iter.

  • since 0.12
val filter_map : f:(char -> char option) -> string -> string

filter_map ~f s calls (f a0) (f a1) … (f an) where a0 … an are the characters of s. It returns the string of characters ci such as f ai = Some ci (when f returns None, the corresponding element of s is discarded).

  • since 0.17
val filter : f:(char -> bool) -> string -> string

filter ~f s discards characters of s not satisfying f.

  • since 0.17
val uniq : eq:(char -> char -> bool) -> string -> string

uniq ~eq s remove consecutive duplicate characters in s.

  • since 3.4
val flat_map : ?sep:string -> f:(char -> string) -> string -> string

flat_map ?sep ~f s maps each chars of s to a string, then concatenates them all.

  • parameter sep

    optional separator between each generated string.

  • since 0.12
val for_all : f:(char -> bool) -> string -> bool

for_all ~f s is true iff all characters of s satisfy the predicate f.

  • since 0.12
val exists : f:(char -> bool) -> string -> bool

exists ~f s is true iff some character of s satisfy the predicate f.

  • since 0.12
val drop_while : f:(char -> bool) -> t -> t

drop_while ~f s discards any characters of s starting from the left, up to the first character c not satisfying f c.

  • since 2.2
val rdrop_while : f:(char -> bool) -> t -> t

rdrop_while ~f s discards any characters of s starting from the right, up to the first character c not satisfying f c.

  • since 2.2
val ltrim : t -> t

ltrim s trims space on the left (see String.trim for more details).

  • since 1.2
val rtrim : t -> t

rtrim s trims space on the right (see String.trim for more details).

  • since 1.2

Operations on 2 strings

val map2 : f:(char -> char -> char) -> string -> string -> string

map2 ~f s1 s2 maps pairs of chars.

  • raises Invalid_argument

    if the strings have not the same length.

  • since 0.12
val iter2 : f:(char -> char -> unit) -> string -> string -> unit

iter2 ~f s1 s2 iterates on pairs of chars.

  • raises Invalid_argument

    if the strings have not the same length.

  • since 0.12
val iteri2 : f:(int -> char -> char -> unit) -> string -> string -> unit

iteri2 ~f s1 s2 iterates on pairs of chars with their index.

  • raises Invalid_argument

    if the strings have not the same length.

  • since 0.12
val fold2 : f:('a -> char -> char -> 'a) -> init:'a -> string -> string -> 'a

fold2 ~f ~init s1 s2 folds on pairs of chars.

  • raises Invalid_argument

    if the strings have not the same length.

  • since 0.12
val for_all2 : f:(char -> char -> bool) -> string -> string -> bool

for_all2 ~f s1 s2 returns true iff all pairs of chars satisfy the predicate f.

  • raises Invalid_argument

    if the strings have not the same length.

  • since 0.12
val exists2 : f:(char -> char -> bool) -> string -> string -> bool

exists2 ~f s1 s2 returns true iff a pair of chars satisfy the predicate f.

  • raises Invalid_argument

    if the strings have not the same length.

  • since 0.12

Ascii functions

Those functions are deprecated in String since 4.03, so we provide a stable alias for them even in older versions.

val capitalize_ascii : string -> string

capitalize_ascii s returns a copy of s with the first character set to uppercase using the US-ASCII character set. See String.

  • since 0.18
val uncapitalize_ascii : string -> string

uncapitalize_ascii s returns a copy of s with the first character set to lowercase using the US-ASCII character set. See String.

  • since 0.18
val uppercase_ascii : string -> string

uppercase_ascii s returns a copy of s with all lowercase letters translated to uppercase using the US-ASCII character set. See String.

  • since 0.18
val lowercase_ascii : string -> string

lowercase_ascii s returns a copy of s with all uppercase letters translated to lowercase using the US-ASCII character set. See String.

  • since 0.18
val equal_caseless : string -> string -> bool

equal_caseless s1 s2 compares s1 and s2 without respect to ascii lowercase.

  • since 1.2

Finding

A relatively efficient algorithm for finding sub-strings.

  • since 1.0
module Find : sig ... end

Splitting

module Split : sig ... end
val split_on_char : by:char -> string -> string list

split_on_char ~by s splits the string s along the given char by.

  • since 1.2
val split : by:string -> string -> string list

split ~by s splits the string s along the given string by. Alias to Split.list_cpy.

  • since 1.2

Utils

val compare_versions : string -> string -> int

compare_versions s1 s2 compares version strings s1 and s2, considering that numbers are above text.

  • since 0.13
val compare_natural : string -> string -> int

compare_natural s1 s2 is the Natural Sort Order, comparing chunks of digits as natural numbers. https://en.wikipedia.org/wiki/Natural_sort_order

  • since 1.3
val edit_distance : ?cutoff:int -> string -> string -> int

edit_distance ?cutoff s1 s2 is the edition distance between the two strings s1 and s2. This satisfies the classical distance axioms: it is always positive, symmetric, and satisfies the formula distance s1 s2 + distance s2 s3 >= distance s1 s3.

  • parameter cutoff

    if provided, it's a cap on both the number of iterations, and on the result. (since 3.0). This is useful if you just want to check whether the edit distance is less or equal than 2 (use cutoff of 3).

Infix operators

  • since 3.0
module Infix : sig ... end
include module type of Infix
val (=) : t -> t -> bool
  • since 3.0
val (<>) : t -> t -> bool
  • since 3.0
val (<) : t -> t -> bool
  • since 3.0
val (<=) : t -> t -> bool
  • since 3.0
val (>=) : t -> t -> bool
  • since 3.0
val (>) : t -> t -> bool
  • since 3.0
\ No newline at end of file diff --git a/dev/containers/CCUtf8_string/index.html b/dev/containers/CCUtf8_string/index.html index 4f24e988..5697c0e9 100644 --- a/dev/containers/CCUtf8_string/index.html +++ b/dev/containers/CCUtf8_string/index.html @@ -1,2 +1,2 @@ -CCUtf8_string (containers.CCUtf8_string)

Module CCUtf8_string

Unicode String, in UTF8

A unicode string represented by a utf8 bytestring. This representation is convenient for manipulating normal OCaml strings that are encoded in UTF8.

We perform only basic decoding and encoding between codepoints and bytestrings. For more elaborate operations, please use the excellent Uutf.

status: experimental

  • since 2.1
type uchar = Stdlib.Uchar.t
type 'a gen = unit -> 'a option
type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

  • since 2.8
type t = private string

A UTF8 string

val equal : t -> t -> bool
val hash : t -> int
val compare : t -> t -> int
val pp : Stdlib.Format.formatter -> t -> unit
val to_string : t -> string

Identity.

exception Malformed of string * int

Malformed string at given offset

val to_gen : ?idx:int -> t -> uchar gen

Generator of unicode codepoints.

  • parameter idx

    offset where to start the decoding.

val to_iter : ?idx:int -> t -> uchar iter

Iterator of unicode codepoints.

  • parameter idx

    offset where to start the decoding.

  • since 2.8
val to_seq : ?idx:int -> t -> uchar Stdlib.Seq.t

Iter of unicode codepoints. Renamed from to_std_seq since 3.0.

  • parameter idx

    offset where to start the decoding.

  • since 3.0
val to_list : ?idx:int -> t -> uchar list

List of unicode codepoints.

  • parameter idx

    offset where to start the decoding.

val fold : ?idx:int -> ('a -> uchar -> 'a) -> 'a -> t -> 'a
val iter : ?idx:int -> (uchar -> unit) -> t -> unit
val n_chars : t -> int

Number of characters.

val n_bytes : t -> int

Number of bytes.

val map : (uchar -> uchar) -> t -> t
val filter_map : (uchar -> uchar option) -> t -> t
val flat_map : (uchar -> t) -> t -> t
val empty : t

Empty string.

  • since 3.5
val append : t -> t -> t

Append two string together.

val concat : t -> t list -> t

concat sep l concatenates each string in l, inserting sep in between each string. Similar to String.concat.

val of_uchar : uchar -> t

of_char c is a string with only one unicode char in it.

  • since 3.5
val make : int -> uchar -> t

make n c makes a new string with n copies of c in it.

  • since 3.5
val of_seq : uchar Stdlib.Seq.t -> t

Build a string from unicode codepoints Renamed from of_std_seq since 3.0.

  • since 3.0
val of_iter : uchar iter -> t

Build a string from unicode codepoints

  • since 2.8
val uchar_to_bytes : uchar -> char iter

Translate the unicode codepoint to a list of utf-8 bytes. This can be used, for example, in combination with Buffer.add_char on a pre-allocated buffer to add the bytes one by one (despite its name, Buffer.add_char takes individual bytes, not unicode codepoints).

  • since 3.2
val of_gen : uchar gen -> t
val of_list : uchar list -> t
val of_string_exn : string -> t

Validate string by checking it is valid UTF8.

  • raises Invalid_argument

    if the string is not valid UTF8.

val of_string : string -> t option

Safe version of of_string_exn.

val is_valid : string -> bool

Valid UTF8?

val unsafe_of_string : string -> t

Conversion from a string without validating. CAUTION this is unsafe and can break all the other functions in this module. Use only if you're sure the string is valid UTF8. Upon iteration, if an invalid substring is met, Malformed will be raised.

\ No newline at end of file +CCUtf8_string (containers.CCUtf8_string)

Module CCUtf8_string

Unicode String, in UTF8

A unicode string represented by a utf8 bytestring. This representation is convenient for manipulating normal OCaml strings that are encoded in UTF8.

We perform only basic decoding and encoding between codepoints and bytestrings. For more elaborate operations, please use the excellent Uutf.

status: experimental

  • since 2.1
type uchar = Stdlib.Uchar.t
type 'a gen = unit -> 'a option
type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

  • since 2.8
type t = private string

A UTF8 string

val equal : t -> t -> bool
val hash : t -> int
val compare : t -> t -> int
val pp : Stdlib.Format.formatter -> t -> unit
val to_string : t -> string

Identity.

exception Malformed of string * int

Malformed string at given offset

val to_gen : ?idx:int -> t -> uchar gen

Generator of unicode codepoints.

  • parameter idx

    offset where to start the decoding.

val to_iter : ?idx:int -> t -> uchar iter

Iterator of unicode codepoints.

  • parameter idx

    offset where to start the decoding.

  • since 2.8
val to_seq : ?idx:int -> t -> uchar Stdlib.Seq.t

Iter of unicode codepoints. Renamed from to_std_seq since 3.0.

  • parameter idx

    offset where to start the decoding.

  • since 3.0
val to_list : ?idx:int -> t -> uchar list

List of unicode codepoints.

  • parameter idx

    offset where to start the decoding.

val fold : ?idx:int -> ('a -> uchar -> 'a) -> 'a -> t -> 'a
val iter : ?idx:int -> (uchar -> unit) -> t -> unit
val n_chars : t -> int

Number of characters.

val n_bytes : t -> int

Number of bytes.

val map : (uchar -> uchar) -> t -> t
val filter_map : (uchar -> uchar option) -> t -> t
val flat_map : (uchar -> t) -> t -> t
val empty : t

Empty string.

  • since 3.5
val append : t -> t -> t

Append two string together.

val concat : t -> t list -> t

concat sep l concatenates each string in l, inserting sep in between each string. Similar to String.concat.

val of_uchar : uchar -> t

of_char c is a string with only one unicode char in it.

  • since 3.5
val make : int -> uchar -> t

make n c makes a new string with n copies of c in it.

  • since 3.5
val of_seq : uchar Stdlib.Seq.t -> t

Build a string from unicode codepoints Renamed from of_std_seq since 3.0.

  • since 3.0
val of_iter : uchar iter -> t

Build a string from unicode codepoints

  • since 2.8
val uchar_to_bytes : uchar -> char iter

Translate the unicode codepoint to a list of utf-8 bytes. This can be used, for example, in combination with Buffer.add_char on a pre-allocated buffer to add the bytes one by one (despite its name, Buffer.add_char takes individual bytes, not unicode codepoints).

  • since 3.2
val of_gen : uchar gen -> t
val of_list : uchar list -> t
val of_string_exn : string -> t

Validate string by checking it is valid UTF8.

  • raises Invalid_argument

    if the string is not valid UTF8.

val of_string : string -> t option

Safe version of of_string_exn.

val is_valid : string -> bool

Valid UTF8?

val unsafe_of_string : string -> t

Conversion from a string without validating. CAUTION this is unsafe and can break all the other functions in this module. Use only if you're sure the string is valid UTF8. Upon iteration, if an invalid substring is met, Malformed will be raised.

\ No newline at end of file diff --git a/dev/containers/CCVector/index.html b/dev/containers/CCVector/index.html index 92d5b6c2..30c4cf7e 100644 --- a/dev/containers/CCVector/index.html +++ b/dev/containers/CCVector/index.html @@ -1,3 +1,3 @@ -CCVector (containers.CCVector)

Module CCVector

Growable, mutable vector

type ro = [
| `RO
]
type rw = [
| `RW
]

Mutability is rw (read-write) or ro (read-only).

type ('a, 'mut) t

The type of a vector of elements of type 'a, with a mutability flat 'mut.

type 'a vector = ('arw) t

Type synonym: a 'a vector is mutable.

type 'a ro_vector = ('aro) t

Alias for immutable vectors.

  • since 0.15
type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

  • since 2.8
type 'a gen = unit -> 'a option
type 'a equal = 'a -> 'a -> bool
type 'a ord = 'a -> 'a -> int
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
val freeze : ('a_) t -> ('aro) t

Make an immutable vector (no copy! Don't use the old version).

val freeze_copy : ('a_) t -> ('aro) t

Copy the vector into an immutable version.

val create : unit -> ('arw) t

Create a new, empty vector.

val create_with : ?capacity:int -> 'a -> ('arw) t

Create a new vector, the value is used to enforce the type the new vector.

  • parameter capacity

    the size of the underlying array.

val return : 'a -> ('a'mut) t

Singleton vector.

  • since 0.14
val make : int -> 'a -> ('a'mut) t

make n x makes a vector of size n, filled with x.

val init : int -> (int -> 'a) -> ('a'mut) t

Init the vector with the given function and size.

val clear : ('arw) t -> unit

Clear the content of the vector. This ensures that length v = 0 but the underlying array is kept, and possibly references to former elements, which are therefore not garbage collectible.

val clear_and_reset : ('arw) t -> unit

Clear the content of the vector, and deallocate the underlying array, removing references to all the elements. The elements can be collected.

  • since 2.8
val ensure_with : init:'a -> ('arw) t -> int -> unit

Hint to the vector that it should have at least the given capacity. This does not affect length v.

  • parameter init

    if capacity v = 0, used to enforce the type of the vector (see create_with).

  • raises Invalid_arg

    if the size is not suitable (negative, or too big for OCaml arrays)

  • since 0.14
val ensure : ('arw) t -> int -> unit

Hint to the vector that it should have at least the given capacity. Just a hint, will not be enforced if the vector is empty and init is not provided.

  • raises Invalid_arg

    if the size is not suitable (negative, or too big for OCaml arrays)

val is_empty : ('a_) t -> bool

Is the vector empty?

val push : ('arw) t -> 'a -> unit

Add an element at the end of the vector.

val resize_with : ('arw) t -> (int -> 'a) -> int -> unit

resize_with vec f size resizes vector vec up to size, fills vector with calls to f on indexes [vec.size-1.. size - 1]. The contents and size of vec are untouched if size is inferior or equal to length vec.

  • raises Invalid_argument

    if the size is too big

  • since NEXT_RELEASE
val resize_with_init : ('arw) t -> init:'a -> int -> unit

resize_with_init vec init size resizes vector vec up to size, fills vector with calls to init on indexes [length vec -1.. size - 1]. The contents and size of vec are untouched if size is inferior or equal to length vec.

  • raises Invalid_argument

    if the size is too big

  • since NEXT_RELEASE
val append : ('arw) t -> ('a_) t -> unit

append a b adds all elements of b to a.

val append_array : ('arw) t -> 'a array -> unit

Like append, with an array.

val append_iter : ('arw) t -> 'a iter -> unit

Append content of iterator.

  • since 2.8
val append_seq : ('arw) t -> 'a Stdlib.Seq.t -> unit

Append content of iterator. Renamed from append_std_seq since 3.0.

  • since 3.0
val append_list : ('arw) t -> 'a list -> unit

Append content of list.

  • since 0.14
val append_gen : ('arw) t -> 'a gen -> unit

Append content of generator.

  • since 0.20
val equal : 'a equal -> ('a_) t equal
val compare : 'a ord -> ('a_) t ord

Total ordering on vectors. Lexicographic comparison.

exception Empty

Raised on empty stack.

val pop : ('arw) t -> 'a option

Remove last element, or None.

val pop_exn : ('arw) t -> 'a

Remove last element, or raise an exception if empty.

  • raises Empty

    on an empty vector.

val top : ('a_) t -> 'a option

Top element, if present.

  • since 0.6
val top_exn : ('a_) t -> 'a

Top element, if present.

  • raises Empty

    on an empty vector.

  • since 0.6
val copy : ('a_) t -> ('a'mut) t

Shallow copy (may give an immutable or mutable vector).

val truncate : ('arw) t -> int -> unit

Truncate to the given size (remove elements above this size). Does nothing if the parameter is bigger than the current size. truncate was called shrink.

  • since 3.0
val shrink_to_fit : ('a_) t -> unit

Shrink internal array to fit the size of the vector

  • since 2.8
val member : eq:('a -> 'a -> bool) -> 'a -> ('a_) t -> bool

Is the element a member of the vector?

val sort : ('a -> 'a -> int) -> ('a_) t -> ('a'mut) t

Sort the vector, returning a copy of it that is sorted w.r.t the given ordering. The vector itself is unchanged. The underlying array of the new vector can be smaller than the original one.

val sort' : ('a -> 'a -> int) -> ('arw) t -> unit

Sort the vector in place (modifying it). This function change the size of the underlying array.

val uniq_sort : ('a -> 'a -> int) -> ('arw) t -> unit

Sort the array and remove duplicates, in place (e.g. modifying the vector itself).

val iter : ('a -> unit) -> ('a_) t -> unit

Iterate on the vector's content.

val iteri : (int -> 'a -> unit) -> ('a_) t -> unit

Iterate on the vector, with indexes.

val map : ('a -> 'b) -> ('a_) t -> ('b'mut) t

Map elements of the vector, yielding a new vector.

val mapi : (int -> 'a -> 'b) -> ('a_) t -> ('b'mut) t

map f v is just like map, but it also passes in the index of each element as the first argument to the function f.

  • since 2.8
val map_in_place : ('a -> 'a) -> ('a_) t -> unit

Map elements of the vector in place

  • since 2.3
val filter : ('a -> bool) -> ('a_) t -> ('a'mut) t

Filter elements from the vector. filter p v leaves v unchanged but returns a new vector that only contains elements of v satisfying p.

val filter_in_place : ('a -> bool) -> ('arw) t -> unit

Filter elements from the vector in place.

  • since 3.0
val fold : ('b -> 'a -> 'b) -> 'b -> ('a_) t -> 'b

Fold on elements of the vector

val exists : ('a -> bool) -> ('a_) t -> bool

Existential test (is there an element that satisfies the predicate?).

val for_all : ('a -> bool) -> ('a_) t -> bool

Universal test (do all the elements satisfy the predicate?).

val find : ('a -> bool) -> ('a_) t -> 'a option

Find an element that satisfies the predicate.

val find_exn : ('a -> bool) -> ('a_) t -> 'a

Find an element that satisfies the predicate, or

  • raises Not_found

    if no element does.

val find_map : ('a -> 'b option) -> ('a_) t -> 'b option

find_map f v returns the first Some y = f x for x in v, or None if f x = None for each x in v.

  • since 0.14
val filter_map : ('a -> 'b option) -> ('a_) t -> ('b'mut) t

Map elements with a function, possibly filtering some of them out.

val filter_map_in_place : ('a -> 'a option) -> ('a_) t -> unit

Filter-map elements of the vector in place

  • since 2.3
val flat_map : ('a -> ('b_) t) -> ('a_) t -> ('b'mut) t

Map each element to a sub-vector.

val flat_map_seq : ('a -> 'b Stdlib.Seq.t) -> ('a_) t -> ('b'mut) t

Like flat_map, but using Seq for intermediate collections. Renamed from flat_map_std_seq since 3.0.

  • since 3.0
val flat_map_list : ('a -> 'b list) -> ('a_) t -> ('b'mut) t

Like flat_map, but using list for intermediate collections.

  • since 0.14
val monoid_product : ('a -> 'b -> 'c) -> ('a_) t -> ('b_) t -> ('c_) t

All combinaisons of tuples from the two vectors are passed to the function.

  • since 2.8
val (>>=) : ('a_) t -> ('a -> ('b_) t) -> ('b'mut) t

Infix version of flat_map.

val (>|=) : ('a_) t -> ('a -> 'b) -> ('b'mut) t

Infix version of map.

val get : ('a_) t -> int -> 'a

Access element by its index, or

  • raises Invalid_argument

    if bad index.

val set : ('arw) t -> int -> 'a -> unit

Modify element at given index, or

  • raises Invalid_argument

    if the index is invalid (i.e. not in [0.. length v-1]).

val remove_and_shift : ('arw) t -> int -> unit

remove_and_shift v i remove the i-th element from v. Move elements that are after the i-th in v, in linear time. Preserve the order of the elements in v. See remove_unordered for constant time removal function that doesn't preserve the order of elements.

  • since 3.0
val remove_unordered : ('arw) t -> int -> unit

remove_unordered v i remove the i-th element from v. Does NOT preserve the order of the elements in v (might swap with the last element). See remove_and_shift if you want to keep the ordering.

val rev : ('a_) t -> ('a'mut) t

Reverse the vector.

val rev_in_place : ('arw) t -> unit

Reverse the vector in place.

  • since 0.14
val rev_iter : ('a -> unit) -> ('a_) t -> unit

rev_iter f a is the same as iter f (rev a), only more efficient.

  • since 0.14
val size : ('a_) t -> int

Number of elements in the vector.

val length : (__) t -> int

Synonym for size.

val capacity : (__) t -> int

Number of elements the vector can contain without being resized.

val unsafe_get_array : ('arw) t -> 'a array

Access the underlying shared array (do not modify!). unsafe_get_array v is longer than size v, but elements at higher index than size v are undefined (do not access!).

val (--) : int -> int -> (int, 'mut) t

Range of integers, either ascending or descending (both included, therefore the result is never empty). Example: 1 -- 10 returns the vector [1;2;3;4;5;6;7;8;9;10].

val (--^) : int -> int -> (int, 'mut) t

Range of integers, either ascending or descending, but excluding right. Example: 1 --^ 10 returns the vector [1;2;3;4;5;6;7;8;9].

  • since 0.17
val of_array : 'a array -> ('a'mut) t

of_array a returns a vector corresponding to the array a. Operates in O(n) time.

val of_list : 'a list -> ('a'mut) t
val to_array : ('a_) t -> 'a array

to_array v returns an array corresponding to the vector v.

val to_list : ('a_) t -> 'a list

Return a list with the elements contained in the vector.

val of_iter : ?init:('arw) t -> 'a iter -> ('arw) t

Convert an Iterator to a vector.

  • since 2.8.1
val of_seq : ?init:('arw) t -> 'a Stdlib.Seq.t -> ('arw) t

Convert an Iterator to a vector. Renamed from of_std_seq since 3.0.

  • since 3.0
val to_iter : ('a_) t -> 'a iter

Return a iter with the elements contained in the vector.

  • since 2.8
val to_iter_rev : ('a_) t -> 'a iter

to_iter_rev v returns the sequence of elements of v in reverse order, that is, the last elements of v are iterated on first.

  • since 2.8
val to_seq : ('a_) t -> 'a Stdlib.Seq.t

Return an iterator with the elements contained in the vector. Renamed from to_std_seq since 3.0.

  • since 3.0
val to_seq_rev : ('a_) t -> 'a Stdlib.Seq.t

to_seq v returns the sequence of elements of v in reverse order, that is, the last elements of v are iterated on first. Renamed from to_std_seq since 3.0.

  • since 3.0
val slice : ('arw) t -> 'a array * int * int

Vector as an array slice. By doing it we expose the internal array, so be careful!.

val slice_iter : ('a_) t -> int -> int -> 'a iter

slice_iter v start len is the sequence of elements from v.(start) to v.(start+len-1).

  • since 3.0
val of_gen : ?init:('arw) t -> 'a gen -> ('arw) t
val to_gen : ('a_) t -> 'a gen
val to_string : ?start:string -> ?stop:string -> ?sep:string -> +CCVector (containers.CCVector)

Module CCVector

Growable, mutable vector

type ro = [
| `RO
]
type rw = [
| `RW
]

Mutability is rw (read-write) or ro (read-only).

type ('a, 'mut) t

The type of a vector of elements of type 'a, with a mutability flat 'mut.

type 'a vector = ('arw) t

Type synonym: a 'a vector is mutable.

type 'a ro_vector = ('aro) t

Alias for immutable vectors.

  • since 0.15
type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

  • since 2.8
type 'a gen = unit -> 'a option
type 'a equal = 'a -> 'a -> bool
type 'a ord = 'a -> 'a -> int
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
val freeze : ('a_) t -> ('aro) t

Make an immutable vector (no copy! Don't use the old version).

val freeze_copy : ('a_) t -> ('aro) t

Copy the vector into an immutable version.

val create : unit -> ('arw) t

Create a new, empty vector.

val create_with : ?capacity:int -> 'a -> ('arw) t

Create a new vector, the value is used to enforce the type the new vector.

  • parameter capacity

    the size of the underlying array.

val return : 'a -> ('a'mut) t

Singleton vector.

  • since 0.14
val make : int -> 'a -> ('a'mut) t

make n x makes a vector of size n, filled with x.

val init : int -> (int -> 'a) -> ('a'mut) t

Init the vector with the given function and size.

val clear : ('arw) t -> unit

Clear the content of the vector. This ensures that length v = 0 but the underlying array is kept, and possibly references to former elements, which are therefore not garbage collectible.

val clear_and_reset : ('arw) t -> unit

Clear the content of the vector, and deallocate the underlying array, removing references to all the elements. The elements can be collected.

  • since 2.8
val ensure_with : init:'a -> ('arw) t -> int -> unit

Hint to the vector that it should have at least the given capacity. This does not affect length v.

  • parameter init

    if capacity v = 0, used to enforce the type of the vector (see create_with).

  • raises Invalid_arg

    if the size is not suitable (negative, or too big for OCaml arrays)

  • since 0.14
val ensure : ('arw) t -> int -> unit

Hint to the vector that it should have at least the given capacity. Just a hint, will not be enforced if the vector is empty and init is not provided.

  • raises Invalid_arg

    if the size is not suitable (negative, or too big for OCaml arrays)

val is_empty : ('a_) t -> bool

Is the vector empty?

val push : ('arw) t -> 'a -> unit

Add an element at the end of the vector.

val resize_with : ('arw) t -> (int -> 'a) -> int -> unit

resize_with vec f size resizes vector vec up to size, fills vector with calls to f on indexes [vec.size-1.. size - 1]. The contents and size of vec are untouched if size is inferior or equal to length vec.

  • raises Invalid_argument

    if the size is too big

  • since NEXT_RELEASE
val resize_with_init : ('arw) t -> init:'a -> int -> unit

resize_with_init vec init size resizes vector vec up to size, fills vector with calls to init on indexes [length vec -1.. size - 1]. The contents and size of vec are untouched if size is inferior or equal to length vec.

  • raises Invalid_argument

    if the size is too big

  • since NEXT_RELEASE
val append : ('arw) t -> ('a_) t -> unit

append a b adds all elements of b to a.

val append_array : ('arw) t -> 'a array -> unit

Like append, with an array.

val append_iter : ('arw) t -> 'a iter -> unit

Append content of iterator.

  • since 2.8
val append_seq : ('arw) t -> 'a Stdlib.Seq.t -> unit

Append content of iterator. Renamed from append_std_seq since 3.0.

  • since 3.0
val append_list : ('arw) t -> 'a list -> unit

Append content of list.

  • since 0.14
val append_gen : ('arw) t -> 'a gen -> unit

Append content of generator.

  • since 0.20
val equal : 'a equal -> ('a_) t equal
val compare : 'a ord -> ('a_) t ord

Total ordering on vectors. Lexicographic comparison.

exception Empty

Raised on empty stack.

val pop : ('arw) t -> 'a option

Remove last element, or None.

val pop_exn : ('arw) t -> 'a

Remove last element, or raise an exception if empty.

  • raises Empty

    on an empty vector.

val top : ('a_) t -> 'a option

Top element, if present.

  • since 0.6
val top_exn : ('a_) t -> 'a

Top element, if present.

  • raises Empty

    on an empty vector.

  • since 0.6
val copy : ('a_) t -> ('a'mut) t

Shallow copy (may give an immutable or mutable vector).

val truncate : ('arw) t -> int -> unit

Truncate to the given size (remove elements above this size). Does nothing if the parameter is bigger than the current size. truncate was called shrink.

  • since 3.0
val shrink_to_fit : ('a_) t -> unit

Shrink internal array to fit the size of the vector

  • since 2.8
val member : eq:('a -> 'a -> bool) -> 'a -> ('a_) t -> bool

Is the element a member of the vector?

val sort : ('a -> 'a -> int) -> ('a_) t -> ('a'mut) t

Sort the vector, returning a copy of it that is sorted w.r.t the given ordering. The vector itself is unchanged. The underlying array of the new vector can be smaller than the original one.

val sort' : ('a -> 'a -> int) -> ('arw) t -> unit

Sort the vector in place (modifying it). This function change the size of the underlying array.

val uniq_sort : ('a -> 'a -> int) -> ('arw) t -> unit

Sort the array and remove duplicates, in place (e.g. modifying the vector itself).

val iter : ('a -> unit) -> ('a_) t -> unit

Iterate on the vector's content.

val iteri : (int -> 'a -> unit) -> ('a_) t -> unit

Iterate on the vector, with indexes.

val map : ('a -> 'b) -> ('a_) t -> ('b'mut) t

Map elements of the vector, yielding a new vector.

val mapi : (int -> 'a -> 'b) -> ('a_) t -> ('b'mut) t

map f v is just like map, but it also passes in the index of each element as the first argument to the function f.

  • since 2.8
val map_in_place : ('a -> 'a) -> ('a_) t -> unit

Map elements of the vector in place

  • since 2.3
val filter : ('a -> bool) -> ('a_) t -> ('a'mut) t

Filter elements from the vector. filter p v leaves v unchanged but returns a new vector that only contains elements of v satisfying p.

val filter_in_place : ('a -> bool) -> ('arw) t -> unit

Filter elements from the vector in place.

  • since 3.0
val fold : ('b -> 'a -> 'b) -> 'b -> ('a_) t -> 'b

Fold on elements of the vector

val exists : ('a -> bool) -> ('a_) t -> bool

Existential test (is there an element that satisfies the predicate?).

val for_all : ('a -> bool) -> ('a_) t -> bool

Universal test (do all the elements satisfy the predicate?).

val find : ('a -> bool) -> ('a_) t -> 'a option

Find an element that satisfies the predicate.

val find_exn : ('a -> bool) -> ('a_) t -> 'a

Find an element that satisfies the predicate, or

  • raises Not_found

    if no element does.

val find_map : ('a -> 'b option) -> ('a_) t -> 'b option

find_map f v returns the first Some y = f x for x in v, or None if f x = None for each x in v.

  • since 0.14
val filter_map : ('a -> 'b option) -> ('a_) t -> ('b'mut) t

Map elements with a function, possibly filtering some of them out.

val filter_map_in_place : ('a -> 'a option) -> ('a_) t -> unit

Filter-map elements of the vector in place

  • since 2.3
val flat_map : ('a -> ('b_) t) -> ('a_) t -> ('b'mut) t

Map each element to a sub-vector.

val flat_map_seq : ('a -> 'b Stdlib.Seq.t) -> ('a_) t -> ('b'mut) t

Like flat_map, but using Seq for intermediate collections. Renamed from flat_map_std_seq since 3.0.

  • since 3.0
val flat_map_list : ('a -> 'b list) -> ('a_) t -> ('b'mut) t

Like flat_map, but using list for intermediate collections.

  • since 0.14
val monoid_product : ('a -> 'b -> 'c) -> ('a_) t -> ('b_) t -> ('c_) t

All combinaisons of tuples from the two vectors are passed to the function.

  • since 2.8
val (>>=) : ('a_) t -> ('a -> ('b_) t) -> ('b'mut) t

Infix version of flat_map.

val (>|=) : ('a_) t -> ('a -> 'b) -> ('b'mut) t

Infix version of map.

val get : ('a_) t -> int -> 'a

Access element by its index, or

  • raises Invalid_argument

    if bad index.

val set : ('arw) t -> int -> 'a -> unit

Modify element at given index, or

  • raises Invalid_argument

    if the index is invalid (i.e. not in [0.. length v-1]).

val remove_and_shift : ('arw) t -> int -> unit

remove_and_shift v i remove the i-th element from v. Move elements that are after the i-th in v, in linear time. Preserve the order of the elements in v. See remove_unordered for constant time removal function that doesn't preserve the order of elements.

  • since 3.0
val remove_unordered : ('arw) t -> int -> unit

remove_unordered v i remove the i-th element from v. Does NOT preserve the order of the elements in v (might swap with the last element). See remove_and_shift if you want to keep the ordering.

val rev : ('a_) t -> ('a'mut) t

Reverse the vector.

val rev_in_place : ('arw) t -> unit

Reverse the vector in place.

  • since 0.14
val rev_iter : ('a -> unit) -> ('a_) t -> unit

rev_iter f a is the same as iter f (rev a), only more efficient.

  • since 0.14
val size : ('a_) t -> int

Number of elements in the vector.

val length : (__) t -> int

Synonym for size.

val capacity : (__) t -> int

Number of elements the vector can contain without being resized.

val unsafe_get_array : ('arw) t -> 'a array

Access the underlying shared array (do not modify!). unsafe_get_array v is longer than size v, but elements at higher index than size v are undefined (do not access!).

val (--) : int -> int -> (int, 'mut) t

Range of integers, either ascending or descending (both included, therefore the result is never empty). Example: 1 -- 10 returns the vector [1;2;3;4;5;6;7;8;9;10].

val (--^) : int -> int -> (int, 'mut) t

Range of integers, either ascending or descending, but excluding right. Example: 1 --^ 10 returns the vector [1;2;3;4;5;6;7;8;9].

  • since 0.17
val of_array : 'a array -> ('a'mut) t

of_array a returns a vector corresponding to the array a. Operates in O(n) time.

val of_list : 'a list -> ('a'mut) t
val to_array : ('a_) t -> 'a array

to_array v returns an array corresponding to the vector v.

val to_list : ('a_) t -> 'a list

Return a list with the elements contained in the vector.

val of_iter : ?init:('arw) t -> 'a iter -> ('arw) t

Convert an Iterator to a vector.

  • since 2.8.1
val of_seq : ?init:('arw) t -> 'a Stdlib.Seq.t -> ('arw) t

Convert an Iterator to a vector. Renamed from of_std_seq since 3.0.

  • since 3.0
val to_iter : ('a_) t -> 'a iter

Return a iter with the elements contained in the vector.

  • since 2.8
val to_iter_rev : ('a_) t -> 'a iter

to_iter_rev v returns the sequence of elements of v in reverse order, that is, the last elements of v are iterated on first.

  • since 2.8
val to_seq : ('a_) t -> 'a Stdlib.Seq.t

Return an iterator with the elements contained in the vector. Renamed from to_std_seq since 3.0.

  • since 3.0
val to_seq_rev : ('a_) t -> 'a Stdlib.Seq.t

to_seq v returns the sequence of elements of v in reverse order, that is, the last elements of v are iterated on first. Renamed from to_std_seq since 3.0.

  • since 3.0
val slice : ('arw) t -> 'a array * int * int

Vector as an array slice. By doing it we expose the internal array, so be careful!.

val slice_iter : ('a_) t -> int -> int -> 'a iter

slice_iter v start len is the sequence of elements from v.(start) to v.(start+len-1).

  • since 3.0
val of_gen : ?init:('arw) t -> 'a gen -> ('arw) t
val to_gen : ('a_) t -> 'a gen
val to_string : ?start:string -> ?stop:string -> ?sep:string -> ('a -> string) -> ('a_) t -> string

Print the vector in a string

  • since 2.7
val pp : ?pp_start:unit printer -> ?pp_stop:unit printer -> ?pp_sep:unit printer -> 'a printer -> ('a_) t printer

pp ~pp_start ~pp_stop ~pp_sep pp_item ppf v formats the vector v on ppf. Each element is formatted with pp_item, pp_start is called at the beginning, pp_stop is called at the end, pp_sep is called between each elements. By defaults pp_start and pp_stop does nothing and pp_sep defaults to (fun out -> Format.fprintf out ",@ ").

Let operators on OCaml >= 4.08.0, nothing otherwise

  • since 2.8
include CCShimsMkLet_.S2 with type ('a, 'e) t_let2 := ('a'e) t
val let+ : ('a'e) t -> ('a -> 'b) -> ('b'e) t
val and+ : ('a'e) t -> ('b'e) t -> ('a * 'b'e) t
val let* : ('a'e) t -> ('a -> ('b'e) t) -> ('b'e) t
val and* : ('a'e) t -> ('b'e) t -> ('a * 'b'e) t
\ No newline at end of file diff --git a/dev/containers/Containers/index.html b/dev/containers/Containers/index.html index f7e91647..a885b428 100644 --- a/dev/containers/Containers/index.html +++ b/dev/containers/Containers/index.html @@ -1,2 +1,2 @@ -Containers (containers.Containers)

Module Containers

Drop-In replacement to Stdlib

module Array = CCArray
module Bool = CCBool
module Char = CCChar
module Equal = CCEqual
module Either = CCEither
module Float = CCFloat
module Format = CCFormat
module Fun = CCFun
module Hash = CCHash
module Hashtbl : sig ... end
module Heap = CCHeap
module Int = CCInt
module Int32 = CCInt32
module Int64 = CCInt64
module IO = CCIO
module List = CCList
module Map = CCMap
module Nativeint = CCNativeint
module Option = CCOption
module Ord = CCOrd
module Pair = CCPair
module Parse = CCParse
module Random = CCRandom
module Ref = CCRef
module Result = CCResult
module Seq = CCSeq
module Set = CCSet
module String = CCString
module Vector = CCVector
module Monomorphic = CCMonomorphic
module Utf8_string = CCUtf8_string
module Sexp = CCSexp
module Sexp_intf = CCSexp_intf
module Canonical_sexp = CCCanonical_sexp
module Stdlib = CCShims_.Stdlib
include module type of struct include Monomorphic end
  • since 2.0
val (=) : int -> int -> bool
val (<>) : int -> int -> bool
val (<) : int -> int -> bool
val (>) : int -> int -> bool
val (<=) : int -> int -> bool
val (>=) : int -> int -> bool
val compare : int -> int -> int
val min : int -> int -> int
val max : int -> int -> int

Infix operators for Floats

val (=.) : float -> float -> bool
  • since 2.1
val (<>.) : float -> float -> bool
  • since 2.1
val (<.) : float -> float -> bool
  • since 2.1
val (>.) : float -> float -> bool
  • since 2.1
val (<=.) : float -> float -> bool
  • since 2.1
val (>=.) : float -> float -> bool
  • since 2.1

Shadow Dangerous Operators

val (==) : [ `Consider_using_CCEqual_physical ]
val (!=) : [ `Consider_using_CCEqual_physical ]
  • since 2.1
\ No newline at end of file +Containers (containers.Containers)

Module Containers

Drop-In replacement to Stdlib

module Array = CCArray
module Bool = CCBool
module Char = CCChar
module Equal = CCEqual
module Either = CCEither
module Float = CCFloat
module Format = CCFormat
module Fun = CCFun
module Hash = CCHash
module Hashtbl : sig ... end
module Heap = CCHeap
module Int = CCInt
module Int32 = CCInt32
module Int64 = CCInt64
module IO = CCIO
module List = CCList
module Map = CCMap
module Nativeint = CCNativeint
module Option = CCOption
module Ord = CCOrd
module Pair = CCPair
module Parse = CCParse
module Random = CCRandom
module Ref = CCRef
module Result = CCResult
module Seq = CCSeq
module Set = CCSet
module String = CCString
module Vector = CCVector
module Monomorphic = CCMonomorphic
module Utf8_string = CCUtf8_string
module Sexp = CCSexp
module Sexp_intf = CCSexp_intf
module Canonical_sexp = CCCanonical_sexp
module Stdlib = CCShims_.Stdlib
include module type of struct include Monomorphic end
  • since 2.0
val (=) : int -> int -> bool
val (<>) : int -> int -> bool
val (<) : int -> int -> bool
val (>) : int -> int -> bool
val (<=) : int -> int -> bool
val (>=) : int -> int -> bool
val compare : int -> int -> int
val min : int -> int -> int
val max : int -> int -> int

Infix operators for Floats

val (=.) : float -> float -> bool
  • since 2.1
val (<>.) : float -> float -> bool
  • since 2.1
val (<.) : float -> float -> bool
  • since 2.1
val (>.) : float -> float -> bool
  • since 2.1
val (<=.) : float -> float -> bool
  • since 2.1
val (>=.) : float -> float -> bool
  • since 2.1

Shadow Dangerous Operators

val (==) : [ `Consider_using_CCEqual_physical ]
val (!=) : [ `Consider_using_CCEqual_physical ]
  • since 2.1
\ No newline at end of file diff --git a/dev/containers/ContainersLabels/index.html b/dev/containers/ContainersLabels/index.html index 9f052ad8..d2cf1e33 100644 --- a/dev/containers/ContainersLabels/index.html +++ b/dev/containers/ContainersLabels/index.html @@ -1,2 +1,2 @@ -ContainersLabels (containers.ContainersLabels)

Module ContainersLabels

Drop-In replacement to Stdlib

module Array = CCArrayLabels
module Bool = CCBool
module Char = CCChar
module Equal = CCEqualLabels
module Either = CCEither
module Float = CCFloat
module Format = CCFormat
module Fun = CCFun
module Hash = CCHash
module Hashtbl : sig ... end
module Heap = CCHeap
module Int = CCInt
module Int32 = CCInt32
module Int64 = CCInt64
module IO = CCIO
module List = CCListLabels
module Map = CCMap
module Nativeint = CCNativeint
module Option = CCOption
module Ord = CCOrd
module Pair = CCPair
module Parse = CCParse
module Random = CCRandom
module Ref = CCRef
module Result = CCResult
module Seq = CCSeq
module Set = CCSet
module String = CCStringLabels
module Vector = CCVector
module Monomorphic = CCMonomorphic
module Utf8_string = CCUtf8_string
module Sexp = CCSexp
module Sexp_intf = CCSexp_intf
module Stdlib = CCShims_.Stdlib
include module type of struct include Monomorphic end
  • since 2.0
val (=) : int -> int -> bool
val (<>) : int -> int -> bool
val (<) : int -> int -> bool
val (>) : int -> int -> bool
val (<=) : int -> int -> bool
val (>=) : int -> int -> bool
val compare : int -> int -> int
val min : int -> int -> int
val max : int -> int -> int

Infix operators for Floats

val (=.) : float -> float -> bool
  • since 2.1
val (<>.) : float -> float -> bool
  • since 2.1
val (<.) : float -> float -> bool
  • since 2.1
val (>.) : float -> float -> bool
  • since 2.1
val (<=.) : float -> float -> bool
  • since 2.1
val (>=.) : float -> float -> bool
  • since 2.1

Shadow Dangerous Operators

val (==) : [ `Consider_using_CCEqual_physical ]
val (!=) : [ `Consider_using_CCEqual_physical ]
  • since 2.1
\ No newline at end of file +ContainersLabels (containers.ContainersLabels)

Module ContainersLabels

Drop-In replacement to Stdlib

module Array = CCArrayLabels
module Bool = CCBool
module Char = CCChar
module Equal = CCEqualLabels
module Either = CCEither
module Float = CCFloat
module Format = CCFormat
module Fun = CCFun
module Hash = CCHash
module Hashtbl : sig ... end
module Heap = CCHeap
module Int = CCInt
module Int32 = CCInt32
module Int64 = CCInt64
module IO = CCIO
module List = CCListLabels
module Map = CCMap
module Nativeint = CCNativeint
module Option = CCOption
module Ord = CCOrd
module Pair = CCPair
module Parse = CCParse
module Random = CCRandom
module Ref = CCRef
module Result = CCResult
module Seq = CCSeq
module Set = CCSet
module String = CCStringLabels
module Vector = CCVector
module Monomorphic = CCMonomorphic
module Utf8_string = CCUtf8_string
module Sexp = CCSexp
module Sexp_intf = CCSexp_intf
module Stdlib = CCShims_.Stdlib
include module type of struct include Monomorphic end
  • since 2.0
val (=) : int -> int -> bool
val (<>) : int -> int -> bool
val (<) : int -> int -> bool
val (>) : int -> int -> bool
val (<=) : int -> int -> bool
val (>=) : int -> int -> bool
val compare : int -> int -> int
val min : int -> int -> int
val max : int -> int -> int

Infix operators for Floats

val (=.) : float -> float -> bool
  • since 2.1
val (<>.) : float -> float -> bool
  • since 2.1
val (<.) : float -> float -> bool
  • since 2.1
val (>.) : float -> float -> bool
  • since 2.1
val (<=.) : float -> float -> bool
  • since 2.1
val (>=.) : float -> float -> bool
  • since 2.1

Shadow Dangerous Operators

val (==) : [ `Consider_using_CCEqual_physical ]
val (!=) : [ `Consider_using_CCEqual_physical ]
  • since 2.1
\ No newline at end of file diff --git a/dev/containers/index.html b/dev/containers/index.html index 764ab0bc..fc2d6efc 100644 --- a/dev/containers/index.html +++ b/dev/containers/index.html @@ -1,2 +1,2 @@ -index (containers.index)

containers index

Library containers

This library exposes the following toplevel modules:

Library containers.codegen

The entry point of this library is the module: Containers_codegen.

Library containers.monomorphic

This library exposes the following toplevel modules:

Library containers.top

The entry point of this library is the module: Containers_top.

Library containers.unix

The entry point of this library is the module: CCUnix.

\ No newline at end of file +index (containers.index)

containers index

Library containers

This library exposes the following toplevel modules:

Library containers.codegen

The entry point of this library is the module: Containers_codegen.

Library containers.monomorphic

This library exposes the following toplevel modules:

Library containers.top

The entry point of this library is the module: Containers_top.

Library containers.unix

The entry point of this library is the module: CCUnix.

\ No newline at end of file