Reply to comment

even faster ...

If you specialize the hashtbl...

 
module OCAMLHashtbl = Hashtbl

open ExtLib ;;

[...]

let hash_unique2_mono l =
  let module StringHash = OCAMLHashtbl.Make(
    struct
      type t = string
      let equal (x : string) (y : string) = x = y
      let hash t = Hashtbl.hash t
    end)
  in
  let h = StringHash.create (List.length l) in
  let rec add acc =
    function
      | hd :: tl when not (StringHash.mem h hd) ->
          StringHash.add h hd ();
          add (hd :: acc) tl
      | _ :: tl ->
          add acc tl
      | [] ->
          acc
  in
  add [] l

Reply

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
u
E
G
3
2
R
Enter the code without spaces and pay attention to upper/lower case.