On Saturday, 22 July 2017 at 20:55:06 UTC, kerdemdemir wrote:
We have awesome way for creating slices like:
a = new int[5];
int[] b = a[0..2];
But what about if I have 2D array and I don't want to go
vertical. Something like :
int[3][3] matrix = [
[ 1, 2, 3 ],
[ 4, 5, 6 ],
On 22.07.2017 22:55, kerdemdemir wrote:
We have awesome way for creating slices like:
a = new int[5];
int[] b = a[0..2];
But what about if I have 2D array and I don't want to go vertical.
Something like :
int[3][3] matrix = [
[ 1, 2, 3 ],
[ 4, 5, 6 ],
[ 7, 8, 9 ]
];
On Saturday, 22 July 2017 at 20:55:06 UTC, kerdemdemir wrote:
And what if I want to go diagonal like 1,5,9 or 3,5,7 in the
example above. Is there a good solution in std without using
for loops?
I suggest using an actual matrix type for tasks like this. I
don't know about diagonal slicing,
We have awesome way for creating slices like:
a = new int[5];
int[] b = a[0..2];
But what about if I have 2D array and I don't want to go
vertical. Something like :
int[3][3] matrix = [
[ 1, 2, 3 ],
[ 4, 5, 6 ],
[ 7, 8, 9 ]
];
I believe I can use std.range function