From: Goswin von Brederlow <goswin-v-b@web.de>
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?
Date: Mon, 20 Apr 2009 07:29:44 +0200 [thread overview]
Message-ID: <87y6tvvqnr.fsf@frosties.localdomain> (raw)
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)")
Arkady Andrukonis <grazingcows@yahoo.com> 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
prev parent reply other threads:[~2009-04-20 5:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-17 22:02 Arkady Andrukonis
2009-04-18 16:16 ` [Caml-list] " Jon Harrop
2009-04-20 5:29 ` Goswin von Brederlow [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y6tvvqnr.fsf@frosties.localdomain \
--to=goswin-v-b@web.de \
--cc=caml-list@yquem.inria.fr \
--cc=grazingcows@yahoo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).