Module BC_Array


module BC_Array: sig  end
An extention of the standard Array module. Inherits all functions from Array with a few more functions of our own.
Author(s): Hideo Bannai, Yoshinori Tamada

val rev : 'a array -> 'a array
return a fresh array with the elements in reverse order
val rev_map : ('a -> 'b) -> 'a array -> 'b array
reverse map. Same as (fun f a -> BC_Array.rev (Array.map f a)) but doesn't create the intermediate array
val map_to_list : ('a -> 'b) -> 'a array -> 'b list
map and return the result as a list. Should be more efficient than Array.to_list (Array.map f a) because intermediate arrays or lists are not created
val rev_map_to_list : ('a -> 'b) -> 'a array -> 'b list
map and return the result as list. Should be more efficient than List.rev (Array.to_list (Array.map f a) because intermediate arrays or lists are not created
val rev_of_list : 'a list -> 'a array
create a fresh array from a list. Same as Array.of_list except that the order of the elements is reversed
val partition : ('a -> bool) -> 'a array -> 'a array * 'a array
partition p a returns pair of arrays (a1, a2) where a1 is the array of all elements of a which satisfy p, and a2 is the array of all elements of a which do not satisfy p. The order of the input array is preserved
val count : ('a -> bool) -> 'a array -> int
count elements in array which satisfy predicate p
val sub_fold_left : int -> int -> ('a -> 'b -> 'a) -> 'a -> 'b array -> 'a
sub_fold_left b l f init a computes f (... (f (f init a.(b)) a.(b+1)) ...) a.(b+l-1) It is equivalent to Array.fold_left f (Array.sub arr b l) init a (if f does not modify the array) but should be more efficient in that a fresh array is not created
Raises Invalid_argument if b and l are not in valid range
val foldi_left : (int -> 'a -> 'b -> 'a) -> 'a -> 'b array -> 'a
same as fold_left, but the function is applied to the index of the element as first argument, the cummulative value as the second argument, and the element itself as the third argument
val foldi_right : (int -> 'a -> 'b -> 'b) -> 'a array -> 'b -> 'b
same as fold_right, but the function is applied to the index of the element as first argument, and the element itself as the second argument, and the cummulative value as the third argument.
val exists : ('a -> bool) -> 'a array -> bool
exists p a returns true if at least one element of array a satisfies the predicate p, and false otherwise.
val m : ('a -> 'a -> int) -> 'a array -> 'a
m cmp a return the element of array a that is minimum, with respect to cmp. cmp x y should return 0 if x and y is equal, -1 if x < y and 1 otherwise.
Raises Invalid_argument for an empty array.
val min : 'a array -> 'a
return the minimum element of an array. (minimum defined by Pervasives.min)
Raises Invalid_argument for an empty array.
val max : 'a array -> 'a
return the maximum element of an array. (maximum defined by Pervasives.max)
Raises Invalid_argument for an empty array.
val split : ('a * 'b) array -> 'a array * 'b array
array version of List.split. convert [|(a1,b1);(a2,b2); ... |] into ([|a1;a2;...|],[|b1;b2;...|])
val combine : 'a array -> 'b array -> ('a * 'b) array
array version of List.combine. opposite of BC_Array.split.
Raises Invalid_argument if the two arrays have different lengths.
val arg_m : ('a -> 'a -> int) -> 'a array -> int
arg_m cmp arr return the element number with the minimum value with respect to cmp. the younger element # is chosen when there are multiple elements with the maximum value.
val arg_max : 'a array -> int
return the element number with the maximum value. the younger element # is chosen when there are multiple elements with the maximum value.
val arg_min : 'a array -> int
return the element number with the minimum value. the younger element # is chosen when there are multiple elements with the maximum value.
val arg_sort : ('a -> 'a -> int) -> 'a array -> int array
argsort comp a returns an array consisting of indices of a sorted array a.


The following are functions of the standard Array module. See the OCaml manual for documentation.


val length : 'a array -> int
val get : 'a array -> int -> 'a
val set : 'a array -> int -> 'a -> unit
val make : int -> 'a -> 'a array
val create : int -> 'a -> 'a array
val init : int -> (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 map : ('a -> 'b) -> 'a array -> 'b array
val iteri : (int -> 'a -> unit) -> 'a array -> unit
val mapi : (int -> 'a -> 'b) -> 'a array -> 'b array
val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b array -> 'a
val fold_right : ('a -> 'b -> 'b) -> 'a array -> 'b -> 'b
val sort : ('a -> 'a -> int) -> 'a array -> unit
val stable_sort : ('a -> 'a -> int) -> 'a array -> unit
val unsafe_get : 'a array -> int -> 'a
val unsafe_set : 'a array -> int -> 'a -> unit