[chuck-users] .cap() for multi-dimensional arrays
Mark Pauley
mpauley at mac.com
Wed Oct 3 11:23:59 EDT 2007
In some languages (like C) multi-dimensional arrays do need to be
rectangular. This is because it's really just one big array. i.e.
If you
int foo[2][3];
you're doing exactly the same as
int foo[6];
except that the compiler will do a bit of sugar for you and multiply
your outer index by the inner array size and add it to your inner index.
In java this is not the case because each index into your outer array
is infact a ref to an array object.
_Mark
On Oct 3, 2007, at 6:54 AM, Kassen wrote:
>
>
> On 10/3/07, Spencer Salazar <ssalazar at cs.princeton.edu> wrote:
> It makes sense when you think of multi dimensional arrays as just
> arrays of arrays. Additionally each sub-array need not be of equal
> length.
>
>
> Ah! I didn't think your could do that, I had assumed the sub-
> arrays needed to be equal length.
>
> In that case I withdraw my comment about the need for the index
> being ugly, obviously. In that case it's also quite coherent that
> we need ask to get the .cap() for higher dimensions in exactly that
> way but I still think a note about this in the manual couldn't hurt.
>
> Thanks for the demonstration!
>
> Kas.
>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20071003/b499b55a/attachment.htm
More information about the chuck-users
mailing list