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.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 59899BBAF for ; Mon, 20 Apr 2009 07:30:11 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtIBAHOl60nZSMDdi2dsb2JhbACBTotWiRcBAQEKCwoHDwW0VIN9Bg X-IronPort-AV: E=Sophos;i="4.40,215,1238968800"; d="scan'208";a="24836307" Received: from fmmailgate01.web.de ([217.72.192.221]) by mail2-smtp-roc.national.inria.fr with ESMTP; 20 Apr 2009 07:30:11 +0200 Received: from smtp07.web.de (fmsmtp07.dlan.cinetic.de [172.20.5.215]) by fmmailgate01.web.de (Postfix) with ESMTP id 372F410046409; Mon, 20 Apr 2009 07:29:45 +0200 (CEST) Received: from [78.43.226.218] (helo=frosties.localdomain) by smtp07.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #277) id 1Lvm4f-0003gd-00; Mon, 20 Apr 2009 07:29:45 +0200 Received: from mrvn by frosties.localdomain with local (Exim 4.69) (envelope-from ) id 1Lvm4e-0005Yd-PK; Mon, 20 Apr 2009 07:29:44 +0200 From: Goswin von Brederlow To: grazingcows@yahoo.com Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] what is the "best" block structure to code a tree structure? References: <323491.43292.qm@web63003.mail.re1.yahoo.com> Date: Mon, 20 Apr 2009 07:29:44 +0200 In-Reply-To: <323491.43292.qm@web63003.mail.re1.yahoo.com> (Arkady Andrukonis's message of "Fri, 17 Apr 2009 15:02:43 -0700 (PDT)") Message-ID: <87y6tvvqnr.fsf@frosties.localdomain> User-Agent: Gnus/5.110006 (No Gnus v0.6) XEmacs/21.4.21 (linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: goswin-v-b@web.de X-Sender: goswin-v-b@web.de X-Provags-ID: V01U2FsdGVkX182TaWjmzKiud0nZslCtLrNHiVu7iZn1XF15EJJ 09pPHjd2ksVrAEMvjicktAxhs+qvhdptWplyEohlUFTqeko0Kn zbaJvXwr0= X-Spam: no; 0.00; nodes:01 ocaml:01 ocaml:01 node:01 node:01 numbering:01 10,:98 20,:98 10,:98 20,:98 ......:98 mfg:98 imho:01 caml-list:01 int:01 Arkady Andrukonis writes: > Hi, > > I would like to find the easiest block structure to represent nested leaves and nodes in a tree structure that works for OCaml. In Common Lisp there is the help of indentation, but I haven't found one for OCaml. > > We have one parent node composed of one leaf and a nested node which has another node with two leaves and a leaf (of the second node). To help illustrate the level of depth we can use numbers 10, 20, and 30. > (* > ------------------- > our type definition > ------------------- > *) > # type tree = Node of tree * tree | Leaf of int;; > (* > ------------ > and our tree > ------------ > *) > # Node ((Leaf 10), (Node ((Node ((Leaf 20),(Leaf 30))), Leaf 30)));; > -: tree = Node (Leaf 10, Node (Node (Leaf 20, Leaf 30), Leaf 30)) Node ((Leaf 10), ......(Node .........((Node .............((Leaf 20), ..............(Leaf 30))), ..........Leaf 30)));; How about that? I don't get your numbering though. The 20 is too deep and the second 30 not deep enough imho. Mfg Goswin