From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA01280; Fri, 23 Apr 2004 20:55:27 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA01278 for ; Fri, 23 Apr 2004 20:55:26 +0200 (MET DST) Received: from mail-in-02.arcor-online.net (mail-in-02.arcor-online.net [151.189.21.42]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i3NItPjq012314 for ; Fri, 23 Apr 2004 20:55:25 +0200 Received: from diebuntekuh.de (dialin-212-144-211-185.arcor-ip.net [212.144.211.185]) by mail-in-02.arcor-online.net (Postfix) with ESMTP id 725ACB86FD3 for ; Fri, 23 Apr 2004 20:55:24 +0200 (CEST) Received: by diebuntekuh.de (Postfix, from userid 500) id EA3C8608EC0; Fri, 23 Apr 2004 21:02:01 +0200 (CEST) To: OCaml List Subject: Re: [Caml-list] how to define a property list References: <20040423180650.GB24360@redhat.com> From: Christoph Bauer Date: Fri, 23 Apr 2004 21:02:01 +0200 In-Reply-To: <20040423180650.GB24360@redhat.com> (Richard Jones's message of "Fri, 23 Apr 2004 19:06:50 +0100") Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 bauer:01 bauer:01 val:01 generic:01 3..:99 expr:01 .25:99 shifted:01 int:01 node:02 node:02 tree:02 tree:02 string:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, > Could well be missing the point entirely here, but what about: > > type 'a tree = Leaf of 'a | Node of 'a tree * 'a * 'a tree > > and then use something simple like an assoc-list for storing the > properties, so your final type would be: > > (string * string) list tree ^^^^^^ this could be a int or a string in the same tree! > eg: > > let t = Node (Leaf [], [ "prop1", "value1" ], Leaf []);; > val t : (string * string) list tree = (* ... *) > > This seems to separate out the 'treeness' from what is stored at each > node, so you can use generic algorithms to operate over the tree. Of course I could convert my integer to strings (and back), but this solutions isn't so satisfying Regards, Christoph Bauer -- beginfig(1)u=3cm;draw fullcircle scaled 2u;x0=x1=y1=x2=y3=0;-y0=y2=x3=1u; filldraw z0..{left}z1{left}..z2{curl 1}..z3..z0..cycle;def t(expr p)=fullcircle scaled .25u shifted(0,p*u);enddef;unfill t(.5);fill t(-.5);endfig;bye ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners