Removing an old, cherished, yet pointless caveat "This documentation is
[supercollider.git] / Help / Core / loop.html
blob71335cb641532e32dea3e29033ff157a68720525
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta http-equiv="Content-Style-Type" content="text/css">
6 <title></title>
7 <meta name="Generator" content="Cocoa HTML Writer">
8 <meta name="CocoaVersion" content="824.42">
9 <style type="text/css">
10 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 19.0px Helvetica}
11 p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
12 p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
15 span.s1 {font: 9.0px Monaco}
16 span.Apple-tab-span {white-space:pre}
17 </style>
18 </head>
19 <body>
20 <p class="p1"><b>loop / repeat</b></p>
21 <p class="p2"><br></p>
22 <p class="p2"><br></p>
23 <p class="p3">create an object that behaves like a stream that returns values for a limited (or infinite) number of times.</p>
24 <p class="p2"><br></p>
25 <p class="p2"><br></p>
26 <p class="p3"><b>Function-loop</b></p>
27 <p class="p3"><span class="s1"><span class="Apple-tab-span"> </span></span>repeats the function forever.</p>
28 <p class="p2"><span class="Apple-tab-span"> </span></p>
29 <p class="p4"><span class="Apple-tab-span"> </span>f = { 3.yield };</p>
30 <p class="p4"><span class="Apple-tab-span"> </span>x = Routine({ f.loop });</p>
31 <p class="p4"><span class="Apple-tab-span"> </span>10.do({ x.next.postln })</p>
32 <p class="p2"><br></p>
33 <p class="p2"><br></p>
34 <p class="p3"><b>Object-repeat(n)</b></p>
35 <p class="p3"><span class="s1"><span class="Apple-tab-span"> </span></span>repeat to yield the object</p>
36 <p class="p2"><span class="Apple-tab-span"> </span></p>
37 <p class="p4"><span class="Apple-tab-span"> </span>x = 5;</p>
38 <p class="p4"><span class="Apple-tab-span"> </span>y = x.repeat(6);</p>
39 <p class="p4"><span class="Apple-tab-span"> </span>y.nextN(8);</p>
40 <p class="p2"><br></p>
41 <p class="p2"><br></p>
42 <p class="p3"><b>Pattern-repeat(n)</b></p>
43 <p class="p2"><span class="Apple-tab-span"> </span></p>
44 <p class="p4"><span class="Apple-tab-span"> </span>x = Prand([1, 2]).repeat(6).asStream;</p>
45 <p class="p4"><span class="Apple-tab-span"> </span>x.nextN(8);</p>
46 <p class="p2"><br></p>
47 <p class="p3"><b>Pattern-loop</b></p>
48 <p class="p2"><span class="Apple-tab-span"> </span></p>
49 <p class="p4"><span class="Apple-tab-span"> </span>x = Prand([1, 2]).loop.asStream;</p>
50 <p class="p4"><span class="Apple-tab-span"> </span>x.nextN(8);</p>
51 <p class="p2"><span class="Apple-tab-span"> </span></p>
52 <p class="p2"><br></p>
53 <p class="p3"><b>Stream-repeat(n)</b></p>
54 <p class="p5"><br></p>
55 <p class="p3"><span class="s1"><span class="Apple-tab-span"> </span></span>embeds the stream repeatedly</p>
56 <p class="p5"><span class="Apple-tab-span"> </span></p>
57 <p class="p4"><span class="Apple-tab-span"> </span>x = Routine({ 3.do({ arg i; i.yield }) }).repeat(6);</p>
58 <p class="p4"><span class="Apple-tab-span"> </span>x.nextN(8);</p>
59 <p class="p2"><span class="Apple-tab-span"> </span></p>
60 <p class="p3"><b>Stream-loop</b></p>
61 <p class="p5"><br></p>
62 <p class="p3"><span class="s1"><span class="Apple-tab-span"> </span></span>embeds the stream repeatedly</p>
63 <p class="p5"><span class="Apple-tab-span"> </span></p>
64 <p class="p4"><span class="Apple-tab-span"> </span>x = Routine({ 3.do({ arg i; i.yield }) }).loop;</p>
65 <p class="p4"><span class="Apple-tab-span"> </span>x.nextN(8);</p>
66 <p class="p2"><span class="Apple-tab-span"> </span></p>
67 <p class="p2"><br></p>
68 <p class="p2"><br></p>
69 <p class="p2"><br></p>
70 </body>
71 </html>