What is the simplest logic which will construct a tree such as that
below. You may use any data representation you like for anything. I happen 
to be using an SQL database which I read into a hash of (id => array of 
children), but this isn't important.

One has to remember things like "at level X, are there any more children?" 
and "is this the last child of this parent?"

Extra credits for generating something that looks nice in HTML, as opposed 
to straight ascii. FTR, the output below was generated by tree(1).

.
|-- Documents
|   |-- Paradox
|   |   |-- Samples
|   |   `-- Tutorial
|   `-- macros
|       |-- pr
|       |-- qp
|       `-- wp
|-- GNUstep
|   |-- Defaults
|   `-- Library
|       |-- Icons
|       `-- WindowMaker
|           |-- Backgrounds
|           |-- IconSets
|           |-- Pixmaps
|           |-- SoundSets
|           |-- Sounds
|           |-- Styles
|           `-- Themes
|               `-- DirtyPair.themed
`-- a2map

(etc etc)

S.

-- 
Shevek
I am the Borg.

sub AUTOLOAD{my$i=$AUTOLOAD;my$x=shift;$i=~s/^.*://;print"$x\n";eval
qq{*$AUTOLOAD=sub{my\$x=shift;return unless \$x%$i;&{$x}(\$x);};};}

foreach my $i (3..65535) { &{'2'}($i); }


Reply via email to