Int within ranges

Jonathan M Davis jmdavisProg at gmx.com
Mon Jun 13 11:14:18 PDT 2011


On 2011-06-13 09:15, nrgyzer wrote:
> Hi there,
> 
> is there any possibility to get a sliced array from another array
> between two ranges like:
> 
> int[uint] myArray;
> myArray[10] = 1000;
> myArray[20] = 2000;
> myArray[30] = 3000;
> myArray[40] = 4000;
> myArray[50] = 5000;
> 
> int[] newArray = myArray[>= 20 .. <= 40]; // not able to do this
> writeln(newArray); // should print [2000, 3000, 4000]
> 
> Is there any way to do this?

Slices take a contiguous chunk of an array. You can't skip any values. So, if 
you want them separate, you're going to have to put them in another container 
yourself.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list