Flattening an array of arrays

This evening a friend asked me if I knew how to easily flatten an array of arrays (AoA from now on) in Perl 5. What that means is, basically, to construct a single array that contains the concatenation of all the arrays inside the AoA. My first answer was: "foldr", but I knew beforehand that he wouldn't like it because... this is Haskell. After some time we got to the conclusion that there is no trivial way to flatten an AoA in Perl 5, even though Perl 6 includes a built-in function to do so.

June 7, 2007 · Tags: array, haskell, perl
Continue reading (about 2 minutes)