in reply to flattening a list-of-lists

What you are flattening here is a tree, not a list of list - you do a depth-first walk on it. It's a standard algorithm - not much to improve there (beside, perhaps, some tail-recursion tweaking - I've never cared to learn about that technique).

Replies are listed 'Best First'.
Re: Re: flattening a list-of-lists
by aquarium (Curate) on Nov 19, 2003 at 13:30 UTC
    as zby pointed out...you're doing a tree search/flatten. a standard flattening of arrays in perl is simply assignment  @flat = (@this, @that, @the_other);...where the flat array now contains all elements of the assigned arrays, not pointers etc, and there is no way to re-create the original three arrays (without cheating) from the final flat array.