<br><br>On Monday, November 12, 2012 4:38:14 PM UTC+9, David House wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">hashtbl_of is called of_alist or of_alist_exn. (Note that because this
<br>is a creator function, you have to either use Foo.Table.of_alist, or
<br>Hashtbl.Poly.of_alist -- see my email last week.)
<br></blockquote><div><br>I think I will tap into Caml.Hashtbl.<br>I have too much code relying on them that I don't have the courage to port<br>today.<br><br></div><blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
<br>I don't think we have a function that does reverse_binding (I can't
<br>recall ever needing it). But you should be able to write it using the
<br>other functions in Hashtbl. What precisely are you struggling with?
<br></blockquote><div><br>Something not very interesting to troubleshoot.<br>Also, I don't have the courage today so Caml.Hashtbl will save me. ;)<br> <br></div><blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
<br>On Mon, Nov 12, 2012 at 5:49 AM, Francois Berenger
<br><<a href="javascript:" target="_blank" gdf-obfuscated-mailto="f4zmUquoEmUJ">francois.ber...@<wbr>gmail.com</a>> wrote:
<br>> Hello,
<br>>
<br>> I'm stuck with these (standard OCaml code I'd like t
<br>> make core-compatible, or know the equivalent functions
<br>> in Core):
<br>>
<br>> module A = Array
<br>> module F = Filename
<br>> module HT = Hashtbl
<br>> module L = List
<br>> module Mar = Marshal
<br>> module P = Printf
<br>> module RNG = Random
<br>> module S = String
<br>>
<br>> (* create a Hashtbl from a list of key-value pairs *)
<br>> let hashtbl_of key_value_pairs =
<br>> let res = HT.create (L.length key_value_pairs) in
<br>> L.iter
<br>> (fun (k, v) -> HT.add res k v)
<br>> key_value_pairs;
<br>> res
<br>>
<br>> (* transform a Hashtbl of key->value into a Hashtbl of value->key *)
<br>> let reverse_binding ht =
<br>> let res = HT.create (HT.length ht) in
<br>> HT.iter
<br>> (fun k v -> HT.add res v k)
<br>> ht;
<br>> res
<br>>
<br>> Thanks,
<br>> F.
<br>>
<br></blockquote>