clean(Array): remove functions defined in Stdlib

This commit is contained in:
Fardale 2020-03-05 19:27:31 +01:00 committed by Simon Cruanes
parent 2bde1e4dd3
commit f3719d29aa
3 changed files with 0 additions and 75 deletions

View file

@ -24,10 +24,6 @@ let empty = [| |]
let map = Array.map 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 length = Array.length
let get = Array.get let get = Array.get
@ -352,18 +348,6 @@ let bsearch ~cmp k a =
bsearch ~cmp:CCInt.compare 3 [| |] = `Empty 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 = 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)) 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 = let exists2 p a b =
_exists2 p a b 0 0 ~len:(min (Array.length a) (Array.length 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 _fold2 f acc a b i j ~len =
let rec aux acc o = let rec aux acc o =
if o=len then acc if o=len then acc
@ -392,10 +371,6 @@ let _fold2 f acc a b i j ~len =
in in
aux acc 0 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 = let fold2 f acc a b =
if length a <> length b then invalid_arg "fold2"; if length a <> length b then invalid_arg "fold2";
_fold2 f acc a b 0 0 ~len:(Array.length a) _fold2 f acc a b 0 0 ~len:(Array.length a)

View file

@ -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]. @raise Invalid_argument if the array is found to be unsorted w.r.t [cmp].
@since 0.13 *) @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 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] (** [for_all2 f [|a1; ...; an|] [|b1; ...; bn|]] is [true] if each pair of elements [ai bi]
satisfies the predicate [f]. satisfies the predicate [f].
@ -213,11 +208,6 @@ val for_all2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool
Allow different types. Allow different types.
@since 0.20 *) @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 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] (** [exists2 f [|a1; ...; an|] [|b1; ...; bn|]] is [true] if any pair of elements [ai bi]
satisfies the predicate [f]. 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. @raise Invalid_argument if [a] and [b] have distinct lengths.
@since 0.20 *) @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 val shuffle : 'a t -> unit
(** [shuffle a] randomly shuffles the array [a], in place. *) (** [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]: and builds an array with the results returned by [f]:
[[| f a.(0); f a.(1); ...; f a.(length a - 1) |]]. *) [[| 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 val rev : 'a t -> 'a t
(** [rev a] copies the array [a] and reverses it in place. (** [rev a] copies the array [a] and reverses it in place.
@since 0.20 *) @since 0.20 *)

View file

@ -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]. @raise Invalid_argument if the array is found to be unsorted w.r.t [cmp].
@since 0.13 *) @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 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] (** [for_all2 ~f [|a1; ...; an|] [|b1; ...; bn|]] is [true] if each pair of elements [ai bi]
satisfies the predicate [~f]. satisfies the predicate [~f].
@ -213,11 +208,6 @@ val for_all2 : f:('a -> 'b -> bool) -> 'a t -> 'b t -> bool
Allow different types. Allow different types.
@since 0.20 *) @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 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] (** [exists2 ~f [|a1; ...; an|] [|b1; ...; bn|]] is [true] if any pair of elements [ai bi]
satisfies the predicate [~f]. 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. @raise Invalid_argument if [a] and [b] have distinct lengths.
@since 0.20 *) @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 val shuffle : 'a t -> unit
(** [shuffle a] randomly shuffles the array [a], in place. *) (** [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]: and builds an array with the results returned by [~f]:
[[| ~f a.(0); ~f a.(1); ...; ~f a.(length a - 1) |]]. *) [[| ~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 val rev : 'a t -> 'a t
(** [rev a] copies the array [a] and reverses it in place. (** [rev a] copies the array [a] and reverses it in place.
@since 0.20 *) @since 0.20 *)