Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
8
Task/Matrix-transposition/D/matrix-transposition-1.d
Normal file
8
Task/Matrix-transposition/D/matrix-transposition-1.d
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
void main() {
|
||||
import std.stdio, std.range;
|
||||
|
||||
/*immutable*/ auto M = [[10, 11, 12, 13],
|
||||
[14, 15, 16, 17],
|
||||
[18, 19, 20, 21]];
|
||||
writefln("%(%(%2d %)\n%)", M.transposed);
|
||||
}
|
||||
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);
|
||||
}
|
||||
12
Task/Matrix-transposition/D/matrix-transposition-3.d
Normal file
12
Task/Matrix-transposition/D/matrix-transposition-3.d
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import std.stdio, std.algorithm, std.range, std.functional;
|
||||
|
||||
auto transpose(T)(in T[][] m) pure nothrow {
|
||||
return m[0].length.iota.map!(curry!(transversal, m));
|
||||
}
|
||||
|
||||
void main() {
|
||||
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