I was first introduced to the concept of 'streams' akin to this in SuperCollider, which uses them as building blocks for musical patterns.<p><a href="http://danielnouri.org/docs/SuperColliderHelp/Streams-Patterns-Events/Pbind.html" rel="nofollow">http://danielnouri.org/docs/SuperColliderHelp/Streams-Patter...</a><p><a href="http://danielnouri.org/docs/SuperColliderHelp/Streams-Patterns-Events/Pattern.html" rel="nofollow">http://danielnouri.org/docs/SuperColliderHelp/Streams-Patter...</a><p>SuperCollider is a fun language to study. You end up with compositional structures like the following (notice 'inf', which indicates an infinite loop)<p><pre><code> Pbind(
\octave, 4,
\degree, PstepNadd(
Pseq([1, 2, 3]),
Pseq([0, -2, [1, 3], -5]),
Pshuf([1, 0, 3, 0], 2)
),
\dur, PstepNadd(
Pseq([1, 0, 0, 1], 2),
Pshuf([1, 1, 2, 1], 2)
).loop * (1/8),
\legato, Pn(Pshuf([0.2, 0.2, 0.2, 0.5, 0.5, 1.6, 1.4], 4), inf),
\scale, #[0, 1, 3, 4, 5, 7, 8]
).play;</code></pre>