Matrix transposition: Difference between revisions

Content added Content deleted
m (Improved clojure section with sample output)
(→‎{{header|Perl 6}}: Added a more concise solution and output)
Line 1,227: Line 1,227:
say "transposed: ";
say "transposed: ";
.perl.say for @b;</lang>
.perl.say for @b;</lang>

A more concise solution:
<lang perl6>sub transpose (@m) {
@m[0].keys.map: {[ @m».[$_] ]};
}

my @a = [< a b c d e >],
[< f g h i j >],
[< k l m n o >],
[< p q r s t >];

.say for @a.&transpose;</lang>

Output:<pre>a f k p
b g l q
c h m r
d i n s
e j o t</pre>


=={{header|PHP}}==
=={{header|PHP}}==