## WeBWorK Problems

### Re: Merging several matrices into one matrix

by Davide Cervone -
Number of replies: 0
It looks good. You could combine the line
    my $Row = Matrix($c[$i])->transpose;$Row = $Row->row(1);  into the single command  my$Row = Matrix($c[$i])->transpose->row(1);

In fact, you could replace
    my $Row = Matrix($c[$i])->transpose;$Row = $Row->row(1); push(@temp,$Row);

with
    push(@temp,Matrix($c[$i])->transpose->row(1));

I guess you could also simplify the loop slightly as
    for my $c (@c) { push(@temp,Matrix($c)->transpose->row(1));
}

since you can iterate over your column array. Technically, you could also reuse @c by setting
    for my $c (@c) {$c = Matrix(\$c)->transpose->row(1)}
return Matrix(@c)->transpose;

rather than allocating a second array, but perhaps that is too much.

Other than that, it looks fine.

Davide