Disjoint slices of an array as reference

Paul Backus snarwin at gmail.com
Thu Aug 20 03:47:15 UTC 2020


On Thursday, 20 August 2020 at 02:21:15 UTC, data pulverizer 
wrote:
> ```
> double[] y;
> y ~= x[0..5];
> y ~= x[9..14];
> ```
>
> But the act of appending results in array copying - breaks the 
> reference with the original array. The only other thing I have 
> considered is creating an array of references to each of the 
> elements of x I would like but that just seems like overkill.
>
> It would be good to know if there is a more straightforward way 
> of doing this type of disjoint selection.
>
> Thanks in advance.

double[][] y;
y ~= x[0..5];
y ~= x[9..14];


More information about the Digitalmars-d-learn mailing list