Version française
Home     About     Download     Resources     Contact us    
Browse thread
Pervasives.compare: slow?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Judicael Courant <Judicael.Courant@l...>
Subject: Re: Pervasives.compare: slow?
On 19 jun, David Monniaux wrote:
> Perhaps including a String.compare function would be easier.
> 

Adding a function "compare" to the String module would be a very good
idea indeed. May I suggest that a "type t = string" be added also ?

Hence, one could write

module StringSet = Set.Make(String)

module StringMap = Map.Make(String)

instead of

module StringSet =
  Set.Make(struct
             type t = string
             let compare = compare
           end)

module StringMap =
  Map.Make(struct
             type t = string
             let compare = compare
           end)



(This could be done for modules Char, Int32, Int64 and NativeInt also)

By the way, one also could add functions "equal" and "hash" to these
modules...


Judicaël.
-- 
Judicael.Courant@lri.fr, http://www.lri.fr/~jcourant/
(+33) (0)1 69 15 64 85
"Montre moi des morceaux de ton monde, et je te montrerai le mien"
Tim, matricule #929, condamné à mort.
http://rozenn.picard.free.fr/tim.html