Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Greetings Monks,
I need to transpose a bi-dimentional array, so that rows become columns and vice-versa.
my @matrix = ( [ qw(ab cd ef gh)], [ qw(ij kl mn op)], [ qw(qr st uv wx)] ); # should become my @transposed = ( [ qw(ab ij qr)], [ qw(cd kl st)], [ qw(ef mn uv)], [ qw(gh op wx)] );
I found Math::Matrix, which has a "transpose" method. However, it only works with numerical matrices, and since my matrices are mostly text, I was wondering if there are any general purpose methods (or modules) to achieve this goal.
Thanks
20030721 Edit by Corion: Changed title from 'Transpose a bi-dimentional array'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Transpose a bi-dimensional array
by dbwiz (Curate) on Jul 21, 2003 at 11:24 UTC | |
|
Re: Transpose a bi-dimensional array
by edan (Curate) on Jul 21, 2003 at 11:28 UTC | |
|
Re: Transpose a bi-dimensional array
by Abigail-II (Bishop) on Jul 21, 2003 at 12:35 UTC | |
|
Re: Transpose a bi-dimensional array
by broquaint (Abbot) on Jul 21, 2003 at 11:31 UTC | |
|
Re: Transpose a bi-dimensional array
by jmcnamara (Monsignor) on Jul 21, 2003 at 11:29 UTC | |
by Anonymous Monk on Apr 02, 2016 at 19:21 UTC | |
by Anonymous Monk on Apr 02, 2016 at 19:27 UTC |