array help.
bearophile via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jul 8 11:16:54 PDT 2014
NA:
> Any ideas welcome.
Is this good enough?
void main() {
import std.algorithm: swap;
int[][][][] a =
[[[],
[],
[[0, 1], [0, 2]],
[[0, 0], [0, 3]]
],
[[],
[],
[[1, 1], [1, 2]],
[[1, 0], [1, 3]]
]
];
int[][][][] b =
[[[[0, 1], [0, 2]],
[[0, 0], [0, 3]],
[],
[],
],
[[[1, 1], [1, 2]],
[[1, 0], [1, 3]],
[],
[]
]
];
foreach (s1; a) {
swap(s1[0], s1[2]);
swap(s1[1], s1[3]);
}
assert(a == b);
}
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list