The Directory Walker revisited

Geoff Canyon gcanyon at inspiredlogic.com
Sat Sep 6 13:41:00 EDT 2003


253-4121
On Saturday, September 6, 2003, at 05:19  AM, Wouter wrote:

> If I may ask just a little practical question to be able to completely 
> understand  your  explanation :
>
> A  folder "a" contains 3 folders "a1","b1","c1" and each of this 
> folders contains another folder :  "a1" contains folder "a2", folder 
> "b1" contains folder "b2" and folder "c1" contains folder "c2".
>
> How many times your recursive handler is recursing?

So if I understand you, this is the structure we're talking about:

a
|-a1
| |-a2
|-b1
| |-b2
|-c1
| |-c2

By the way, that's the actual order they would be processed in by the 
recursion routines we've been discussing.

So the recursion routine (RR for short) gets called for a. In 
processing a, RR would come to a1, and process that. In processing a1, 
RR would come to a2, and process that.

At this point we're three recursions deep: RR is processing a, a1, and 
a2.

Now RR finishes a2, so we're only two recursions deep: a and a1. RR 
finishes a2, and we're only one level deep.

RR moves on to b1, and now we're two deep. RR starts on b2, and we're 
three deep. RR finishes b2, finishes b1, and we're one level deep again.

RR moves on to c1, and now we're two deep. RR starts on c2, and we're 
three deep. RR finishes c2, finishes c1, and we're one level deep again.

Finally, RR has finished everything in a, and exits.

So RR has been called seven times: once for each directory in the list. 
But the deepest level of recursion reached was three levels: the 
deepest nesting of directories in the tree.

regards,

Geoff Canyon
gcanyon at inspiredlogic.com




More information about the use-livecode mailing list