[
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: | 2006-07-26 (02:18) |
From: | oleg@p... |
Subject: | generic Hashtbl.to_array |
I wonder about the following solution. At least it traverses the hashtable exactly once (and it does not ignore the result of the fold). let to_array9 t = let Some (a,_) = Hashtbl.fold (fun k v seed -> match seed with Some (a,i) -> a.(i) <- (k,v); Some (a,i+1) | None -> let a = Array.make (Hashtbl.length t) (k,v) in Some (a,1)) t None in a ;;