Anonymous user
Matrix transposition: Difference between revisions
Updated D code
No edit summary |
(Updated D code) |
||
Line 656:
<lang d>import std.stdio, std.algorithm, std.array, std.conv;
auto r = new T[][](m[0].length, m.length);
foreach (nr, row; m)
Line 665:
void main() {
[14, 15, 16, 17],
[18, 19, 20, 21]];
writeln("[", array(map!text(
}</lang>
Output:
Line 679:
<lang d>import std.stdio, std.algorithm, std.conv, std.range;
auto transpose(T)(in T[][] m) /*pure*/ {
return map!((
}
void main() {
[14, 15, 16, 17],
[18, 19, 20, 21]];
/*immutable*/ auto
writeln("[", array(map!text(
}</lang>
|