| Anonymous | Login | Signup for a new account | 2013-05-24 14:10 CEST | ![]() |
| Main | My View | View Issues | Change Log | Roadmap |
| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | ||||||
| 0004103 | OCaml | OCaml general | public | 2006-09-07 19:19 | 2006-09-11 11:20 | ||||||
| Reporter | acone | ||||||||||
| Assigned To | |||||||||||
| Priority | normal | Severity | feature | Reproducibility | N/A | ||||||
| Status | acknowledged | Resolution | open | ||||||||
| Platform | OS | OS Version | |||||||||
| Product Version | 3.09.2 | ||||||||||
| Target Version | Fixed in Version | ||||||||||
| Summary | 0004103: Hashtbl.arbitrary | ||||||||||
| Description | Hashtbl.arbitrary : ('a, 'b) Hashtbl.t -> ('a * 'b) Returns an arbitrary (i.e. quickest to access) key-value pair in a hashtable, or raises Not_found if the hashtable is empty. This would be useful for starting a function that finds the key with the maximum value: let hashmax gt t = let maxfolder key value (maxkey, maxval) = if gt key maxkey then (key, value) else (maxkey, maxval) in let startpair = Hashtbl.arbitrary t in Hashtbl.fold maxfolder t startpair | ||||||||||
| Additional Information | The code for such a function might look like: let arbitrary h = let d = h.data in let len = Array.length d let rec loop i = if i == len then raise Not_found else (match d.(i) with Empty -> loop(i+1) | Cons(key, val, _) -> (key, val)) in loop 0 | ||||||||||
| Tags | No tags attached. | ||||||||||
| Attached Files | |||||||||||
Notes |
|
|
(0003766) acone (reporter) 2006-09-07 19:20 |
I accidentally labeled this as caml-light. It concerns caml genereally. |
Issue History |
|||
| Date Modified | Username | Field | Change |
| 2006-09-07 19:19 | acone | New Issue | |
| 2006-09-07 19:20 | acone | Note Added: 0003766 | |
| 2006-09-08 10:20 | ertai | Category | Caml-light => OCaml general |
| 2006-09-11 11:20 | doligez | Status | new => acknowledged |
| Copyright © 2000 - 2011 MantisBT Group |