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 UAA29676; Fri, 23 Apr 2004 20:06:55 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA29782 for ; Fri, 23 Apr 2004 20:06:54 +0200 (MET DST) Received: from aomori.annexia.org (annexia.force9.co.uk [212.56.101.183]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i3NI6pYM016827 for ; Fri, 23 Apr 2004 20:06:52 +0200 Received: from rich by aomori.annexia.org with local (Exim 3.36 #1 (Debian)) id 1BH54c-0006Mj-00 for ; Fri, 23 Apr 2004 19:06:50 +0100 Date: Fri, 23 Apr 2004 19:06:50 +0100 Cc: OCaml List Subject: Re: [Caml-list] how to define a property list Message-ID: <20040423180650.GB24360@redhat.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.5.1+cvs20040105i From: Richard Jones X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 2004:99 bauer:01 val:01 generic:01 autoconf:01 automake:01 compiles:01 rpms:01 ltd:98 0200,:01 nodes:02 node:02 node:02 tree:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, Apr 23, 2004 at 07:56:54PM +0200, Christoph Bauer wrote: > Hi List, > > I want to create a tree. This tree should be a very simple accessible > for algorithms and easy to understand. The nodes in the tree can have > different properties of different types. 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 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. Rich. -- Richard Jones. http://www.annexia.org/ http://www.j-london.com/ Merjis Ltd. http://www.merjis.com/ - improving website return on investment MAKE+ is a sane replacement for GNU autoconf/automake. One script compiles, RPMs, pkgs etc. Linux, BSD, Solaris. http://www.annexia.org/freeware/makeplus/ ------------------- 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