in reply to How to transpose lines faster?
Both ways are non-destructive (after using map in second).
FWIW: I don't understand what "after using map in second" means, but the second OPed method is destructive (i.e., changes @orig array):
But changing the map expression toc:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my @orig = qw( abcde fghij klmno pqrst uvwxy ); ;; my @transposed; for (map $_ = reverse, @orig) { my $i = 0; $transposed[ $i ++ ] .= chop while $_; } dd \@transposed; dd \@orig; " ["afkpu", "bglqv", "chmrw", "dinsx", "ejoty"] ["edcba", "jihgf", "onmlk", "tsrqp", "yxwvu"]
Give a man a fish: <%-{-{-{-<
|
|---|