diff --git a/sledge/src/import/vector.ml b/sledge/src/import/vector.ml index 6908f7e86..708af7d69 100644 --- a/sledge/src/import/vector.ml +++ b/sledge/src/import/vector.ml @@ -44,11 +44,14 @@ let fold_right x ~f ~init = Array.fold_right (a x) ~f ~init let fold_result x ~init ~f = Array.fold_result (a x) ~init ~f let fold_until x ~init ~f ~finish = Array.fold_until (a x) ~init ~f ~finish let fold2_exn x y ~init ~f = Array.fold2_exn (a x) (a y) ~init ~f +let exists x ~f = Array.exists (a x) ~f let for_all x ~f = Array.for_all (a x) ~f let for_all2_exn x y ~f = Array.for_all2_exn (a x) (a y) ~f +let filteri x ~f = v (Array.filteri (a x) ~f) external get : 'a t -> int -> 'a = "%array_safe_get" +let last x = Array.last (a x) let init n ~f = v (Array.init n ~f) let is_empty x = Array.is_empty (a x) let iter x ~f = Array.iter (a x) ~f @@ -78,6 +81,8 @@ let fold_map x ~init ~f = let concat xs = v (Array.concat (al xs)) let copy x = v (Array.copy (a x)) +let sub ~pos ~len x = v (Array.sub ~pos ~len (a x)) +let subo ?pos ?len x = v (Array.subo ?pos ?len (a x)) let of_ x = v [|x|] let of_array = v let of_list x = v (Array.of_list x) diff --git a/sledge/src/import/vector.mli b/sledge/src/import/vector.mli index 53faa66eb..596ddfe33 100644 --- a/sledge/src/import/vector.mli +++ b/sledge/src/import/vector.mli @@ -46,8 +46,7 @@ val fold_until : -> finish:('accum -> 'final) -> 'final -(* val exists : 'a t -> f:('a -> bool) -> bool *) - +val exists : 'a t -> f:('a -> bool) -> bool val for_all : 'a t -> f:('a -> bool) -> bool (* val count : 'a t -> f:('a -> bool) -> int *) @@ -87,10 +86,8 @@ val init : int -> f:(int -> 'a) -> 'a t val concat : 'a t list -> 'a t val copy : 'a t -> 'a t - -(* val sub : ('a t, 'a t) Base__Blit_intf.sub *) -(* val subo : ('a t, 'a t) Base__Blit_intf.subo *) - +val sub : pos:int -> len:int -> 'a t -> 'a t +val subo : ?pos:int -> ?len:int -> 'a t -> 'a t val of_ : 'a -> 'a t val of_array : 'a array -> 'a t @@ -148,8 +145,7 @@ val for_all2_exn : 'a t -> 'b t -> f:('a -> 'b -> bool) -> bool (* val exists2_exn : 'a t -> 'b t -> f:('a -> 'b -> bool) -> bool *) (* val filter : 'a t -> f:('a -> bool) -> 'a t *) -(* val filteri : 'a t -> f:(int -> 'a -> bool) -> 'a t *) - +val filteri : 'a t -> f:(int -> 'a -> bool) -> 'a t val of_list_rev : 'a list -> 'a t (* val of_list_map : 'a list -> f:('a -> 'b) -> 'b t *) @@ -182,8 +178,7 @@ val reduce_exn : 'a t -> f:('a -> 'a -> 'a) -> 'a val unzip : ('a * 'b) t -> 'a t * 'b t (* val sorted_copy : 'a t -> compare:('a -> 'a -> int) -> 'a t *) -(* val last : 'a t -> 'a *) - +val last : 'a t -> 'a val empty : 'a t (* val to_sequence : 'a t -> 'a Sequence.t *)