From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=AWL,MAILTO_TO_SPAM_ADDR autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 1EC59BC6C for ; Sat, 4 Aug 2007 14:23:25 +0200 (CEST) Received: from 30.mail-out.ovh.net (30.mail-out.ovh.net [213.186.62.213]) by discorde.inria.fr (8.13.6/8.13.6) with SMTP id l74CNO0A019992 for ; Sat, 4 Aug 2007 14:23:24 +0200 Received: (qmail 11133 invoked by uid 503); 4 Aug 2007 12:23:48 -0000 Received: (QMFILT: 1.0); 04 Aug 2007 12:23:48 -0000 Received: from b7.ovh.net (HELO mail93.ha.ovh.net) (213.186.33.57) by 30.mail-out.ovh.net with SMTP; 4 Aug 2007 12:23:48 -0000 Received: from b0.ovh.net (HELO queue-out) (213.186.33.50) by b0.ovh.net with SMTP; 4 Aug 2007 12:23:33 -0000 Received: from vil93-4-82-227-140-227.fbx.proxad.net (HELO ?192.168.1.222?) (82.227.140.227) by ns0.ovh.net with SMTP; 4 Aug 2007 12:23:31 -0000 Message-ID: <46B46FB3.3090606@philippewang.info> Date: Sat, 04 Aug 2007 14:23:15 +0200 From: Philippe Wang User-Agent: Thunderbird 1.5.0.12 (Macintosh/20070509) MIME-Version: 1.0 To: skaller Cc: tmp123@menta.net, ocaml ml Subject: Re: [Caml-list] Sorted list References: <46B4485B.7040406@menta.net> <46B454ED.700@philippewang.info> <1186226538.14440.105.camel@rosella.wigram> In-Reply-To: <1186226538.14440.105.camel@rosella.wigram> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Ovh-Remote: 82.227.140.227 (vil93-4-82-227-140-227.fbx.proxad.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-Miltered: at discorde with ID 46B46FBC.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; 0200,:01 elt:01 sugestion:01 functor:01 sig:01 val:01 struct:01 elt:01 val:01 abstr:01 bool:01 bool:01 subset:01 iter:01 abstr:01 skaller wrote: > On Sat, 2007-08-04 at 12:29 +0200, Philippe Wang wrote: > >> tmp123@menta.net wrote: >> > > >>> Of the standard modules, the most similar seems "set", because allows >>> insertion and has the funcion "min_elt". However, the problem is, if >>> two timers have the same time, addition of the second one removes the >>> first. >>> >>> Please, has someone any sugestion? >>> >>> Thanks a lot. >>> >> Hello, >> >> Let's remind that Set.Make is a functor that takes a module with >> sig >> type t >> val compare : t -> t -> int >> end >> >> If you simply give him a compare function that never returns 0, then you >> can add multiple elements that are the same. >> > > You cannot do that! compare function must be a total order. > Why not ? Objective Caml version 3.10.0 # include Set.Make(struct type t = int let compare : t -> t -> int = fun a b -> match compare a b with 0 -> 1 | n -> n end);; type elt = int type t val empty : t = val is_empty : t -> bool = val mem : elt -> t -> bool = val add : elt -> t -> t = val singleton : elt -> t = val remove : elt -> t -> t = val union : t -> t -> t = val inter : t -> t -> t = val diff : t -> t -> t = val compare : t -> t -> int = val equal : t -> t -> bool = val subset : t -> t -> bool = val iter : (elt -> unit) -> t -> unit = val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a = val for_all : (elt -> bool) -> t -> bool = val exists : (elt -> bool) -> t -> bool = val filter : (elt -> bool) -> t -> t = val partition : (elt -> bool) -> t -> t * t = val cardinal : t -> int = val elements : t -> elt list = val min_elt : t -> elt = val max_elt : t -> elt = val choose : t -> elt = val split : elt -> t -> t * bool * t = # let x = empty ;; val x : t = # let x = add 1 x ;; val x : t = # let x = add 1 x ;; val x : t = # let x = add 1 x ;; val x : t = # let x = add 42 x ;; val x : t = # let x = add 45 x ;; val x : t = # elements x ;; - : elt list = [1; 1; 1; 42; 45] It works ! ... Or did I miss something ?