Commits

camlspotter committed 976d2b1

added Hashtbl.concat

Comments (0)

Files changed (2)

       let v = f k in
       Hashtbl.replace tbl k v;
       v
+
+let concat tbls =
+  let t = Hashtbl.create 101 in (* CR jfuruse: fixed *)
+  List.iter (Hashtbl.iter (Hashtbl.add t)) tbls;
+  t
 val find_or_add  : ('a -> 'b) -> ('a, 'b) Hashtbl.t -> 'a -> 'b
 val alter        : ('a, 'b) Hashtbl.t -> 'a -> ('b option -> 'b option) -> unit
 val memoize      : ('a, 'b) Hashtbl.t -> ('a -> 'b) -> 'a -> 'b
+
+val concat : ('a, 'b) Hashtbl.t list -> ('a, 'b) Hashtbl.t
+(** Keys bound more than once in the tables are multiply bound in the result.
+    The order of adding key-value pair is the order of the table list.
+*)