D slicing

Colin Grogan grogan.colin at gmail.com
Mon Jun 17 16:34:41 PDT 2013


Hi all.

Wondering what way I'd go about this, I want to slice an array 
into two arrays. First array containing every even index (i.e. 
0,2,4,6,8..$)
Second slice containing every odd index (i.e. 1,3,5,7,9..$) <-- 
be some issue with using $ depending on if orig length is odd or 
even. Can work that out easily enough...

Reading the articles on array slicing its not clear if its 
possible.

Ideally, I could do something like the following:

auto orig = [1,2,3,4,5,6,7];
auto sliceEven = orig[0..$..2];
auto sliceOdd = orig[1..$..2];

But I dont think thats possible?

Any idears?


More information about the Digitalmars-d-learn mailing list