Henri DF <henri.dubois-ferriere@xxxxxxx> writes:
> hi list,
> i find myself often having to do [1]
>
> if Hashtbl.mem h k then
> let v = Hashtbl.find h k in ... do stg with k here
try this :
try
let v = Hashtbl.find h k in ... do stg with k here
with
| Not_found -> ()
it's more efficient.
>
> I was wondering if it would be worth having a Hashtbl.find_opt, which
> returns Some v if there is a binding, None otherwise.
Well, then
let find_opt h k =
try
Some (Hashtbl.find h k)
with
| Not_found -> None
not sure it is so useful, but well, it might be.
We could also have some use for findk :
let findk h k found not_found =
try
found (Hashtbl.find h k)
with
| Not_found -> not_found ()
But there is not so many use for the continuation way of writing things.
[...]
--
Rémi Vanicat
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
|