<br>
Hi, Stephen!<br><br><div class="gmail_quote">2008/11/22 Stephen Sugden <span dir="ltr">&lt;<a href="mailto:glurgle@gmail.com">glurgle@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Is it possible to mix both types of array keys?</blockquote><div><br><br>Yes... or at least it *should* be.... ;¬)<br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
 The code I below works fine until I try to access any elements of the array, then I get an ArrayOutofBounds exception. </blockquote><div><br>I corrected the lack of a type for &quot;melodies&quot;.<br><br>Then I had a hard time with it, as it turns out that this;<br>
&nbsp;<br>[ 0, 2, 4, 5, 7, 9, 11, 12 ] @=&gt; int melodies[0];<br><br>crashes ChucK. That&#39;s a bug, and it&#39;s good that we accidentally found it but kindly try to avoid such confusion by making sure the code you send works as you described.<br>
<br>Right, on to the business at hand;<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>&lt;&lt;&lt; scales[&quot;just&quot;][0] &gt;&gt;&gt;;<br>
<br></blockquote></div><br>You can&#39;t print the contents of a array (which this refers to) in one swoop like this, I fear. If you&#39;d like to do this you&#39;d have to loop over the array, if they all need to be on the same line and the length of the array is dynamic I think you&#39;ll have to join all elements together in a string and print that.<br>
<br>Let&#39;s look at a version that should work properly;<br><br>//===========================<br>float scales[0][0][0];<br><br>[ 0, 2, 4, 5, 7, 9, 11, 12 ] @=&gt; int melodies[];<br><br>[ [1.0, 1.0], [16.0, 15.0], [9.0, 8.0], [6.0, 5.0], [5.0, 4.0],<br>
[4.0, 3.0], [7.0,5.0], [3.0, 2.0], [8.0,5.0], [5.0, 3.0],<br>&nbsp;[7.0, 4.0], [15.0, 8.0], [2.0, 1.0]<br>] @=&gt; scales[&quot;just&quot;];<br><br><br>float et[13][2];<br>for(0 =&gt; int i; i &lt;= 12; ++i){<br>&nbsp;&nbsp;&nbsp; 1.0 =&gt; et[i][0];<br>
&nbsp;&nbsp;&nbsp; Math.pow(2.0, i / 12.0) =&gt; et[i][1];<br>}<br><br>et @=&gt; scales[&quot;equalTempered&quot;];<br><br>for(int n; n&lt; scales[&quot;just&quot;][0].cap(); n++)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp; //goes out of bound for n==0 already<br>&nbsp;&nbsp;&nbsp; &lt;&lt;&lt;scales[&quot;just&quot;][0][n]&gt;&gt;&gt;;<br>
&nbsp;&nbsp;&nbsp; }<br>//==================<br><br>So... that&#39;s a bug, yes, and clearing out the associative indexes in favour of ints makes it go away. Good catch! <br><br>If you&#39;d like; add it to the Wiki here; <a href="http://wiki.cs.princeton.edu/index.php/ChucK/Bugs/Release">http://wiki.cs.princeton.edu/index.php/ChucK/Bugs/Release</a><br>
<br>Yours,<br>Kas.<br>