From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id D92E0BB91 for ; Sat, 23 Jul 2005 21:18:19 +0200 (CEST) Received: from 26.mail-out.ovh.net (26.mail-out.ovh.net [213.186.42.179]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j6NJIJ1o012870 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Sat, 23 Jul 2005 21:18:19 +0200 Received: (qmail 21843 invoked by uid 503); 23 Jul 2005 19:18:21 -0000 Received: (QMFILT: 1.0); 23 Jul 2005 19:18:21 -0000 Received: from b6.ovh.net (HELO mail155.ha.ovh.net) (213.186.33.56) by 26.mail-out.ovh.net with DES-CBC3-SHA encrypted SMTP; 23 Jul 2005 19:18:21 -0000 Received: from b0.ovh.net (HELO queue-out) (213.186.33.50) by b0.ovh.net with SMTP; 23 Jul 2005 19:18:23 -0000 Received: from mail155.ha.ovh.net (10.0.50.155) by mail155.ha.ovh.net with SMTP; 23 Jul 2005 19:18:21 -0000 Received: from b0.ovh.net (HELO queue-pre) (213.186.33.50) by b0.ovh.net with SMTP; 23 Jul 2005 19:18:20 -0000 Received: from ppp-69-228-157-203.dsl.scrm01.pacbell.net (HELO trantor.glondu.net) (postmaster%glondu.net@69.228.157.203) by ns0.ovh.net with SMTP; 23 Jul 2005 19:18:20 -0000 From: Stephane Glondu Organization: Crans To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] How to do this properly with OCaml? Date: Sat, 23 Jul 2005 12:18:12 -0700 User-Agent: KMail/1.7.1 Cc: Berke Durak References: <200507230936.47352.Stephane.Glondu@crans.org> <20050723182709.GA4076@ara.zapto.org> In-Reply-To: <20050723182709.GA4076@ara.zapto.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200507231218.13166.Stephane.Glondu@crans.org> X-Ovh-Remote: 69.228.157.203 (ppp-69-228-157-203.dsl.scrm01.pacbell.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-Miltered: at concorde with ID 42E297FB.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 berke:01 durak:01 heap:01 heap:01 sig:01 val:01 val:01 struct:01 wrote:01 cleanly:01 int:01 int:01 match:02 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.9 required=5.0 tests=FORGED_RCVD_HELO, RCVD_IN_BL_SPAMCOP_NET autolearn=disabled version=3.0.3 On Saturday 23 July 2005 11:27, Berke Durak wrote: > That was my point. You could cleanly initialize your heap with that > "any" value. I was thinking about sth you could adjust to your purpose: module type HEAP = sig type 'a t val create : int -> 'a t val set : 'a t -> int -> 'a -> unit val get : 'a t -> int -> 'a end module Heap : HEAP = struct type 'a cell = Fill of 'a array | Empty of int type 'a t = 'a cell ref let create n = ref (Empty n) let set h i e = match !h with Empty n -> h := Fill (Array.create n e) | Fill a -> a.(i) <- e let get h n = match !h with Empty _ -> raise Not_found | Fill a -> a.(n) end No Obj.magic here. Does this suit you? Stephane Glondu.