Matrix transposition: Difference between revisions

Content deleted Content added
Simplified D code
Added functional D version
Line 643: Line 643:
[12, 16, 20]
[12, 16, 20]
[13, 17, 21]]</pre>
[13, 17, 21]]</pre>
Functional style (same output):
<lang>import std.stdio, std.algorithm, std.conv, std.range;

auto transpose(T)(in T[][] m) {
return map!((int i){ return transversal(m,i); })(iota(m[0].length));
}

void main() {
auto M = [[10, 11, 12, 13],
[14, 15, 16, 17],
[18, 19, 20, 21]];
auto Mt = transpose(M);
writeln("[", array(map!text(Mt)).join("\n "), "]");
}</lang>


=={{header|ELLA}}==
=={{header|ELLA}}==