[chuck-users] Mixing associative with integer indexed arrays?

Stephen Sugden glurgle at gmail.com
Fri Nov 21 23:18:17 EST 2008


Is it possible to mix both types of array keys? The code I below works fine
until I try to access any elements of the array, then I get an
ArrayOutofBounds exception. The snippet is pretty short and I would hope
it's self evident what I'm trying do with it.

float scales[0][0][0];

[ 0, 2, 4, 5, 7, 9, 11, 12 ] @=> melodies[0];

[ [1.0, 1.0], [16.0, 15.0], [9.0, 8.0], [6.0, 5.0], [5.0, 4.0],
 [4.0, 3.0], [7.0,5.0], [3.0, 2.0], [8.0,5.0], [5.0, 3.0],
 [7.0, 4.0], [15.0, 8.0], [2.0, 1.0]
] @=> scales["just"];


float et[13][2];
for(0 => int i; i <= 12; ++i){
    1.0 => et[i][0];
    Math.pow(2.0, i / 12.0) => et[i][1];
}

et @=> scales["equalTempered"];

<<< scales["just"][0] >>>;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20081121/2e5a1179/attachment.html>


More information about the chuck-users mailing list