A SuperCollider pattern is a factory for a stream, with Pseq and Prand giving ordered and random values
In SuperCollider a pattern is essentially a factory for a stream: it holds the data and its type decides how that data is streamed. Reusable pattern classes compose inside Pbind: Pseq(list, repeats) spits out the list values in order, cycling repeats times; Prand(list, repeats) picks one at random each step; Pxrand is like Prand but never repeats a value twice in a row; Pshuf shuffles once per repeat; Pwrand picks by probability weights. Arithmetic generators include Pseries (arithmetic) and Pgeom (geometric). Patterns nest freely, so a Pseq can contain other patterns as its items.
Examples
Pbind(\freq, Prand([300, 400, 500, 600, 700], inf), \dur, 0.25).play; // pattern nested inside a pattern: Pbind(\freq, Pseq([Prand([200, 300], 2), 400], inf), \dur, 0.5).play;
Assessment
Predict Pseq([1, 2, Prand([3, 4], 1)], 2).asStream.nextN(6), then rewrite it so no value repeats consecutively using Pxrand.