In the following code I am manipulating an array. Everything works to plan except the last line of code. My expectation is that do would ¨return¨ the array that it has just swapped around, and then I could continue to use that array further in my patch. Instead I get the error message:
ERROR: syntax error, unexpected NAME, expecting $end
in interpreted text
line 31 char 4:data.postln;
^^^^
Any illumination greatly appreciated.
var data;
var parts;
var size;
var change1;
var change2;
var reflection;
parts = 5;
data = Array.fill(parts, {arg i; i});
data.postln;
size = data.size;
size = size/2;
size = size.asInteger;
change1 = size;
change1 = change1.asInteger;
change1.postln;
change2 = if(parts.odd, {size.asInteger}, {size-1});
change2.postln;
(
do(parts, {arg count;
x = count % 2;
data.postln;
if(x.even,
{do(change1, {arg count1; data.swap(count1*2, count1*2+1) })},
{do(change2, {arg count2; data.swap(count2*2+1, count2*2+2) })})
}
)
)
data.postln;