[PD] Shuffling arrays

martin.peach at sympatico.ca martin.peach at sympatico.ca
Mon Oct 4 17:06:23 CEST 2010

That's a bad way to shuffle, as it can swap things back again and generally reduce the randomness, the way someone who is good at shufflng cards can put them all back the way they started while appearing to mix them up.

A better way is to start at the beginning of the array, swap the first item with one of the remaining items, then swap the second item, up to the end.


Claude wrote:
> On 03/10/10 23:21, Andrew Faraday wrote:
>> Hey Guys
>> I've recently come across the .shuffle method in Ruby which randomly re-orders the content of an array. Does anyone know of a way to do this in Pd, that is, either change the order of notes within an array or output them in a random order (without repeating any part of it)?
>> Help would be appreciated
>> Andrew
> You can pick pairs of indices at random and swap them with
> tabread/tabwrite; repeat to shuffle more.
> I used a similar technique to gradually sort an array (swap random
> elements only if they are out of order):
> https://code.goto10.org/svn/maximus/2007/clouds-are-made-of-water/
> http://www.archive.org/details/ClaudiusMaximus_-_Clouds_Are_Made_Of_Water
> (track 5)
> Claude
> --
> http://claudiusmaximus.goto10.org
> _______________________________________________
> Pd-list at iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list

More information about the Pd-list mailing list