Hello everyone,<br><br>I tried to send this earlier today, and it didn't seem to come through, but in the meantime I did more work on the problem.<br><br>I am writing some functions that will be made
into a class, for doing basic serial operations on cells (i.e. arrays
of floats). The operations I have so far are: transpose, reverse,
invert, permute, shuffle.
<br><br>The next function to finish is multiply, which does
Boulez-style cell multiplication. For the function to work correctly,
it should remove any duplicates from the array. Unfortunately, my
brain's a little rusty right now. I'm sure I did this in the only
computer class I ever took (C++). But I'm too sleepy to figure out the
correct solution offhand, I think the ways I'm coming up with are
inefficient. Can anyone help? My attempt at this is in the function remDup below, but I made some mistake, I'm sure relating to using a while loop--I'm not sure what the problem is though, or a better way to do it.<br><br>
I've gotten really spoiled, by usually coding these sorts of
things in Python, where its amazingly quick to do list manipulations of
any kind.<br><br>//cellFun.ck<br><br>public class Argh<br>{<br>&nbsp; fun static void print(float cell[])<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; for (0 =&gt; int i; i&lt;cell.cap(); i++)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;&lt;&lt; cell[i] &gt;&gt;&gt; ;<br>&nbsp;&nbsp;&nbsp; }<br>
&nbsp; }<br><br>&nbsp; fun static void remove (float a[], int index)<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; a.cap()-1 =&gt; int newLength;<br>&nbsp;&nbsp;&nbsp; float temp[newLength];<br>&nbsp;&nbsp;&nbsp; for (0 =&gt; int i; i &lt; newLength; i++)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (i&lt;index)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a[i] =&gt; temp[i];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a[i+1] =&gt; temp[i];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; float a[newLength];<br>&nbsp;&nbsp;&nbsp; for (0 =&gt; int i; i &lt; newLength; i++ )<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; temp[i] =&gt; a[i];
<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; }<br><br>&nbsp; //match<br>&nbsp; fun static int match(float cell[], float element)<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; cell.cap() =&gt; int length;<br>&nbsp;&nbsp;&nbsp; -1 =&gt; int position;<br>&nbsp;&nbsp;&nbsp; for (0 =&gt; int i; i&lt;length; i++)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (cell[i] == element)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i =&gt; position;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; return position;<br>&nbsp; }<br>&nbsp; <br><br><br>&nbsp; fun static float[] copy(float cell[])<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; cell.cap() =&gt; int length;<br>&nbsp;&nbsp;&nbsp; float newCell[length];
<br>&nbsp;&nbsp;&nbsp; for (0 =&gt; int i; i&lt;length; i++)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cell[i] =&gt; newCell[i];<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; return (newCell);<br>&nbsp; }<br><br>&nbsp; //sort<br>&nbsp; fun static float[] sort(float cell[])<br>&nbsp; {<br>&nbsp; cell.cap() =&gt; int length;
<br>&nbsp; float temp;<br>&nbsp; for (0 =&gt; int x ; x &lt; length-1; x++)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; for (0 =&gt; int y; y &lt; length-x-1; y++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (cell[y] &gt; cell[y+1])<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cell[y] =&gt; temp;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cell[y+1] =&gt; cell[y];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; temp =&gt; cell[y+1];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; return cell;<br>&nbsp; }<br><br>&nbsp; fun static float[] remDup(float cell[])<br>&nbsp; {<br>&nbsp; 1 =&gt; int i;<br>
&nbsp; cell.cap() =&gt; int length;&nbsp; <br>&nbsp; while (i &lt; length-1)<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; if (cell[i]==cell[i+1])<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; remove(cell,i+1);<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i++;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; }<br>&nbsp; return cell;<br>&nbsp; }<br>
<br>}<br><br>