Merge pull request #506 from andrewcsmith/patch-2
[supercollider.git] / HelpSource / Reference / loop.schelp
blobda4cea7ed38e30a5cebf6d5e7ece02052518deca
1 title:: loop / repeat
2 summary:: Repeat stuff
3 categories::Core,Common methods
5 method:: loop, repeat
7 Create an object that behaves like a stream that returns values for a limited (or infinite) number of times.
9 For a full list of implementing classes, see link::Overviews/Methods#loop:: and link::Overviews/Methods#repeat::
11 definitionlist::
12 ## link::Classes/Function#-loop:: ||
13         repeats the function forever.
14 code::
15         f = { 3.yield };
16         x = Routine({ f.loop });
17         10.do({ x.next.postln })
20 ## link::Classes/Object#-repeat:: (n) ||
21         repeat to yield the object
22 code::
23         x = 5;
24         y = x.repeat(6);
25         y.nextN(8);
28 ## link::Classes/Pattern#-repeat:: (n) ||
30 code::
31         x = Prand([1, 2]).repeat(6).asStream;
32         x.nextN(8);
35 ## link::Classes/Pattern#-loop:: ||
37 code::
38         x = Prand([1, 2]).loop.asStream;
39         x.nextN(8);
42 ## link::Classes/Stream#-repeat:: (n) ||
44         embeds the stream repeatedly
46 code::
47         x = Routine({ 3.do({ arg i; i.yield }) }).repeat(6);
48         x.nextN(8);
51 ## link::Classes/Stream#-loop:: ||
53         embeds the stream repeatedly
55 code::
56         x = Routine({ 3.do({ arg i; i.yield }) }).loop;
57         x.nextN(8);