citromatik has asked for the wisdom of the Perl Monks concerning the following question:
Obtain a tree-like structure like this:my @list1 = qw/Truck Car Byke/; my @list2 = qw/Truck Car Scooter/; my @list3 = qw/Truck Trailer Skates/;
Truck |_____ Car | |_______Byke | |_______Scooter | |_____Trailer |_______Skates
Maybe implementing the tree as a hash of hash refs would be a good solution:
{'Truck' => { 'Car' => { 'Byke' => ?, 'Scooter' => ? }, 'Trailer' => { 'Skates' => ? } }
But every attemp to implement an algorithm to make the conversion ends with a too obfuscated code involving too much recursion. (Well, surely, the obfuscation comes from me)
Maybe I'm missing a simpler solution. Any idea on how to solve this would be highly appreciated
Thank you very much in advance
citromatik
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: trees of word lists
by GrandFather (Saint) on Jan 22, 2009 at 20:02 UTC | |
by lostjimmy (Chaplain) on Jan 22, 2009 at 20:18 UTC | |
by MidLifeXis (Monsignor) on Jan 23, 2009 at 19:39 UTC | |
|
Re: trees of word lists
by apl (Monsignor) on Jan 22, 2009 at 18:44 UTC | |
|
Re: trees of word lists
by zentara (Cardinal) on Jan 22, 2009 at 19:52 UTC | |
|
Re: trees of word lists
by MidLifeXis (Monsignor) on Jan 22, 2009 at 18:38 UTC | |
|
Re: trees of word lists
by JavaFan (Canon) on Jan 22, 2009 at 19:52 UTC | |
by Limbic~Region (Chancellor) on Jan 22, 2009 at 20:17 UTC |