And depth/breadth first recursion can be adjusted by shifting instead of popping at the top of the loop (or when inserting new work).seed the stack with the first instance while (stack has entries) pop off top entry from stack process it take any potential new work as a result of processing, put it back on the stack
Of course this only replaces the subroutine stack with your own, but it can be quicker and save memory. (Sometimes it's a lot more obvious too!)
In reply to Re: Unrolling recursion
by clintp
in thread Unrolling recursion
by dragonchild
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |