Have you seen http://www.jsoftware.com/jwiki/Essays/Tree%20Display ?



----- Original Message -----
From: Kip Murray <[email protected]>
Date: Wednesday, August 19, 2009 11:33
Subject: Re: [Jprogramming] Box tree
To: Programming forum <[email protected]>

> Answering queries from Raul, here are more example tree 
> displays. Lovingly 
> created by hand, these are in organization chart style.  It 
> might be better to 
> rotate them 90 degrees counterclockwise so they open to the 
> right instead of 
> down.  THERE WAS AN ERROR IN THE ORIGINAL POST, see the 
> note following the 
> examples here.
> 
> Array structure is indicated with '.' , box structure with 'o', 
> but leaves are 
> not shown as trees.  Levels are in brackets.
> 
> Can you write a verb that produces a bare tree display -- dots 
> and ohs and 
> connectors but no levels, leaves, or array name?  We can 
> add those later.
> 
> 
>     ]u =: i.&.>1+i.3
> +-+---+-----+
> |0|0 1|0 1 2|
> +-+---+-----+
> 
>                               u
>                       ________._[1]____
>                      |        |        |
>                      |        |        |
>                      o [0]    o [0]    o [0]
>                      0       0 1     0 1 2
> 
> 
>     ]v =: i.&.>1+i. 2 2
> +-----+-------+
> |0    |0 1    |
> +-----+-------+
> |0 1 2|0 1 2 3|
> +-----+-------+
> 
>                                      v
>                        ______________._[1]___________
>                       |                              |
>                       |                              |
>               ________._[1]____              ________._[1]____
>              |                 |            |                 |
>              |                 |            |                 |
>              o [0]             o [0]        o [0]             o [0]
>              0                0 1         0 1 2            0 1 2 3
> 
> 
>     ]w =: i.&.>1+i. 2 2 2
> +-------------+---------------+
> |0            |0 1            |
> +-------------+---------------+
> |0 1 2        |0 1 2 
> 3        |
> +-------------+---------------+
> 
> +-------------+---------------+
> |0 1 2 3 4    |0 1 2 3 4 5    |
> +-------------+---------------+
> |0 1 2 3 4 5 6|0 1 2 3 4 5 6 7|
> +-------------+---------------+
> 
>                                       w
>                   ____________________._[1]_________________
>                  |                                          |
>                  |                                          |
>          
> ________._[1]_____                       __________._[1]_____
>         
> |                  |                     |                    |
>         
> |                  |                     |                    |
>   ______._[1]__        
> ____._[1]__           ____._[1]_           ___._[1]_
> |             |      |           |         |          |         |         |
> |             |      |           |         |          |         |         |
> o [0]         o 
> [0]  o [0]       o 
> [0]     o [0]      
> o [0]     o [0]     o [0]
> 0            0 1   0 1 2      0 1 2 3  0 1 2 ...  0 1 2 ... 0 1 2 ... 0 1 2 
> ...
> 
> 
> See the original post (below) for an example of more complicated 
> box structure. 
>      THE TREE DISPLAY THERE IS IN ERROR, 
> because one of the boxes contained a 
> list of boxes, and that list should have been shown with a '.' 
> just beneath the 
> 'o' where where the [2] marker is, with the rest of that side 
> emanating from the 
> '.'.  The correct display of the list is like that in the 
> first example above. 
> In a later post I will correct the display, changing to the now 
> preferred 
> organization chart style.
> 
> 
> Kip Murray wrote:
> > Here is an array from the L: Level At page in the 
> Dictionary.  Below is a tree 
> > display representing the array and showing levels (square 
> brackets) and leaves.
> > 
> > Your mission, should you decide to accept it, is to write a 
> verb boxtree such 
> > that "boxtree array" produces as much of the tree display as 
> is practical.
> > 
> > To begin with, just produce the bare tree.  Each 'o' 
> represents a box.  We can 
> > work on adding level markers, leaves, and the name of the 
> array later.
> > 
> > I hope the array and tree display well in your email 
> reader.  I sent them in 
> > Unicode Courier New as defined by Microsoft's WordPad and 
> transformed by 
> > Thunderbird (email program).
> > 
> > Kip
> > 
> >       ] y=: (<<2 3 
> 4),<(5 6 ; <<i. 2 3)
> > +-------+-------------+
> > |+-----+|+---+-------+|
> > ||2 3 4|||5 6|+-----+||
> > |+-----+||   ||0 1 2|||
> > |       ||   ||3 4 5|||
> > |       ||   |+-----+||
> > |       |+---+-------+|
> > +-------+-------------+
> > 
> > 
> >                      y
> >                      .  [3]
> >                     / \
> >                    /   \
> >                   /     \
> >                  /       \
> >                 /         \
> >                /           \
> >               /             \
> >          [1] 
> o               o  [2]
> >              |              / \
> >              |             /   \
> >              |            /     \
> >              |           /       \
> >          [0] 
> o      [0] 
> o         o  [1]
> >            2 3 4       5 6        |
> >                                   |
> >                                   |
> >                                   o  [0]
> >                                 0 1 2
> >                                 3 4 5
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to