There is the simple "flatten as you go" approach:
sub genIterator { my @stack = @_; return sub { splice @stack, 0, 1, @{$stack[0]} while 'ARRAY' eq ref $stack[0]; shift @stack; } }
In reply to Re: An iterator for (not "iterating") a recursive data structure.
by Anonymous Monk
in thread An iterator for (not "iterating") a recursive data structure.
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |