mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
clean(Array): remove functions defined in Stdlib
This commit is contained in:
parent
2bde1e4dd3
commit
f3719d29aa
3 changed files with 0 additions and 75 deletions
|
|
@ -24,10 +24,6 @@ let empty = [| |]
|
|||
|
||||
let map = Array.map
|
||||
|
||||
let map2 f a b =
|
||||
if Array.length a <> Array.length b then invalid_arg "map2";
|
||||
Array.init (Array.length a) (fun i -> f (Array.unsafe_get a i) (Array.unsafe_get b i))
|
||||
|
||||
let length = Array.length
|
||||
|
||||
let get = Array.get
|
||||
|
|
@ -352,18 +348,6 @@ let bsearch ~cmp k a =
|
|||
bsearch ~cmp:CCInt.compare 3 [| |] = `Empty
|
||||
*)
|
||||
|
||||
let for_all p a =
|
||||
let rec aux i =
|
||||
i = Array.length a || (p a.(i) && aux (i+1))
|
||||
in
|
||||
aux 0
|
||||
|
||||
let exists p a =
|
||||
let rec aux i =
|
||||
i <> Array.length a && (p a.(i) || aux (i+1))
|
||||
in
|
||||
aux 0
|
||||
|
||||
let rec _for_all2 p a1 a2 i1 i2 ~len =
|
||||
len=0 || (p a1.(i1) a2.(i2) && _for_all2 p a1 a2 (i1+1) (i2+1) ~len:(len-1))
|
||||
|
||||
|
|
@ -378,11 +362,6 @@ let rec _exists2 p a1 a2 i1 i2 ~len =
|
|||
let exists2 p a b =
|
||||
_exists2 p a b 0 0 ~len:(min (Array.length a) (Array.length b))
|
||||
|
||||
let _iter2 f a b i j ~len =
|
||||
for o = 0 to len-1 do
|
||||
f (Array.get a (i+o)) (Array.get b (j+o))
|
||||
done
|
||||
|
||||
let _fold2 f acc a b i j ~len =
|
||||
let rec aux acc o =
|
||||
if o=len then acc
|
||||
|
|
@ -392,10 +371,6 @@ let _fold2 f acc a b i j ~len =
|
|||
in
|
||||
aux acc 0
|
||||
|
||||
let iter2 f a b =
|
||||
if length a <> length b then invalid_arg "iter2";
|
||||
_iter2 f a b 0 0 ~len:(Array.length a)
|
||||
|
||||
let fold2 f acc a b =
|
||||
if length a <> length b then invalid_arg "fold2";
|
||||
_fold2 f acc a b 0 0 ~len:(Array.length a)
|
||||
|
|
|
|||
|
|
@ -199,11 +199,6 @@ val bsearch : cmp:('a -> 'a -> int) -> 'a -> 'a t ->
|
|||
@raise Invalid_argument if the array is found to be unsorted w.r.t [cmp].
|
||||
@since 0.13 *)
|
||||
|
||||
val for_all : ('a -> bool) -> 'a t -> bool
|
||||
(** [for_all f [|a1; ...; an|]] is [true] if all elements of the array
|
||||
satisfy the predicate [f]. That is, it returns
|
||||
[(f a1) && (f a2) && ... && (f an)]. *)
|
||||
|
||||
val for_all2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool
|
||||
(** [for_all2 f [|a1; ...; an|] [|b1; ...; bn|]] is [true] if each pair of elements [ai bi]
|
||||
satisfies the predicate [f].
|
||||
|
|
@ -213,11 +208,6 @@ val for_all2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool
|
|||
Allow different types.
|
||||
@since 0.20 *)
|
||||
|
||||
val exists : ('a -> bool) -> 'a t -> bool
|
||||
(** [exists f [|a1; ...; an|]] is [true] if at least one element of
|
||||
the array satisfies the predicate [f]. That is, it returns
|
||||
[(f a1) || (f a2) || ... || (f an)]. *)
|
||||
|
||||
val exists2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool
|
||||
(** [exists2 f [|a1; ...; an|] [|b1; ...; bn|]] is [true] if any pair of elements [ai bi]
|
||||
satisfies the predicate [f].
|
||||
|
|
@ -234,13 +224,6 @@ val fold2 : ('acc -> 'a -> 'b -> 'acc) -> 'acc -> 'a t -> 'b t -> 'acc
|
|||
@raise Invalid_argument if [a] and [b] have distinct lengths.
|
||||
@since 0.20 *)
|
||||
|
||||
val iter2 : ('a -> 'b -> unit) -> 'a t -> 'b t -> unit
|
||||
(** [iter2 f a b] iterates on the two arrays [a] and [b] stepwise.
|
||||
It is equivalent to [f a0 b0; ...; f a.(length a - 1) b.(length b - 1); ()].
|
||||
|
||||
@raise 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. *)
|
||||
|
||||
|
|
@ -300,14 +283,6 @@ val map : ('a -> 'b) -> 'a t -> 'b t
|
|||
and builds an array with the results returned by [f]:
|
||||
[[| f a.(0); f a.(1); ...; f a.(length a - 1) |]]. *)
|
||||
|
||||
val map2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t
|
||||
(** [map2 f a b] applies function [f] to all elements of [a] and [b],
|
||||
and builds an array with the results returned by [f]:
|
||||
[[| f a.(0) b.(0); ...; f a.(length a - 1) b.(length b - 1)|]].
|
||||
|
||||
@raise 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 *)
|
||||
|
|
|
|||
|
|
@ -199,11 +199,6 @@ val bsearch : cmp:(('a -> 'a -> int) [@keep_label]) -> key:'a -> 'a t ->
|
|||
@raise Invalid_argument if the array is found to be unsorted w.r.t [cmp].
|
||||
@since 0.13 *)
|
||||
|
||||
val for_all : f:('a -> bool) -> 'a t -> bool
|
||||
(** [for_all ~f [|a1; ...; an|]] is [true] if all elements of the array
|
||||
satisfy the predicate [~f]. That is, it returns
|
||||
[(~f a1) && (~f a2) && ... && (~f an)]. *)
|
||||
|
||||
val for_all2 : f:('a -> 'b -> bool) -> 'a t -> 'b t -> bool
|
||||
(** [for_all2 ~f [|a1; ...; an|] [|b1; ...; bn|]] is [true] if each pair of elements [ai bi]
|
||||
satisfies the predicate [~f].
|
||||
|
|
@ -213,11 +208,6 @@ val for_all2 : f:('a -> 'b -> bool) -> 'a t -> 'b t -> bool
|
|||
Allow different types.
|
||||
@since 0.20 *)
|
||||
|
||||
val exists : f:('a -> bool) -> 'a t -> bool
|
||||
(** [exists ~f [|a1; ...; an|]] is [true] if at least one element of
|
||||
the array satisfies the predicate [~f]. That is, it returns
|
||||
[(~f a1) || (~f a2) || ... || (~f an)]. *)
|
||||
|
||||
val exists2 : f:('a -> 'b -> bool) -> 'a t -> 'b t -> bool
|
||||
(** [exists2 ~f [|a1; ...; an|] [|b1; ...; bn|]] is [true] if any pair of elements [ai bi]
|
||||
satisfies the predicate [~f].
|
||||
|
|
@ -234,13 +224,6 @@ val fold2 : f:('acc -> 'a -> 'b -> 'acc) -> init:'acc -> 'a t -> 'b t -> 'acc
|
|||
@raise 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); ()].
|
||||
|
||||
@raise 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. *)
|
||||
|
||||
|
|
@ -300,14 +283,6 @@ val map : f:('a -> 'b) -> 'a t -> 'b t
|
|||
and builds an array with the results returned by [~f]:
|
||||
[[| ~f a.(0); ~f a.(1); ...; ~f a.(length a - 1) |]]. *)
|
||||
|
||||
val map2 : f:('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t
|
||||
(** [map2 ~f a b] applies function [~f] to all elements of [a] and [b],
|
||||
and builds an array with the results returned by [~f]:
|
||||
[[| ~f a.(0) b.(0); ...; ~f a.(length a - 1) b.(length b - 1)|]].
|
||||
|
||||
@raise 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 *)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue