in reply to Transpose a matrix of chars
#! perl -slw use strict; use List::Util qw[ max ]; use Data::Dumper::SLC; my @cmat = ( [ qw[ A B C F G ] ], [ qw[ u b ] ], [ qw[ 1 T A R S 2 P] ], ); my @trans = map { my $index = $_; [ map{ $_->[ $index ] } @cmat ]; } 0 .. max map{ $#$_ } @cmat; Dump \@trans; __END__ P:\test>junk [ [ 'A', 'u', '1', ], [ 'B', 'b', 'T', ], [ 'C', undef, 'A', ], [ 'F', undef, 'R', ], [ 'G', undef, 'S', ], [ undef, undef, '2', ], [ undef, undef, 'P', ], ]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Transpose a matrix of chars
by ysth (Canon) on Jul 04, 2005 at 22:45 UTC | |
by BrowserUk (Patriarch) on Jul 04, 2005 at 23:07 UTC | |
by ysth (Canon) on Jul 04, 2005 at 23:22 UTC | |
by BrowserUk (Patriarch) on Jul 05, 2005 at 00:05 UTC |