On Nov 16, 2005, at 5:25 PM, Kevin Toppenberg wrote:

I need to break away here.  But I need to come up with a recursive
function that will be able to construct this complete reference from
left to right.  I will have to pass each child iteration the reference
so far, as well as the information needed to construct the subscript
nodes.  Then, this iterative process will need to be able to cycle
through all the possibilities.

I think this is a basic problem.  But I need to rest my brain before I
can code it.  Reiterative stuff can be a headache!

Thanks for reading/listening.  Any input is always appreciated.


Really, all you're doing is traversing a tree. I think the simplest and most elegant approach is to write your code recursively. Alternatively, you can think of the DA array (or its equivalent) as a stack. Iterate through all the DA values until you reach the end (of the deepest subfile). When you do, move up to DA(1) and advance it to the next subentry. Move down a level and run through every DA again Repeat until DA(1) cannot be advanced and then advance DA(2), then for each DA(1) below that subrecord, run through every DA. Keep going until you can't move DA(2) any further, advance DA(3), etc.

But this is just unfolding the recursion. An explicitly recursive solution is easier to follow (and code).

===
Gregory Woodhouse

"The whole of science is nothing more than a refinement
 of everyday thinking."  -- Albert Einstein



Reply via email to