[chuck-users] arrays, and random elements therein

Michael Heuer heuermh at gmail.com
Wed Jul 27 22:04:17 EDT 2011

On Wed, Jul 27, 2011 at 7:41 PM,  <tempjayren at gmail.com> wrote:

> i'd like to know if chuck has what i'm going to think of as arrays, that
> is for a variable foo, foo(1) is 4 foo(2) would be something else other
> than 4, and so on. then there'd hafta be a way to determine how many
> elements were in foo in the first place

Yes, ChucK has arrays

int foo[10];
4 => foo[1];
42 => foo[2];
foo[Math.rand2(0, 9)] => int sample;


or if you would prefer Java-style Lists

IntArrayList list;
list.set(1, 4);
list.set(2, 42);
list.sample() => int sample;


or if you would prefer Lisp-style Lists, there is such library code
out there but I can't remember where it is or who wrote it, try
searching the chuck-users@ mailing list archives.



More information about the chuck-users mailing list