mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
remove trailing whitespace
This commit is contained in:
parent
f24d03ddb9
commit
ac180aa339
24 changed files with 40 additions and 40 deletions
|
|
@ -273,7 +273,7 @@ module Coll = struct
|
|||
S.cardinal set
|
||||
|
||||
let choose_exn (type elt) c =
|
||||
let fail () = _exit_with_error "choose: empty collection" in
|
||||
let fail () = _exit_with_error "choose: empty collection" in
|
||||
match c with
|
||||
| List [] -> fail ()
|
||||
| List (x::_) -> x
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ module PMap : sig
|
|||
@raise Not_found if the element is not present *)
|
||||
|
||||
val size : (_,_) t -> int
|
||||
|
||||
|
||||
val to_seq : ('a, 'b) t -> ('a * 'b) sequence
|
||||
|
||||
val to_list : ('a, 'b) t -> ('a * 'b) list
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ let rec _exists2 p a1 a2 i1 i2 ~len =
|
|||
|
||||
(* shuffle a[i...j[ using the given int random generator
|
||||
See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle *)
|
||||
let _shuffle _rand_int a i j =
|
||||
let _shuffle _rand_int a i j =
|
||||
for k = j-1 downto i+1 do
|
||||
let l = _rand_int (k+1) in
|
||||
let tmp = a.(l) in
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ let max (x : t) y =
|
|||
|
||||
let equal (a:float) b = a=b
|
||||
|
||||
let hash = Hashtbl.hash
|
||||
let hash = Hashtbl.hash
|
||||
let compare (a:float) b = Pervasives.compare a b
|
||||
|
||||
type 'a printer = Buffer.t -> 'a -> unit
|
||||
|
|
@ -71,9 +71,9 @@ type 'a random_gen = Random.State.t -> 'a
|
|||
let pp buf = Printf.bprintf buf "%f"
|
||||
let print fmt = Format.pp_print_float fmt
|
||||
|
||||
let sign (a:float) =
|
||||
if a < 0.0 then -1
|
||||
else if a > 0.0 then 1
|
||||
let sign (a:float) =
|
||||
if a < 0.0 then -1
|
||||
else if a > 0.0 then 1
|
||||
else 0
|
||||
|
||||
let fsign a =
|
||||
|
|
|
|||
|
|
@ -39,11 +39,11 @@ val nan : t
|
|||
val max_value : t
|
||||
val min_value : t
|
||||
|
||||
val max_finite_value : t
|
||||
val max_finite_value : t
|
||||
|
||||
val epsilon : float
|
||||
|
||||
val is_nan : t -> bool
|
||||
val is_nan : t -> bool
|
||||
|
||||
val add : t -> t -> t
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ val sub : t -> t -> t
|
|||
|
||||
val neg : t -> t
|
||||
|
||||
val abs : t -> t
|
||||
val abs : t -> t
|
||||
|
||||
val scale : t -> t -> t
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ val max : t -> t -> t
|
|||
|
||||
val equal : t -> t -> bool
|
||||
|
||||
val compare : float -> float -> int
|
||||
val compare : float -> float -> int
|
||||
|
||||
type 'a printer = Buffer.t -> 'a -> unit
|
||||
type 'a formatter = Format.formatter -> 'a -> unit
|
||||
|
|
@ -95,7 +95,7 @@ val sign_exn : t -> int
|
|||
val to_int : t -> int
|
||||
val of_int : int -> t
|
||||
|
||||
val to_string : t -> string
|
||||
val to_string : t -> string
|
||||
val of_string : string -> t
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ module type S = sig
|
|||
|
||||
val equal : 'a equal -> 'a t equal
|
||||
|
||||
val pp : key printer -> 'a printer -> 'a t printer
|
||||
val pp : key printer -> 'a printer -> 'a t printer
|
||||
|
||||
val print : key formatter -> 'a formatter -> 'a t formatter
|
||||
end
|
||||
|
|
@ -237,7 +237,7 @@ module Make(H : HashedType) : S with type key = H.t = struct
|
|||
(* no one will point to the new [t] *)
|
||||
let t = ref (Table (Table.copy tbl)) in
|
||||
t
|
||||
|
||||
|
||||
let iter t f =
|
||||
let tbl = reroot t in
|
||||
Table.iter f tbl
|
||||
|
|
@ -337,7 +337,7 @@ module Make(H : HashedType) : S with type key = H.t = struct
|
|||
Printf.bprintf buf "%a -> %a" pp_k k pp_v v
|
||||
);
|
||||
Buffer.add_string buf "}"
|
||||
|
||||
|
||||
let print pp_k pp_v fmt t =
|
||||
Format.pp_print_string fmt "{";
|
||||
let first = ref true in
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ module type S = sig
|
|||
|
||||
val equal : 'a equal -> 'a t equal
|
||||
|
||||
val pp : key printer -> 'a printer -> 'a t printer
|
||||
val pp : key printer -> 'a printer -> 'a t printer
|
||||
|
||||
val print : key formatter -> 'a formatter -> 'a t formatter
|
||||
end
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ type 'a ord = 'a -> 'a -> int
|
|||
type 'a printer = Buffer.t -> 'a -> unit
|
||||
type 'a formatter = Format.formatter -> 'a -> unit
|
||||
|
||||
type + 'a t = unit ->
|
||||
type + 'a t = unit ->
|
||||
[ `Nil
|
||||
| `Cons of 'a * 'a t
|
||||
]
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ type 'a formatter = Format.formatter -> 'a -> unit
|
|||
|
||||
(** {2 Basics} *)
|
||||
|
||||
type + 'a t = unit ->
|
||||
type + 'a t = unit ->
|
||||
[ `Nil
|
||||
| `Cons of 'a * 'a t
|
||||
]
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ val map_out : ('b -> 'b2) -> ('a, 's, 'b) t -> ('a, 's, 'b2) t
|
|||
|
||||
val nest : ('a, 's, 'b) t list -> ('a, 's list, 'b list) t
|
||||
(** runs all automata in parallel on the input.
|
||||
The state must be a list of the same length as the list of automata.
|
||||
The state must be a list of the same length as the list of automata.
|
||||
@raise Invalid_argument otherwise *)
|
||||
|
||||
val split : ('a, 's, 'b) t -> ('a, 's, ('b * 'b)) t
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ module Instance = struct
|
|||
_schedule q (fun () -> O.send a.transitions (s, i, s', os));
|
||||
List.iter
|
||||
(fun o -> _schedule q (fun () -> O.send a.o o))
|
||||
os
|
||||
os
|
||||
|
||||
let _receive a i =
|
||||
let first = Queue.is_empty _q in
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ module Instance : sig
|
|||
val create : f:('s, 'i, 'o) automaton -> 's -> ('s, 'i, 'o) t
|
||||
(** [create ~f init] creates an instance of [f] with initial state
|
||||
[init].
|
||||
|
||||
|
||||
@param f the transition function
|
||||
@param init the initial state *)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
of the type ['a]. Combinators, listed in the next section (e.g., {!list_}
|
||||
or {!pair}), are used to describe complicated structures from simpler
|
||||
ones.
|
||||
|
||||
|
||||
For instance, to serialize a value of type [(int * string) list]:
|
||||
|
||||
{[let bij = Bij.(list_ (pair int_ string_));;
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ let iter f set = PHashtbl.iter (fun x () -> f x) set
|
|||
|
||||
let fold f acc set = PHashtbl.fold (fun acc x () -> f acc x) acc set
|
||||
|
||||
let filter p set = PHashtbl.filter (fun x () -> p x) set
|
||||
let filter p set = PHashtbl.filter (fun x () -> p x) set
|
||||
|
||||
let to_seq set k = iter k set
|
||||
|
||||
|
|
|
|||
|
|
@ -415,7 +415,7 @@ let seq_head seq =
|
|||
try
|
||||
seq (fun x -> r := Some x; raise ExitHead); None
|
||||
with ExitHead -> !r
|
||||
|
||||
|
||||
(** Shortest path from the first node to the second one, according
|
||||
to the given (positive!) distance function. The path is reversed,
|
||||
ie, from the destination to the source. The int is the distance. *)
|
||||
|
|
@ -555,7 +555,7 @@ let product g1 g2 =
|
|||
Node ((v1,v2), (l1,l2), edges)
|
||||
and eq (v1,v2) (v1',v2') =
|
||||
g1.eq v1 v1' && g2.eq v2 v2'
|
||||
and hash (v1,v2) = ((g1.hash v1) * 65599) + g2.hash v2
|
||||
and hash (v1,v2) = ((g1.hash v1) * 65599) + g2.hash v2
|
||||
in
|
||||
{ eq; hash; force; }
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
(** This module serves to represent directed graphs in a lazy fashion. Such
|
||||
a graph is always accessed from a given initial node (so only connected
|
||||
components can be represented by a single value of type ('v,'e) t).
|
||||
|
||||
|
||||
The default equality considered here is [(=)], and the default hash
|
||||
function is {! Hashtbl.hash}. *)
|
||||
|
||||
|
|
@ -168,8 +168,8 @@ val dijkstra : ('id, 'v, 'e) t ->
|
|||
'id -> 'id ->
|
||||
float * ('id, 'e) path
|
||||
(** Shortest path from the first node to the second one, according
|
||||
to the given (positive!) distance function.
|
||||
[ignore] allows one to ignore some vertices during exploration.
|
||||
to the given (positive!) distance function.
|
||||
[ignore] allows one to ignore some vertices during exploration.
|
||||
This raises Not_found if no path could be found. *)
|
||||
|
||||
val is_dag : ('id, _, _) t -> 'id -> bool
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ module Box = struct
|
|||
w := max !w s.x;
|
||||
h := !h + s.y
|
||||
) a;
|
||||
{x= !w; y= !h;}
|
||||
{x= !w; y= !h;}
|
||||
|
||||
(* from a matrix [m] (line,column), return two arrays [lines] and [columns],
|
||||
with [col.(i)] being the start offset of column [i] and
|
||||
|
|
@ -244,7 +244,7 @@ module Box = struct
|
|||
| Frame t ->
|
||||
let {x;y} = size t in
|
||||
{ x=x+2; y=y+2; }
|
||||
| Pad (dim, b') ->
|
||||
| Pad (dim, b') ->
|
||||
let {x;y} = size b' in
|
||||
{ x=x+2*dim.x; y=y+2*dim.y; }
|
||||
| Grid (style,m) ->
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ val b : Box.t = <abstr>
|
|||
[|"c"; "hello world"|] |]])
|
||||
);;
|
||||
val b2 : PrintBox.Box.t = <abstr>
|
||||
# PrintBox.output stdout b2;;
|
||||
# PrintBox.output stdout b2;;
|
||||
+--------------------+
|
||||
|I love|a|bbb |
|
||||
|to |-+-----------|
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ module PArray = struct
|
|||
let get t i =
|
||||
match !t with
|
||||
| Array a -> a.(i)
|
||||
| Diff _ ->
|
||||
| Diff _ ->
|
||||
let a = reroot t in
|
||||
a.(i)
|
||||
|
||||
|
|
@ -157,7 +157,7 @@ module PBitVector = struct
|
|||
|
||||
(** Bitvector with all bits set to 0 *)
|
||||
let clear bv = make 5
|
||||
|
||||
|
||||
let set_true bv i = set bv i true
|
||||
let set_false bv i = set bv i false
|
||||
end
|
||||
|
|
@ -361,7 +361,7 @@ module Make(X : ID) : S with type elt = X.t = struct
|
|||
and ib' = find_root uf ib in
|
||||
if ia' = ib'
|
||||
then uf (* no change *)
|
||||
else
|
||||
else
|
||||
(* data associated to both representatives *)
|
||||
let data_a = get_data uf ia' in
|
||||
let data_b = get_data uf ib' in
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
(** This is largely inspired by https://ocaml.janestreet.com/?q=node/18 . *)
|
||||
|
||||
type t = {
|
||||
type t = {
|
||||
mutable id : unit ref;
|
||||
mutable store : unit -> unit;
|
||||
} (** The universal type *)
|
||||
|
|
@ -41,7 +41,7 @@ type 'a embedding = {
|
|||
|
||||
(** Create a new embedding. Values packed by a given embedding can
|
||||
only be unpacked by the same embedding. *)
|
||||
let embed () =
|
||||
let embed () =
|
||||
let id = ref () in (* unique ID of the embedding *)
|
||||
let r = ref None in (* place to store values *)
|
||||
let pack a = (* pack the 'a value into a new univ cell *)
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ module type S = sig
|
|||
|
||||
val find_all : pattern:pattern -> string -> int -> int gen
|
||||
(** Generator on all occurrences of the pattern *)
|
||||
|
||||
|
||||
val seq : pattern:pattern -> string -> int -> int sequence
|
||||
(** iterate on matching positions *)
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ module type S = sig
|
|||
|
||||
val find_all : pattern:pattern -> string -> int -> int gen
|
||||
(** Generator on all occurrences of the pattern *)
|
||||
|
||||
|
||||
val seq : pattern:pattern -> string -> int -> int sequence
|
||||
(** iterate on matching positions *)
|
||||
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ module Make(Str : STRING) = struct
|
|||
(* other transitions *)
|
||||
if j < limit then begin
|
||||
(* substitution *)
|
||||
add_transition i j (Upon (Any, i+1, j+1));
|
||||
add_transition i j (Upon (Any, i+1, j+1));
|
||||
(* deletion in indexed string *)
|
||||
add_transition i j (Upon (Any, i, j+1));
|
||||
(* addition to indexed string *)
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ A possible use of the index could be:
|
|||
{[
|
||||
open Batteries;;
|
||||
|
||||
let words = File.with_file_in "/usr/share/dict/english"
|
||||
let words = File.with_file_in "/usr/share/dict/english"
|
||||
(fun i -> IO.read_all i |> String.nsplit ~by:"\\n");;
|
||||
|
||||
let words = List.map (fun s->s,s) words;;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue