Some functions I could not rewrite using core
Francois Berenger
francois.berenger.working at gmail.com
Mon Nov 12 08:32:27 GMT 2012
On Monday, November 12, 2012 4:38:14 PM UTC+9, David House wrote:
>
> hashtbl_of is called of_alist or of_alist_exn. (Note that because this
> is a creator function, you have to either use Foo.Table.of_alist, or
> Hashtbl.Poly.of_alist -- see my email last week.)
>
I think I will tap into Caml.Hashtbl.
I have too much code relying on them that I don't have the courage to port
today.
> I don't think we have a function that does reverse_binding (I can't
> recall ever needing it). But you should be able to write it using the
> other functions in Hashtbl. What precisely are you struggling with?
>
Something not very interesting to troubleshoot.
Also, I don't have the courage today so Caml.Hashtbl will save me. ;)
>
> On Mon, Nov 12, 2012 at 5:49 AM, Francois Berenger
> <francois.ber... at gmail.com <javascript:>> wrote:
> > Hello,
> >
> > I'm stuck with these (standard OCaml code I'd like t
> > make core-compatible, or know the equivalent functions
> > in Core):
> >
> > module A = Array
> > module F = Filename
> > module HT = Hashtbl
> > module L = List
> > module Mar = Marshal
> > module P = Printf
> > module RNG = Random
> > module S = String
> >
> > (* create a Hashtbl from a list of key-value pairs *)
> > let hashtbl_of key_value_pairs =
> > let res = HT.create (L.length key_value_pairs) in
> > L.iter
> > (fun (k, v) -> HT.add res k v)
> > key_value_pairs;
> > res
> >
> > (* transform a Hashtbl of key->value into a Hashtbl of value->key *)
> > let reverse_binding ht =
> > let res = HT.create (HT.length ht) in
> > HT.iter
> > (fun k v -> HT.add res v k)
> > ht;
> > res
> >
> > Thanks,
> > F.
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ocaml.org/pipermail/core/attachments/20121112/02a1e780/attachment-0001.html>
More information about the core
mailing list