diff --git a/3.10/containers/CCArray/index.html b/3.10/containers/CCArray/index.html index 29c1d6ea..381b18e6 100644 --- a/3.10/containers/CCArray/index.html +++ b/3.10/containers/CCArray/index.html @@ -1,5 +1,5 @@ -CCArray (containers.CCArray)

Module CCArray

Array utils

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

Fast internal iterator.

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

Arrays

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

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

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

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

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

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

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

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

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

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

  • since 0.18
val map_inplace : ( 'a -> 'a ) -> 'a t -> unit

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

  • since 3.8
val mapi_inplace : ( int -> 'a -> 'a ) -> 'a t -> unit

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

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

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

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

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

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

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

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

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

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

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

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

reverse_in_place a reverses the array a in place.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  • returns

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

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

lookup_exn ~cmp key a is like lookup, but

  • raises Not_found

    if the key key is not present.

val bsearch : +CCArray (containers.CCArray)

Module CCArray

Array utils

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

Fast internal iterator.

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

Arrays

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

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

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

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

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

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

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

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

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

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

  • since 0.18
val map_inplace : ( 'a -> 'a ) -> 'a t -> unit

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

  • since 3.8
val mapi_inplace : ( int -> 'a -> 'a ) -> 'a t -> unit

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

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

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

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

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

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

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

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

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

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

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

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

reverse_in_place a reverses the array a in place.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  • returns

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

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

lookup_exn ~cmp key a is like lookup, but

  • raises Not_found

    if the key key is not present.

