Random Pattern Question

inlighttone's icon

I'm trying to duplicate the pattern system in Common Music in Max and I'm stumped with "heap" which is described:
'Generates random permutations of its elements'

It basically takes a list shuffles it around then outputs the list, then shuffles it again then outputs for as many items output as I'd like.

For instance: given this list '(a4 b c5 d)
(next pat1 #t)
⇒ (69 72 74 71)
(next pat1 #t)
⇒ (72 74 71 69)
(next pat1 #t)
⇒ (72 71 69 74)
(next pat1 #t)
⇒ (71 69 74 72)

My problem is going from Lisp where you calculate stuff to Max and needing to generate realtime or maybe I'm approaching this wrong. I probably need to sleep...Thanks for any advice.

Rick's icon

Spend some time with the zl objects. For instance [zl.scramble] and [zl.rot]. Lots there to help you with list processing.

metamax's icon
Max Patch
Copy patch and select New From Clipboard in Max.

inlighttone's icon

Thanks guys, just needed a point in the right direction, appreciate...

Man that was almost TOO easy, I was way over-thinking that one...embarrassing.