Stuart stugol at
Sat Jul 28 00:49:42 PDT 2012

On Friday, 27 July 2012 at 22:38:46 UTC, Dmitry Olshansky wrote:
> On 27-Jul-12 22:58, Stuart wrote:
>> Well, off the top of my head, you could use something like:
>>    Public Iterator Function AllFiles(RootDirectory As String) 
>> As
>> IEnumerable(Of String)
>>       Dim Roots As New Queue(Of String) From {RootDirectory}
>>       While Roots.Any
>>          Dim Root = Roots.Pop
>>          Roots.AddRange(IO.Directory.GetDirectories(Root))
>>          For Each Filename in IO.Directory.GetFiles(Root)
>>             Yield Filename
>>          Next
>>       End While
>>    End Function
> Then it's not in anyway better then ranges.

I assume you mean "any way" - "anyway" has a different meaning. 
And I don't know much about ranges, because there's very little 
documentation. But as I understand it, for ranges I'd need to 
write a whole new class. Here, I'm writing a SINGLE FUNCTION in 
standard imperative style.

> You again maintain stack (or queue, whatever).

There is a difference between recursion (stack) and state 
variables. To claim that my function is recursive is sheer 
nonsense. Recursion is costlier than a local queue.

More information about the Digitalmars-d mailing list