array help.
NA via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jul 8 11:30:13 PDT 2014
On Tuesday, 8 July 2014 at 18:16:55 UTC, bearophile wrote:
> 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
Thanks but
int[][][][] a =
[[[],
[],
[],
[],
[[0, 1], [0, 2]],
[[0, 0], [0, 3]]
],
[[],
[],
[],
[],
[[1, 1], [1, 2]],
[[1, 0], [1, 3]]
]
];
will not work and no I can't sort it.
Cheers.
More information about the Digitalmars-d-learn
mailing list