Browse thread
AW: [Caml-list] generic Hashtbl.to_array
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Tom <tom.primozic@g...> |
| Subject: | Re: [Caml-list] generic Hashtbl.to_array |
The dirtiest solution:
let to_array t =
let a = Array.make (Hashtbl.length t) (Obj.magic 0) in
ignore
(Hashtbl.fold (fun k v i -> a.(i) <- (k, v); i + 1) t 0) ;
a