[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] (no subject)



One comment is that it's extremely inefficient to sort the array for every iteration of the loop. You should make the sorted list once and keep it in a variable.

It's a floating point issue -- contrary to expectations, inf.do passes 0.0, 1.0, 2.0 into the loop.

9.wrap(0, 9) == 9
9.0.wrap(0, 9) == 0

A workaround for now is to use a generator expression which will loop from 0 (Integer) to infinity:

a = [1,2,3,4,5,6,7,8,9,0].asSortedList;
b = Routine({
(0..).do({ arg count;
a.wrapAt(count).yield;
})
});

I wonder if this should be considered a bug, though.

hjh

On Oct 9, 2005, at 10:27 AM, jayjayevans@xxxxxxxx wrote:

a = [1,2,3,4,5,6,7,8,9,0]
b = Routine({
inf.do({arg count;
a.asSortedList.wrapAt(count).postln.yield;})
});

b.value

: H. James Harkins
: jamshark70@xxxxxxxxxxxxxxxxx
: http://www.dewdrop-world.net
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal." -- Whitman