val bsearch : cmp:( 'a -> 'a -> int ) -> 'a -> 'a t -> diff --git a/3.10/containers/CCArrayLabels/index.html b/3.10/containers/CCArrayLabels/index.html index b8d4734c..d5cd7a19 100644 --- a/3.10/containers/CCArrayLabels/index.html +++ b/3.10/containers/CCArrayLabels/index.html @@ -9,7 +9,7 @@ f:( 'a -> 'b -> 'a * 'c ) -> init:'a -> 'b array -> - 'a * 'c array
val fold_right : f:( 'b -> 'a -> 'a ) -> 'b array -> init:'a -> 'a
val for_all : f:( 'a -> bool ) -> 'a array -> bool
val exists : f:( 'a -> bool ) -> 'a array -> bool
val memq : 'a -> set:'a array -> bool
val find_opt : f:( 'a -> bool ) -> 'a array -> 'a option
val split : ('a * 'b) array -> 'a array * 'b array
val combine : 'a array -> 'b array -> ('a * 'b) array
val sort : cmp:( 'a -> 'a -> int ) -> 'a array -> unit
val stable_sort : cmp:( 'a -> 'a -> int ) -> 'a array -> unit
val fast_sort : cmp:( 'a -> 'a -> int ) -> 'a array -> unit
val to_seqi : 'a array -> (int * 'a) Stdlib.Seq.t
val of_seq : 'a Stdlib.Seq.t -> 'a array
val unsafe_get : 'a array -> int -> 'a
val unsafe_set : 'a array -> int -> 'a -> unit
module Floatarray : sig ... end
val empty : 'a t

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

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

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

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

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

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

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

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

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

  • since 0.18
val map_inplace : f:( 'a -> 'a ) -> 'a t -> unit

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

  • since 3.8
val mapi_inplace : f:( int -> 'a -> 'a ) -> 'a t -> unit

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

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

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

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

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

val fold_while : + 'a * 'c array
val fold_right : f:( 'b -> 'a -> 'a ) -> 'b array -> init:'a -> 'a
val for_all : f:( 'a -> bool ) -> 'a array -> bool
val exists : f:( 'a -> bool ) -> 'a array -> bool
val memq : 'a -> set:'a array -> bool
val find_opt : f:( 'a -> bool ) -> 'a array -> 'a option
val split : ('a * 'b) array -> 'a array * 'b array
val combine : 'a array -> 'b array -> ('a * 'b) array
val sort : cmp:( 'a -> 'a -> int ) -> 'a array -> unit
val stable_sort : cmp:( 'a -> 'a -> int ) -> 'a array -> unit
val fast_sort : cmp:( 'a -> 'a -> int ) -> 'a array -> unit
val to_seqi : 'a array -> (int * 'a) Stdlib.Seq.t
val of_seq : 'a Stdlib.Seq.t -> 'a array
val unsafe_get : 'a array -> int -> 'a
val unsafe_set : 'a array -> int -> 'a -> unit
module Floatarray : sig ... end
val empty : 'a t

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

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

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

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

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

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

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

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

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

  • since 0.18
val map_inplace : f:( 'a -> 'a ) -> 'a t -> unit

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

  • since 3.8
val mapi_inplace : f:( int -> 'a -> 'a ) -> 'a t -> unit

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

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

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

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

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

val fold_while : f:( 'a -> 'b -> 'a * [ `Stop | `Continue ] ) -> init:'a -> 'b t -> diff --git a/3.10/containers/CCInt64/index.html b/3.10/containers/CCInt64/index.html index 9c93c0d8..2cd84225 100644 --- a/3.10/containers/CCInt64/index.html +++ b/3.10/containers/CCInt64/index.html @@ -1,2 +1,2 @@ -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, a non-negative integer. Uses FNV since NEXT_RELEASE

val hash_to_int64 : t -> t

Like hash but does not truncate. Uses FNV.

  • since NEXT_RELEASE
val popcount : t -> int

Number of bits set to 1.

  • since 3.9
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, a non-negative integer. Uses FNV since 3.10

val hash_to_int64 : t -> t

Like hash but does not truncate. Uses FNV.

  • since 3.10
val popcount : t -> int

Number of bits set to 1.

  • since 3.9
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/3.10/containers/CCRef/index.html b/3.10/containers/CCRef/index.html index a4b1dcc1..04d416e5 100644 --- a/3.10/containers/CCRef/index.html +++ b/3.10/containers/CCRef/index.html @@ -1,2 +1,2 @@ -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 protect : 'a t -> 'a -> ( unit -> 'b ) -> 'b

protect r x f sets r := x; calls f(); restores r to its old value; and returns the result of f().

  • since NEXT_RELEASE
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 protect : 'a t -> 'a -> ( unit -> 'b ) -> 'b

protect r x f sets r := x; calls f(); restores r to its old value; and returns the result of f().

  • since 3.10
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/3.10/containers/CCSeq/index.html b/3.10/containers/CCSeq/index.html index d3f85209..6d214f86 100644 --- a/3.10/containers/CCSeq/index.html +++ b/3.10/containers/CCSeq/index.html @@ -1,5 +1,5 @@ -CCSeq (containers.CCSeq)

Module CCSeq

Helpers for the standard Seq type

See oseq for a richer API.

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

Basics

include module type of Stdlib.Seq
type !'a t = unit -> 'a node
and !'a node = 'a Stdlib__Seq.node =
| Nil
| Cons of 'a * 'a t
exception Forced_twice
val once : 'a t -> 'a t
val transpose : 'a t t -> 'a t t
val partition_map : ( 'a -> ( 'b, 'c ) Stdlib.Either.t ) -> 'a t -> 'b t * 'c t
val partition : ( 'a -> bool ) -> 'a t -> 'a t * 'a t
val of_dispenser : ( unit -> 'a option ) -> 'a t
val to_dispenser : 'a t -> unit -> 'a option
val ints : int -> int t
val nil : 'a t
val empty : 'a t
val cons : 'a -> 'a t -> 'a t
val singleton : 'a -> 'a t
val init : int -> ( int -> 'a ) -> 'a t

init n f corresponds to the sequence f 0; f 1; ...; f (n-1).

  • raises Invalid_argument

    if n is negative.

  • since NEXT_RELEASE
val repeat : ?n:int -> 'a -> 'a t

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

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

forever f corresponds to the infinit sequence containing all the f ().

  • since NEXT_RELEASE
val cycle : 'a t -> 'a t

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

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

iterate f a corresponds to the infinit sequence containing a, f a, f (f a), ...]

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

unfold f acc calls f acc and:

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

is_empty xs checks in the sequence xs is empty

val head : 'a t -> 'a option

Head of the list.

val head_exn : 'a t -> 'a

Unsafe version of head.

  • raises Not_found

    if the list is empty.

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

Tail of the list.

val tail_exn : 'a t -> 'a t

Unsafe version of tail.

  • raises Not_found

    if the list is empty.

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

uncons xs return None if xs is empty other

  • since NEXT_RELEASE
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 foldi : ( 'a -> int -> 'b -> 'a ) -> 'a -> 'b t -> 'a

fold_lefti f init xs applies f acc i x where acc is the result of the previous computation or init for the first one, i is the index in the sequence (starts at 0) and x is the element of the sequence.

  • since NEXT_RELEASE
val fold_lefti : ( 'a -> int -> 'b -> 'a ) -> 'a -> 'b t -> 'a

Alias of foldi.

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

Iterate with index (starts at 0).

val length : _ t -> int

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

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

Map with index (starts at 0).

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

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

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

Alias of product_with.

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

Specialization of product_with producing tuples.

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

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

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

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

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

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

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

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

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

find p [a1; ...; an] return Some ai for the first ai satisfying the predicate p and return None otherwise.

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

find f [a1; ...; an] return Some (f ai) for the first ai such that f ai = Some _ and return None otherwise.

  • since NEXT_RELEASE
val scan : ( 'a -> 'b -> 'a ) -> 'a -> 'b t -> 'a t

scan f init xs is the sequence containing the intermediate result of fold f init xs.

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

Aliass of flat_map

  • since NEXT_RELEASE
val filter_map : ( 'a -> 'b option ) -> 'a t -> 'b t
val flatten : 'a t t -> 'a t
val concat : 'a t t -> 'a t

Alias of flatten.

  • since NEXT_RELEASE
val range : int -> int -> int t
val (--) : int -> int -> int t

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

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

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

Operations on two Collections

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

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

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

Alias for fold2.

  • since NEXT_RELEASE
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 sorted_merge : 'a ord -> 'a t -> 'a t -> 'a t

Alias of merge.

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

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

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

Split each tuple in the list.

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

Alias of unzip.

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

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

  • since 3.8

Misc

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

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

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

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

val memoize : 'a t -> 'a t

Avoid recomputations by caching intermediate results.

Fair Combinations

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

Fair interleaving of both streams.

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

Fair version of flat_map.

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

Fair version of (<*>).

Implementations

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

Infix version of fair_flat_map.

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

Infix version of fair_app.

Infix operators

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

Conversions

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

Gather all values into a list.

val of_array : 'a array -> 'a t

Iterate on the array.

val to_array : 'a t -> 'a array

Convert into array.

val to_rev_list : 'a t -> 'a list

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

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

of_gen g consumes the generator and caches intermediate results.

val of_string : string -> char t

Iterate on characters.

  • since 3.7

IO

val pp : +CCSeq (containers.CCSeq)

Module CCSeq

Helpers for the standard Seq type

See oseq for a richer API.

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

Basics

include module type of Stdlib.Seq
type !'a t = unit -> 'a node
and !'a node = 'a Stdlib__Seq.node =
| Nil
| Cons of 'a * 'a t
exception Forced_twice
val once : 'a t -> 'a t
val transpose : 'a t t -> 'a t t
val partition_map : ( 'a -> ( 'b, 'c ) Stdlib.Either.t ) -> 'a t -> 'b t * 'c t
val partition : ( 'a -> bool ) -> 'a t -> 'a t * 'a t
val of_dispenser : ( unit -> 'a option ) -> 'a t
val to_dispenser : 'a t -> unit -> 'a option
val ints : int -> int t
val nil : 'a t
val empty : 'a t
val cons : 'a -> 'a t -> 'a t
val singleton : 'a -> 'a t
val init : int -> ( int -> 'a ) -> 'a t

init n f corresponds to the sequence f 0; f 1; ...; f (n-1).

  • raises Invalid_argument

    if n is negative.

  • since 3.10
val repeat : ?n:int -> 'a -> 'a t

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

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

forever f corresponds to the infinit sequence containing all the f ().

  • since 3.10
val cycle : 'a t -> 'a t

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

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

iterate f a corresponds to the infinit sequence containing a, f a, f (f a), ...]

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

unfold f acc calls f acc and:

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

is_empty xs checks in the sequence xs is empty

val head : 'a t -> 'a option

Head of the list.

val head_exn : 'a t -> 'a

Unsafe version of head.

  • raises Not_found

    if the list is empty.

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

Tail of the list.

val tail_exn : 'a t -> 'a t

Unsafe version of tail.

  • raises Not_found

    if the list is empty.

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

uncons xs return None if xs is empty other

  • since 3.10
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 foldi : ( 'a -> int -> 'b -> 'a ) -> 'a -> 'b t -> 'a

fold_lefti f init xs applies f acc i x where acc is the result of the previous computation or init for the first one, i is the index in the sequence (starts at 0) and x is the element of the sequence.

  • since 3.10
val fold_lefti : ( 'a -> int -> 'b -> 'a ) -> 'a -> 'b t -> 'a

Alias of foldi.

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

Iterate with index (starts at 0).

val length : _ t -> int

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

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

Map with index (starts at 0).

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

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

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

Alias of product_with.

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

Specialization of product_with producing tuples.

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

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

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

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

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

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

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

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

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

find p [a1; ...; an] return Some ai for the first ai satisfying the predicate p and return None otherwise.

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

find f [a1; ...; an] return Some (f ai) for the first ai such that f ai = Some _ and return None otherwise.

  • since 3.10
val scan : ( 'a -> 'b -> 'a ) -> 'a -> 'b t -> 'a t

scan f init xs is the sequence containing the intermediate result of fold f init xs.

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

Aliass of flat_map

  • since 3.10
val filter_map : ( 'a -> 'b option ) -> 'a t -> 'b t
val flatten : 'a t t -> 'a t
val concat : 'a t t -> 'a t

Alias of flatten.

  • since 3.10
val range : int -> int -> int t
val (--) : int -> int -> int t

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

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

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

Operations on two Collections

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

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

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

Alias for fold2.

  • since 3.10
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 sorted_merge : 'a ord -> 'a t -> 'a t -> 'a t

Alias of merge.

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

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

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

Split each tuple in the list.

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

Alias of unzip.

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

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

  • since 3.8

Misc

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

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

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

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

val memoize : 'a t -> 'a t

Avoid recomputations by caching intermediate results.

Fair Combinations

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

Fair interleaving of both streams.

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

Fair version of flat_map.

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

Fair version of (<*>).

Implementations

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

Infix version of fair_flat_map.

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

Infix version of fair_app.

Infix operators

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

Conversions

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

Gather all values into a list.

val of_array : 'a array -> 'a t

Iterate on the array.

val to_array : 'a t -> 'a array

Convert into array.

val to_rev_list : 'a t -> 'a list

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

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

of_gen g consumes the generator and caches intermediate results.

val of_string : string -> char t

Iterate on characters.

  • since 3.7

IO

val pp : ?pp_start:unit printer -> ?pp_stop:unit printer -> ?pp_sep:unit printer -> diff --git a/3.10/index.html b/3.10/index.html index 65d73eff..46cc4e1f 100644 --- a/3.10/index.html +++ b/3.10/index.html @@ -11,9 +11,9 @@

OCaml package documentation

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