scide: LookupDialog - redo lookup on classes after partial lookup
[supercollider.git] / HelpSource / Classes / Prewrite.schelp
blob7acbe5129ead0e3fa1403fac4962b59f8205e249
1 class:: Prewrite
2 summary:: rewriting system
3 related:: Classes/Pfsm
4 categories:: Streams-Patterns-Events>Patterns>List>Indexing
6 description::
8 Lindenmayer system pattern for selfsimilar structures. Its strong::dictionary (or event):: maps one element to an array of child elements. The algorithm replaces iteratively (strong::levels:: deep) elements by arrays of elements starting with the values in the strong::pattern::.
10 ClassMethods::
12 method::new
14 argument::pattern
15 starting value
17 argument::dict
18 a dictionary or an event.
20 argument::levels
21 number of levels
23 code::
24 IdentityDictionary[
25         elem1 -> [ otherElements ],
26         elem2 -> [ otherElements ],
27         elem2 -> [ otherElements ]
31 Examples::
33 The examples use the code::():: shortcut for link::Classes/Event::.
35 code::
37 a = Prewrite(0, // start with 0
38                 (       0: #[2,0],
39                         1: #[0,0,1],
40                         2: #[1,0,1]
41                 ), 4);
42 x = a.asStream;
43 30.do({ x.next.postln });
47 //Prewrite used as a sequence of pitches:
50 SynthDef(\help_sinegrain,
51         { arg out=0, freq=440, sustain=0.05;
52                 var env;
53                 env = EnvGen.kr(Env.perc(0.01, sustain, 0.2), doneAction:2);
54                 Out.ar(out, SinOsc.ar(freq, 0, env))
55         }).add;
59 a = Prewrite(0, (
60         0: #[2,0],
61         1: #[0,0,1],
62         2: #[1,0,1]
63 ), 4).asStream;
64 Routine({
65         loop({
66                 Synth(\help_sinegrain, [\freq, (a.next * 5 + 70).midicps]);
67                 0.1.wait;
68         })
69 }).play;