Search
Feb 07, 2006
Ivan Senji
Feb 07, 2006
Don Clugston
Feb 07, 2006
Ivan Senji
```Here i will ask a question, and then answer it the way I think Walter would answer.

I would like to create a dynamic but rectangular array (example not D syntax):

<example1>

int[,,,,] array = new int[10,7,5,3,2];
array[x,y,z,w,t] = 100;

</example1>

Question: how or when will this be available in D?

But you can already to the same thing in D, just write:

<example2>

int[][][][][] array = new int[][][][10];

for(int i=0; i<10; i++)
{
array[i].length = 7;
for(int j=0; j<7; j++)
{
array[i][j].length = 5;
for(int k=0; k<5; k++)
{
array[i][j][k].length = 3;
for(int l=0; l<3; l++)
{
array[i][j][k][l].length = 2;
}
}
}
}

and then:

array[x+y*10+z*10*7+w*10*7*5+t*10*7*5*3] = 100; //maybe correct

</example2>

Although i agree that the code in these two examples looks almost identical and can hardly imagine why anyone would wan't to write the first one :) , there may be people who think the first is just a little bit simpler.

Is something like this even a remote posibillity for 2.0 D?
```
```Ivan Senji wrote:
> Here i will ask a question, and then answer it the way I think Walter would answer.
>
> I would like to create a dynamic but rectangular array (example not D syntax):
>
> <example1>
>
> int[,,,,] array = new int[10,7,5,3,2];
> array[x,y,z,w,t] = 100;
>
> </example1>
>
> Question: how or when will this be available in D?
>
>
> But you can already to the same thing in D, just write:
>
> <example2>
>
> int[][][][][] array = new int[][][][10];
>
> for(int i=0; i<10; i++)
> {
>   array[i].length = 7;
>   for(int j=0; j<7; j++)
>   {
>     array[i][j].length = 5;
>     for(int k=0; k<5; k++)
>     {
>       array[i][j][k].length = 3;
>       for(int l=0; l<3; l++)
>       {
>         array[i][j][k][l].length = 2;
>       }
>     }
>   }
> }
>
> and then:
>
> array[x+y*10+z*10*7+w*10*7*5+t*10*7*5*3] = 100; //maybe correct
>
> </example2>
>
> Although i agree that the code in these two examples looks almost identical and can hardly imagine why anyone would wan't to write the first one :) , there may be people who think the first is just a little bit simpler.
>
> Is something like this even a remote posibillity for 2.0 D?

```Don Clugston wrote: