array operations and ranges

Vlad Levenfeld via Digitalmars-d digitalmars-d at puremagic.com
Sun Apr 26 11:48:14 PDT 2015


> On Sunday, 26 April 2015 at 10:17:59 UTC, Manu wrote:
>> I find that my lazy ranges often end up on the stack, but I 
>> can't
>> assign/initialise directly: float[] a = b.transform[];
>> Instead I need to: float[] a;  b.transform.copy(a[]);

To enable the first line, builtin arrays would need to be able to 
recognize arbitrary range types and do the right thing. You can 
always do this:

   float[] a = b[].transform.array;

I've got a lib to enable this syntax:

   Array!float a = b[].transform_1;
   a[i..j] = c[x..y].transform_2;

for arbitrary user-defined or composed n-dimensional range types.

here: https://github.com/evenex/autodata

where ranges are made more interoperable by common mixin 
templates which also cut down on a lot of boilerplate.

(see examples in:
https://github.com/evenex/autodata/tree/master/source/spaces)


More information about the Digitalmars-d mailing list