Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^3: Transpose a matrix of chars

by ysth (Canon)
on Jul 04, 2005 at 22:42 UTC ( [id://472322]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Transpose a matrix of chars
in thread Transpose a matrix of chars

pop only works on an array, not a list; try a list slice:
my $max_col = (sort {$a <=> $b} map $#$_, @rows)[-1];
though in this particular case, you can just reverse the sort and use a list assignment:
my ($max_col) = sort {$b <=> $a} map $#$_, @rows;
Nit: I think of "max_cols" as being maximum number of columns found, but you are wanting one less than that, the maximum column index, so I called it max_col instead. And I think @$_ - 1 is pretty ugly compared to the elegant $#$_ :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://472322]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-25 14:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found