New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Hashtbl.adjust #5220
Comments
Comment author: Christoph Bauer The type is Hashtbl.adjust : ('a, 'b) Hashtbl.t -> 'a -> ('b -> 'b) -> unit |
Comment author: Christoph Bauer Here an implementation: let adjust h key f = |
This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc. |
This is a sensible feature request, but several libraries out there call it |
Original bug ID: 5220
Reporter: Christoph Bauer
Status: acknowledged (set by @damiendoligez on 2011-05-17T14:17:55Z)
Resolution: open
Priority: normal
Severity: feature
Version: 3.11.2
Category: standard library
Related to: #7309
Monitored by: "Pascal Cuoq" "Julien Signoles" @hcarty
Bug description
If you have a Hashtable of counters and you want to increment one, you have to do it that way:
Hashtbl.replace t key (1+Hashtbl.find t key)
There could be a more efficient way to do this with a helper function
Hashtbl.adjust t key f
with the type
Hashtbl.adjust : ('a, 'b) Hashtbl.t -> 'a -> ('b -> 'b)
Hashtbl.adjust looks up the key in t and replaces it associated value b with (f b). It might raise Not_found.
I guess it's not possible to implement this function in BatHashtbl.
The text was updated successfully, but these errors were encountered: