Hi everybody. I'm new to this forum, this is my first post. I've found a few helpful posts about ChucK here -- thanks. I'm relatively new to ChucK also (have been learning it for a couple months), and programming in general.

So far so good. I understand how to instantiate the array in 3 dimensions. I understand how chuck refers to the different positions in the array. I understand how to read specific location in the array. And I understand how to write to the array, two different ways. The way I think of the first method used here is that I'm sending a couple of different 2D arrays to a 3D array. The second method sends a specific value to a specific location in the array.

But what if, later on, I want to send another 2D array to the 3D array? Is there a way to reference a specific position along the 3rd dimension (or 1st dimension, however you think about it), and send a 2D array to it? I can't seem to figure anything out.

You can see a 3d matrix as an array of matrixes, a matrix of arrays, or an array of arrays of arrays. When you are writing the 2d matrix, you are really just storing an element in the "outermost" array._________________Antimon's Window@soundcloud@Flattrhome - you can't explain music

Yeah sorry, to write to the third element (index 2) in the first dimension (root array) you have to allocate memory for it first, or use the dynamic array stuff that increases the size of the array as you add stuff to it. I can't do the research now, but I think there are examples for dynamically adding array elements shipped with ChucK.

The alternative is to allocate enough memory at the start. I'm not sure, but you might be able to change the last line for setting up A to:

Code:

[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],
[] ] @=> int A[][][];

adding an empty array that you can replace by writing to A[2] later. Or try initalizing A like this:

int A[3][][];

(Edit: i.e. don't set the contents next to the matrix declaration using @=>, set them later)

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum

Please support our site. If you click through and buy from our affiliate partners, we earn a small commission.