Some functions I could not rewrite using core
Francois Berenger
francois.berenger.working at gmail.com
Mon Nov 12 05:49:50 GMT 2012
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/20121111/52392b0f/attachment.html>
More information about the core
mailing list