[chuck-users] arrays holding arrays?

Ge Wang gewang at CS.Princeton.EDU
Fri Aug 4 14:04:01 EDT 2006


Hi Kassen!

> I have a slight issue. I'd like to have a array in which every object 
> itself is a array. Particularly I'd like to have one of 8 locations 
> each of which holds a array of length 32.
>
> I tried this;
>
>  int[32] memory[8];

You should be able to do this using a two dimensional array:

     int memory[8][32];

You can treat this as a matrix or as an array of array.  To get the 0th 
array:

     memory[0]

Should be of type int []:

     memory[0] @=> int array[];

You can do this up to arbitrary dimensions, just make sure the 
dimensions
add up (the type checker shall complain if they don't).

Hope this helps.

Ge!



More information about the chuck-users mailing list