[sledge] Update import, vector

Reviewed By: mbouaziz

Differential Revision: D9934559

fbshipit-source-id: a446f386c
master
Josh Berdine 6 years ago committed by Facebook Github Bot
parent f6ba0c8137
commit 91888c4c41

@ -7,92 +7,257 @@
(** Global namespace opened in each source file by the build system *)
include Option.Monad_infix
module Vector = Vector
include Vector.Infix
module Z = struct
include Z
let sexp_of_t z = Sexp.Atom (Z.to_string z)
let t_of_sexp = function
| Sexp.Atom s -> Z.of_string s
| _ -> assert false
end
include (
Base :
sig
include
(module type of Base
(* extended below, remove *)
with module Invariant := Base.Invariant
and module List := Base.List
and module Map := Base.Map
and module Option := Base.Option
and module Result := Base.Result
and module Set := Base.Set
(* prematurely deprecated, remove and use Stdlib instead *)
and module Filename := Base.Filename
and module Format := Base.Format
and module Scanf := Base.Scanf
and type ('ok, 'err) result := ('ok, 'err) Base.result)
[@warning "-3"]
end )
(* undeprecate *)
external ( == ) : 'a -> 'a -> bool = "%eq"
include Stdio
module Fheap = Core_kernel.Fheap
module Hash_queue = Core_kernel.Hash_queue
(** Tuple operations *)
let fst3 (x, _, _) = x
let snd3 (_, y, _) = y
let trd3 (_, _, z) = z
let ( >> ) f g x = g (f x)
(** Function combinators *)
let ( >> ) f g x = g (f x)
let ( $ ) f g x = f x ; g x
let ( $> ) x f = f x ; x
let ( <$ ) f x = f x ; x
type ('a, 'b) fmt_str = ('a, Format.formatter, unit, 'b) format4
(** Pretty-printing *)
type 'a fmt = Format.formatter -> 'a -> unit
let option_fmt fmt pp ff = function
| Some x -> Format.fprintf ff fmt pp x
| None -> ()
let rec list_fmt sep pp ff = function
| [] -> ()
| [x] -> pp ff x
| x :: xs -> Format.fprintf ff "%a%( %)%a" pp x sep (list_fmt sep pp) xs
type 'a pp = Formatter.t -> 'a -> unit
type ('a, 'b) fmt = ('a, Formatter.t, unit, 'b) format4
let vector_fmt sep pp ff v = list_fmt sep pp ff (Vector.to_list v)
(** Failures *)
let warn fmt =
let ff = Format.std_formatter in
Format.pp_open_box ff 2 ;
Format.pp_print_string ff "Warning: " ;
let fs = Format.std_formatter in
Format.pp_open_box fs 2 ;
Format.pp_print_string fs "Warning: " ;
Format.kfprintf
(fun ff ->
Format.pp_close_box ff () ;
Format.pp_force_newline ff () )
ff fmt
(fun fs ->
Format.pp_close_box fs () ;
Format.pp_force_newline fs () )
fs fmt
let raisef exn fmt =
let bt = Caml.Printexc.get_raw_backtrace () in
let ff = Format.str_formatter in
Format.pp_open_box ff 2 ;
let fs = Format.str_formatter in
Format.pp_open_box fs 2 ;
Format.kfprintf
(fun ff () ->
Format.pp_close_box ff () ;
(fun fs () ->
Format.pp_close_box fs () ;
let msg = Format.flush_str_formatter () in
let exn = exn msg in
Caml.Printexc.raise_with_backtrace exn bt )
ff fmt
fs fmt
exception Unimplemented of string
let todo fmt = raisef (fun msg -> Unimplemented msg) fmt
let fail fmt = raisef (fun msg -> Failure msg) fmt
let assertf cnd fmt =
if not cnd then fail fmt
else Format.ikfprintf (fun _ () -> ()) Format.str_formatter fmt
let checkf cnd fmt =
if not cnd then fail fmt
else Format.ikfprintf (fun _ () -> true) Format.str_formatter fmt
let check f x =
assert (f x ; true) ;
x
let violates f x =
assert (f x ; true) ;
assert false
type 'a or_error = ('a, exn * Caml.Printexc.raw_backtrace) Result.t
type 'a or_error = ('a, exn * Caml.Printexc.raw_backtrace) result
let or_error f x () =
try Ok (f x) with exn -> Error (exn, Caml.Printexc.get_raw_backtrace ())
(** Extensions *)
module Invariant = struct
include Base.Invariant
let invariant here t sexp_of_t f =
try f () with exn ->
let bt = Caml.Printexc.get_raw_backtrace () in
let exn =
Error.to_exn
(Error.create_s
(Base.Sexp.message "invariant failed"
[ ("", Source_code_position.sexp_of_t here)
; ("exn", sexp_of_exn exn)
; ("", sexp_of_t t) ]))
in
Caml.Printexc.raise_with_backtrace exn bt
end
let map_preserving_phys_equal map t ~f =
let change = ref false in
let t' =
map t ~f:(fun x ->
let x' = f x in
if not (x' == x) then change := true ;
x' )
in
if !change then t' else t
module Option = struct
include Base.Option
let pp fmt pp_elt fs = function
| Some x -> Format.fprintf fs fmt pp_elt x
| None -> ()
let cons xo xs = match xo with Some x -> x :: xs | None -> xs
end
include Option.Monad_infix
module List = struct
include Base.List
let rec pp ?pre ?suf sep pp_elt fs = function
| [] -> ()
| x :: xs ->
Option.iter pre ~f:(Format.fprintf fs) ;
pp_elt fs x ;
( match xs with
| [] -> ()
| xs -> Format.fprintf fs "%( %)%a" sep (pp sep pp_elt) xs ) ;
Option.iter suf ~f:(Format.fprintf fs)
let find_map_remove xs ~f =
let rec find_map_remove_ ys = function
| [] -> None
| x :: xs -> (
match f x with
| Some x' -> Some (x', rev_append ys xs)
| None -> find_map_remove_ (x :: ys) xs )
in
find_map_remove_ [] xs
let fold_option xs ~init ~f =
With_return.with_return
@@ fun {return} ->
Some
(fold xs ~init ~f:(fun acc elt ->
match f acc elt with Some res -> res | None -> return None ))
let map_preserving_phys_equal t ~f = map_preserving_phys_equal map t ~f
let remove_exn ?(equal = phys_equal) xs x =
let rec remove_ ys = function
| [] -> raise Caml.Not_found
| z :: xs ->
if equal x z then rev_append ys xs else remove_ (z :: ys) xs
in
remove_ [] xs
let remove xs x = try Some (remove_exn xs x) with Caml.Not_found -> None
let rec rev_init n ~f =
if n = 0 then []
else
let n = n - 1 in
let xs = rev_init n ~f in
f n :: xs
end
module Map = struct
include Base.Map
let find_and_remove_exn m k =
let found = ref None in
let m =
change m k ~f:(fun v ->
found := v ;
None )
in
match !found with None -> raise Caml.Not_found | Some v -> (v, m)
let find_and_remove m k =
try Some (find_and_remove_exn m k) with Caml.Not_found -> None
let find_or_add (type data) map key ~(default : data) ~if_found ~if_added
=
let exception Found of data in
match
update map key ~f:(function
| Some old_data -> Exn.raise_without_backtrace (Found old_data)
| None -> default )
with
| exception Found old_data -> if_found old_data
| map -> if_added map
let map_preserving_phys_equal t ~f = map_preserving_phys_equal map t ~f
end
module Result = struct
include Base.Result
let pp fmt pp_elt fs = function
| Ok x -> Format.fprintf fs fmt pp_elt x
| Error _ -> ()
end
module Vector = struct
include Vector
let pp sep pp_elt fs v = List.pp sep pp_elt fs (to_list v)
end
include Vector.Infix
module Set = struct
include Base.Set
type ('elt, 'cmp) tree = ('elt, 'cmp) Using_comparator.Tree.t
let pp pp_elt fs x = List.pp ",@ " pp_elt fs (to_list x)
let disjoint x y = is_empty (inter x y)
let diff_inter_diff x y = (diff x y, inter x y, diff y x)
let inter_diff x y = (inter x y, diff y x)
let of_vector cmp x = of_array cmp (Vector.to_array x)
let to_tree = Using_comparator.to_tree
end
module Z = struct
include Z
let hash_fold_t s z = Int.hash_fold_t s (Z.hash z)
let sexp_of_t z = Sexp.Atom (Z.to_string z)
let t_of_sexp = function
| Sexp.Atom s -> Z.of_string s
| _ -> assert false
end

@ -7,19 +7,35 @@
(** Global namespace opened in each source file by the build system *)
include module type of Option.Monad_infix
module Z : sig
include module type of Z
val t_of_sexp : Sexp.t -> t
val sexp_of_t : t -> Sexp.t
end
module Vector = Vector
include module type of Vector.Infix
include module type of (
Base :
sig
include
(module type of Base
(* extended below, remove *)
with module Invariant := Base.Invariant
and module List := Base.List
and module Map := Base.Map
and module Option := Base.Option
and module Result := Base.Result
and module Set := Base.Set
(* prematurely deprecated, remove and use Stdlib instead *)
and module Filename := Base.Filename
and module Format := Base.Format
and module Scanf := Base.Scanf
and type ('ok, 'err) result := ('ok, 'err) Base.result)
[@warning "-3"]
end )
(* undeprecate *)
external ( == ) : 'a -> 'a -> bool = "%eq"
include module type of Stdio
module Fheap = Core_kernel.Fheap
module Hash_queue = Core_kernel.Hash_queue
(** Tuple operations *)
val fst3 : 'a * _ * _ -> 'a
(** First projection from a triple. *)
@ -30,6 +46,8 @@ val snd3 : _ * 'a * _ -> 'a
val trd3 : _ * _ * 'a -> 'a
(** Third projection from a triple. *)
(** Function combinators *)
val ( >> ) : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c
(** Composition of functions: [(f >> g) x] is exactly equivalent to [g (f
(x))]. Left associative. *)
@ -46,43 +64,154 @@ val ( <$ ) : ('a -> unit) -> 'a -> 'a
(** Reverse apply and ignore function: [f <$ x] is exactly equivalent to [f
x ; x]. Left associative. *)
(** Format strings. *)
type ('a, 'b) fmt_str = ('a, Format.formatter, unit, 'b) format4
(** Pretty-printing *)
(** Formatting function for argument type. *)
type 'a fmt = Format.formatter -> 'a -> unit
(** Pretty-printer for argument type. *)
type 'a pp = Formatter.t -> 'a -> unit
val option_fmt :
('a_fmt -> 'a -> unit, unit) fmt_str -> 'a_fmt -> 'a option fmt
(** Format an option. *)
val list_fmt : (unit, unit) fmt_str -> 'a fmt -> 'a list fmt
(** Format a list. *)
(** Format strings. *)
type ('a, 'b) fmt = ('a, Formatter.t, unit, 'b) format4
val vector_fmt : (unit, unit) fmt_str -> 'a fmt -> 'a vector fmt
(** Format a vector. *)
(** Failures *)
exception Unimplemented of string
val warn : ('a, unit) fmt_str -> 'a
val warn : ('a, unit) fmt -> 'a
(** Issue a warning for a survivable problem. *)
val todo : ('a, unit -> _) fmt_str -> 'a
val todo : ('a, unit -> _) fmt -> 'a
(** Raise an [Unimplemented] exception indicating that an input is valid but
not handled by the current implementation. *)
val assertf : bool -> ('a, unit -> unit) fmt_str -> 'a
val assertf : bool -> ('a, unit -> unit) fmt -> 'a
(** Raise an [Failure] exception if the bool argument is false, indicating
that the expected condition was not satisfied. *)
val checkf : bool -> ('a, unit -> bool) fmt_str -> 'a
val checkf : bool -> ('a, unit -> bool) fmt -> 'a
(** As [assertf] but returns the argument bool. *)
val fail : ('a, unit -> _) fmt_str -> 'a
val fail : ('a, unit -> _) fmt -> 'a
(** Raise a [Failure] exception indicating a fatal error not covered by
[assertf], [checkf], or [todo]. *)
type 'a or_error = ('a, exn * Caml.Printexc.raw_backtrace) Result.t
val check : ('a -> unit) -> 'a -> 'a
(** Assert that function does not raise on argument, and return argument. *)
val violates : ('a -> unit) -> 'a -> _
(** Assert that function raises on argument. *)
type 'a or_error = ('a, exn * Caml.Printexc.raw_backtrace) result
val or_error : ('a -> 'b) -> 'a -> unit -> 'b or_error
(** [or_error f x] runs [f x] and converts unhandled exceptions to errors. *)
(** Extensions *)
module Invariant : module type of Base.Invariant
module Option : sig
include module type of Base.Option
val pp : ('a_pp -> 'a -> unit, unit) fmt -> 'a_pp -> 'a option pp
(** Pretty-print an option. *)
val cons : 'a t -> 'a list -> 'a list
end
include module type of Option.Monad_infix
module List : sig
include module type of Base.List
val pp :
?pre:(unit, unit) fmt
-> ?suf:(unit, unit) fmt
-> (unit, unit) fmt
-> 'a pp
-> 'a list pp
(** Pretty-print a list. *)
val find_map_remove :
'a list -> f:('a -> 'b option) -> ('b * 'a list) option
val fold_option :
'a t
-> init:'accum
-> f:('accum -> 'a -> 'accum option)
-> 'accum option
(** [fold_option t ~init ~f] is a short-circuiting version of [fold] that
runs in the [Option] monad. If [f] returns [None], that value is
returned without any additional invocations of [f]. *)
val map_preserving_phys_equal : 'a t -> f:('a -> 'a) -> 'a t
(** Like map, but preserves [phys_equal] if [f] preserves [phys_equal] of
every element. *)
val remove_exn : ?equal:('a -> 'a -> bool) -> 'a list -> 'a -> 'a list
(** Returns the input list without the first element [equal] to the
argument, or raise [Not_found] if no such element exists. [equal]
defaults to physical equality. *)
val remove : 'a list -> 'a -> 'a list option
val rev_init : int -> f:(int -> 'a) -> 'a list
end
module Map : sig
include module type of Base.Map
val find_and_remove_exn : ('k, 'v, 'c) t -> 'k -> 'v * ('k, 'v, 'c) t
val find_and_remove : ('k, 'v, 'c) t -> 'k -> ('v * ('k, 'v, 'c) t) option
val find_or_add :
('k, 'v, 'c) t
-> 'k
-> default:'v
-> if_found:('v -> 'a)
-> if_added:(('k, 'v, 'c) t -> 'a)
-> 'a
val map_preserving_phys_equal :
('k, 'v, 'c) t -> f:('v -> 'v) -> ('k, 'v, 'c) t
(** Like map, but preserves [phys_equal] if [f] preserves [phys_equal] of
every element. *)
end
module Result : sig
include module type of Base.Result
val pp : ('a_pp -> 'a -> unit, unit) fmt -> 'a_pp -> ('a, _) t pp
(** Pretty-print a result. *)
end
module Vector : sig
include module type of Vector
val pp : (unit, unit) fmt -> 'a pp -> 'a t pp
(** Pretty-print a vector. *)
end
include module type of Vector.Infix
module Set : sig
include module type of Base.Set
type ('e, 'c) tree
val pp : 'e pp -> ('e, 'c) t pp
val disjoint : ('e, 'c) t -> ('e, 'c) t -> bool
val diff_inter_diff :
('e, 'c) t -> ('e, 'c) t -> ('e, 'c) t * ('e, 'c) t * ('e, 'c) t
val inter_diff : ('e, 'c) t -> ('e, 'c) t -> ('e, 'c) t * ('e, 'c) t
val of_vector : ('e, 'c) comparator -> 'e vector -> ('e, 'c) t
val to_tree : ('e, 'c) t -> ('e, 'c) tree
end
module Z : sig
include module type of Z
val hash_fold_t : t Hash.folder
val t_of_sexp : Sexp.t -> t
val sexp_of_t : t -> Sexp.t
end

@ -13,65 +13,66 @@ open Base
type +'a t
let v (a : 'a array) : 'a t = Caml.Obj.magic a
let a (v : 'a t) : 'a array = Caml.Obj.magic v
let _vl (al : 'a array list) : 'a t list = Caml.Obj.magic al
let al (vl : 'a t list) : 'a array list = Caml.Obj.magic vl
let compare cmp x y = Array.compare cmp (a x) (a y)
let hash_fold_t f s x = Hash.Builtin.hash_fold_array_frozen f s (a x)
let t_of_sexp a_of_sexp s = v (Array.t_of_sexp a_of_sexp s)
let sexp_of_t sexp_of_a x = Array.sexp_of_t sexp_of_a (a x)
module Infix = struct
type +'a vector = 'a t [@@deriving compare, sexp]
type +'a vector = 'a t [@@deriving compare, hash, sexp]
end
let concat_map x ~f = v (Array.concat_map (a x) ~f:(fun y -> a (f y)))
let create ~len x = v (Array.create ~len x)
let empty = v [||]
let find x ~f = Array.find (a x) ~f
let contains_dup ~compare xs =
Option.is_some
(Array.find_consecutive_duplicate
~equal:(fun x y -> compare x y = 0)
(Array.sorted_copy ~compare (a xs)))
let find x ~f = Array.find (a x) ~f
let find_exn x ~f = Array.find_exn (a x) ~f
let find_map x ~f = Array.find_map (a x) ~f
let fold x ~init ~f = Array.fold (a x) ~init ~f
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 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
external get : 'a t -> int -> 'a = "%array_safe_get"
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
let rev_iter x ~f = Array.fold_right (a x) ~init:() ~f:(fun e () -> f e)
let iter2_exn x y ~f = Array.iter2_exn (a x) (a y) ~f
let iteri x ~f = Array.iteri (a x) ~f
let length x = Array.length (a x)
let map x ~f = v (Array.map (a x) ~f)
let mapi x ~f = v (Array.mapi (a x) ~f)
let slice x i j = v (Array.slice (a x) i j)
let map_preserving_phys_equal xs ~f =
let change = ref false in
let xs' =
map xs ~f:(fun x ->
let x' = f x in
if not (phys_equal x' x) then change := true ;
x' )
in
if !change then xs' else xs
let mapi x ~f = v (Array.mapi (a x) ~f)
let map2_exn x y ~f = v (Array.map2_exn (a x) (a y) ~f)
let concat xs = v (Array.concat (al xs))
let of_array = v
let of_list x = v (Array.of_list x)
let of_list_rev x = v (Array.of_list_rev x)
let of_option x = v (Option.to_array x)
let to_list x = Array.to_list (a x)
let to_array = a

@ -8,61 +8,58 @@
(** Vector - Immutable view of an array
Note that vectors and arrays can be interconverted without copying. So
Vector is not a safe immutable data structure, it is only attempts to
make it inconvenient to mutate. *)
Vector is not a safe immutable data structure, it only attempts to make
it inconvenient to mutate. *)
open Base
type +'a t
type +'a t [@@deriving compare, hash, sexp]
module Infix : sig
type +'a vector = 'a t [@@deriving compare, sexp]
type +'a vector = 'a t [@@deriving compare, hash, sexp]
end
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
(* val binary_search :
* ('a t, 'a, 'key) Base__Binary_searchable_intf.binary_search *)
val t_of_sexp : (Sexp.t -> 'a) -> Sexp.t -> 'a t
(* val binary_search_segmented :
* ('a t, 'a) Base__Binary_searchable_intf.binary_search_segmented *)
val sexp_of_t : ('a -> Sexp.t) -> 'a t -> Sexp.t
(* val t_of_sexp : (Sexp.t -> 'a) -> Sexp.t -> 'a t *)
(* val sexp_of_t : ('a -> Sexp.t) -> 'a t -> Sexp.t *)
(* val binary_search : *)
(* ('a t, 'a, 'key) Base.Binary_searchable_intf.binary_search *)
(* val binary_search_segmented : *)
(* ('a t, 'a) Binary_searchable_intf.binary_search_segmented *)
(* val mem : 'a t -> 'a -> equal:('a -> 'a -> bool) -> bool *)
val length : 'a t -> int
val is_empty : 'a t -> bool
val iter : 'a t -> f:('a -> unit) -> unit
val rev_iter : 'a t -> f:('a -> unit) -> unit
val fold : 'a t -> init:'accum -> f:('accum -> 'a -> 'accum) -> 'accum
(* val fold_result : *)
(* 'a t -> init:'accum -> f:('accum -> 'a -> ('accum, 'e) result) *)
(* -> ('accum, 'e) result *)
(* val fold_until : *)
(* 'a t -> init:'accum *)
(* -> f:('accum -> 'a -> ('accum, 'stop) Container_intf.Continue_or_stop.t) *)
(* -> ('accum, 'stop) Container_intf.Finished_or_stopped_early.t *)
val fold_result :
'a t
-> init:'accum
-> f:('accum -> 'a -> ('accum, 'e) Result.t)
-> ('accum, 'e) Result.t
val fold_until :
'a t
-> init:'accum
-> f:('accum -> 'a -> ('accum, 'final) Continue_or_stop.t)
-> finish:('accum -> 'final)
-> 'final
(* 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 *)
(* val sum : *)
(* (module Base__.Commutative_group.S with type t = 'sum) -> *)
(* 'a t -> f:('a -> 'sum) -> 'sum *)
val find : 'a t -> f:('a -> bool) -> 'a option
(* val find_map : 'a t -> f:('a -> 'b option) -> 'b option *)
(* val sum :
* (module Commutative_group.S with type t = 'sum)
* -> 'a t
* -> f:('a -> 'sum)
* -> 'sum *)
val find : 'a t -> f:('a -> bool) -> 'a option
val find_map : 'a t -> f:('a -> 'b option) -> 'b option
val to_list : 'a t -> 'a list
val to_array : 'a t -> 'a array
@ -72,9 +69,10 @@ val to_array : 'a t -> 'a array
is e.g. to pattern match on a vector, or to interface with some existing
array code that is known to not mutate its arguments. *)
(* val min_elt : 'a t -> cmp:('a -> 'a -> int) -> 'a option *)
(* val max_elt : 'a t -> cmp:('a -> 'a -> int) -> 'a option *)
(* val invariant : 'a Base__Invariant_intf.t -> 'a t Base__Invariant_intf.t *)
(* val min_elt : 'a t -> compare:('a -> 'a -> int) -> 'a option *)
(* val max_elt : 'a t -> compare:('a -> 'a -> int) -> 'a option *)
(* val invariant : 'a Base__Invariant_intf.inv -> 'a t
Base__Invariant_intf.inv *)
(* val max_length : int *)
external get : 'a t -> int -> 'a = "%array_safe_get"
@ -82,13 +80,16 @@ external get : 'a t -> int -> 'a = "%array_safe_get"
(* external unsafe_get : 'a t -> int -> 'a = "%array_unsafe_get" *)
val create : len:int -> 'a -> 'a t
val init : int -> f:(int -> 'a) -> 'a t
(* val make_matrix : dimx:int -> dimy:int -> 'a -> 'a t t *)
(* val append : 'a t -> 'a t -> 'a t *)
(* val concat : 'a t list -> '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 of_array : 'a array -> 'a t
(** [of_array a] is a vector that shares its representation with array [a],
@ -98,42 +99,39 @@ val of_array : 'a array -> 'a t
of a vector. *)
val of_list : 'a list -> 'a t
val of_option : 'a option -> 'a t
val map : 'a t -> f:('a -> 'b) -> 'b t
val map_preserving_phys_equal : 'a t -> f:('a -> 'a) -> 'a t
(** Like map, but preserves [phys_equal] if [f] preserves [phys_equal] of
every element. *)
(* val folding_map : 'a t -> init:'b -> f:('b -> 'a -> 'b * 'c) -> 'c t *)
(* val folding_mapi : 'a t -> init:'b -> f:(int -> 'b -> 'a -> 'b * 'c) ->
'c t *)
(* val fold_map : 'a t -> init:'b -> f:('b -> 'a -> 'b * 'c) -> 'b * 'c t *)
(* val fold_mapi : *)
(* 'a t -> init:'b -> f:(int -> 'b -> 'a -> 'b * 'c) -> 'b * 'c t *)
val iteri : 'a t -> f:(int -> 'a -> unit) -> unit
(* val fold_mapi :
* 'a t -> init:'b -> f:(int -> 'b -> 'a -> 'b * 'c) -> 'b * 'c t *)
val iteri : 'a t -> f:(int -> 'a -> unit) -> unit
val mapi : 'a t -> f:(int -> 'a -> 'b) -> 'b t
(* val foldi : 'a t -> init:'b -> f:(int -> 'b -> 'a -> 'b) -> 'b *)
val fold_right : 'a t -> f:('a -> 'b -> 'b) -> init:'b -> 'b
(* val sort : 'a t -> cmp:('a -> 'a -> int) -> 'a t *)
(* val stable_sort : 'a t -> cmp:('a -> 'a -> int) -> 'a t *)
(* val is_sorted : 'a t -> cmp:('a -> 'a -> int) -> bool *)
(* val is_sorted_strictly : 'a t -> cmp:('a -> 'a -> int) -> bool *)
(* val concat_map : 'a t -> f:('a -> 'b t) -> 'b t *)
(* val is_sorted : 'a t -> compare:('a -> 'a -> int) -> bool *)
(* val is_sorted_strictly : 'a t -> compare:('a -> 'a -> int) -> bool *)
val concat_map : 'a t -> f:('a -> 'b t) -> 'b t
(* val concat_mapi : 'a t -> f:(int -> 'a -> 'b t) -> 'b t *)
(* val partition_tf : 'a t -> f:('a -> bool) -> 'a t * 'a t *)
(* val partitioni_tf : 'a t -> f:(int -> 'a -> bool) -> 'a t * 'a t *)
(* val cartesian_product : 'a t -> 'b t -> ('a * 'b) t *)
(* val transpose : 'a t t -> 'a t t option *)
(* val transpose_exn : 'a t t -> 'a t t *)
(* val normalize : 'a t -> int -> int *)
val slice : 'a t -> int -> int -> 'a t
(* val nget : 'a t -> int -> 'a *)
(* val filter_opt : 'a option t -> 'a t *)
(* val filter_map : 'a t -> f:('a -> 'b option) -> 'b t *)
(* val filter_mapi : 'a t -> f:(int -> 'a -> 'b option) -> 'b t *)
@ -142,10 +140,8 @@ val slice : 'a t -> int -> int -> 'a t
(* val counti : 'a t -> f:(int -> 'a -> bool) -> int *)
val iter2_exn : 'a t -> 'b t -> f:('a -> 'b -> unit) -> unit
(* val map2_exn : 'a t -> 'b t -> f:('a -> 'b -> 'c) -> 'c t *)
(* val fold2_exn : 'a t -> 'b t -> init:'c -> f:('c -> 'a -> 'b -> 'c) -> 'c *)
val map2_exn : 'a t -> 'b t -> f:('a -> 'b -> 'c) -> 'c t
val fold2_exn : 'a t -> 'b t -> init:'c -> f:('c -> 'a -> 'b -> 'c) -> 'c
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 *)
@ -164,17 +160,26 @@ val find_exn : 'a t -> f:('a -> bool) -> 'a
(* val findi_exn : 'a t -> f:(int -> 'a -> bool) -> int * 'a *)
(* val find_mapi : 'a t -> f:(int -> 'a -> 'b option) -> 'b option *)
(* val find_mapi_exn : 'a t -> f:(int -> 'a -> 'b option) -> 'b *)
(* val find_consecutive_duplicate : *)
(* 'a t -> equal:('a -> 'a -> bool) -> ('a * 'a) option *)
(* val find_consecutive_duplicate :
* 'a t -> equal:('a -> 'a -> bool) -> ('a * 'a) option *)
val contains_dup : compare:('a -> 'a -> int) -> 'a t -> bool
(* val reduce : 'a t -> f:('a -> 'a -> 'a) -> 'a option *)
(* val reduce_exn : 'a t -> f:('a -> 'a -> 'a) -> 'a *)
(* val random_element : ?random_state:Random.State.t -> 'a t -> 'a option *)
(* val random_element_exn : ?random_state:Random.State.t -> 'a t -> 'a *)
(* val random_element :
* ?random_state:Base.Random.State.t -> 'a t -> 'a option *)
(* val random_element_exn : ?random_state:Base.Random.State.t -> 'a t -> 'a *)
(* val zip : 'a t -> 'b t -> ('a * 'b) t option *)
(* val zip_exn : 'a t -> 'b t -> ('a * 'b) t *)
(* 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 empty : 'a t
(* val equal : 'a t -> 'a t -> equal:('a -> 'a -> bool) -> bool *)
(* val to_sequence : 'a t -> 'a Sequence.t *)
(* val to_sequence_mutable : 'a t -> 'a Sequence.t *)

Loading…
Cancel
Save