The function is zipextremely annoying because it uses a (\@\@;\@\@\@...)prototype or something so crazy. You have to do ampersand call to override the prototype: &zip(@$matrix).
, zip it ( ,
[1, 5, 9, 13, 17, 2, 6, 10, 14, 18, 3, 7, 11, 15, 19, 4, 8, 12, 16, 20]
natatime zip:
my $iter = natatime @$matrix, &zip(@$matrix);
my @transposed;
while (my @column = $iter->()) {
push @transposed, \@column;
}
, . :
my $transposed = [];
for my $i (0 .. $#$matrix) {
for my $j (0 .. $#{ $matrix->[0] }) {
$transposed->[$j][$i] = $matrix->[$i][$j];
}
}