Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
16
Task/Matrix-transposition/D/matrix-transposition-2.d
Normal file
16
Task/Matrix-transposition/D/matrix-transposition-2.d
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
T[][] transpose(T)(in T[][] m) pure nothrow {
|
||||
auto r = new typeof(return)(m[0].length, m.length);
|
||||
foreach (immutable nr, const row; m)
|
||||
foreach (immutable nc, immutable c; row)
|
||||
r[nc][nr] = c;
|
||||
return r;
|
||||
}
|
||||
|
||||
void main() {
|
||||
import std.stdio;
|
||||
|
||||
immutable M = [[10, 11, 12, 13],
|
||||
[14, 15, 16, 17],
|
||||
[18, 19, 20, 21]];
|
||||
writefln("%(%(%2d %)\n%)", M.transpose);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue