Create a new library symbol.ml.
[Faustine.git] / documentation / code_VALInterpreter.eval.html
1 <html><head>
2 <link rel="stylesheet" href="style.css" type="text/css">
3 <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
4 <link rel="Start" href="index.html">
5 <link title="Index of types" rel=Appendix href="index_types.html">
6 <link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
7 <link title="Index of values" rel=Appendix href="index_values.html">
8 <link title="Index of modules" rel=Appendix href="index_modules.html">
9 <link title="Types" rel="Chapter" href="Types.html">
10 <link title="Parser" rel="Chapter" href="Parser.html">
11 <link title="Lexer" rel="Chapter" href="Lexer.html">
12 <link title="Value" rel="Chapter" href="Value.html">
13 <link title="Signal" rel="Chapter" href="Signal.html">
14 <link title="Faustexp" rel="Chapter" href="Faustexp.html">
15 <link title="Interpreter" rel="Chapter" href="Interpreter.html">
16 <link title="Preprocess" rel="Chapter" href="Preprocess.html">
17 <link title="Main" rel="Chapter" href="Main.html"><title>Interpreter.eval</title>
18 </head>
19 <body>
20 <code class="code"><span class="keyword">let</span>&nbsp;<span class="keyword">rec</span>&nbsp;eval&nbsp;exp_faust&nbsp;dimension_tree&nbsp;input_beam&nbsp;=&nbsp;<br>
21 <br>
22 <br>
23 </code><table><tr><td></td><td><span class="comment">(** val interpret_par : faust_exp -&gt; faust_exp -&gt; beam -&gt; beam,
24 interprets par(e1, e2) with input beam, produces output beam.*)</span></td></tr></table><code class="code"><br>
25 <span class="keyword">let</span>&nbsp;interpret_par&nbsp;=&nbsp;<span class="keyword">fun</span>&nbsp;e1&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;e2&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;dimension_tree&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;input_beam&nbsp;<span class="keywordsign">-&gt;</span><br>
26 <br>
27 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;dimension&nbsp;information&nbsp;*)</span><br>
28 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;n&nbsp;=&nbsp;<span class="constructor">List</span>.length&nbsp;input_beam&nbsp;<span class="keyword">in</span><br>
29 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;subtree1&nbsp;=&nbsp;subtree_left&nbsp;dimension_tree&nbsp;<span class="keyword">in</span><br>
30 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;subtree2&nbsp;=&nbsp;subtree_right&nbsp;dimension_tree&nbsp;<span class="keyword">in</span><br>
31 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;d1&nbsp;=&nbsp;get_root&nbsp;subtree1&nbsp;<span class="keyword">in</span><br>
32 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;d2&nbsp;=&nbsp;get_root&nbsp;subtree2&nbsp;<span class="keyword">in</span><br>
33 <br>
34 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span>&nbsp;n&nbsp;=&nbsp;(fst&nbsp;d1)&nbsp;+&nbsp;(fst&nbsp;d2)&nbsp;<span class="keyword">then</span>&nbsp;<br>
35 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
36 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;segmentation&nbsp;of&nbsp;input&nbsp;beam&nbsp;*)</span><br>
37 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;input_beam1&nbsp;=&nbsp;sublist&nbsp;input_beam&nbsp;0&nbsp;(fst&nbsp;d1)&nbsp;<span class="keyword">in</span><br>
38 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;input_beam2&nbsp;=&nbsp;sublist&nbsp;input_beam&nbsp;(fst&nbsp;d1)&nbsp;(fst&nbsp;d2)&nbsp;<span class="keyword">in</span><br>
39 <br>
40 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;evaluate&nbsp;two&nbsp;expressions&nbsp;respectively&nbsp;*)</span><br>
41 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;output_beam1&nbsp;=&nbsp;eval&nbsp;e1&nbsp;subtree1&nbsp;input_beam1&nbsp;<span class="keyword">in</span><br>
42 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;output_beam2&nbsp;=&nbsp;eval&nbsp;e2&nbsp;subtree2&nbsp;input_beam2&nbsp;<span class="keyword">in</span><br>
43 <br>
44 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;concat&nbsp;two&nbsp;output&nbsp;beams&nbsp;*)</span><br>
45 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span>&nbsp;<span class="constructor">List</span>.length&nbsp;output_beam1&nbsp;=&nbsp;snd&nbsp;d1&nbsp;<span class="keywordsign">&amp;&amp;</span>&nbsp;<span class="constructor">List</span>.length&nbsp;output_beam2&nbsp;=&nbsp;snd&nbsp;d2&nbsp;<br>
46 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">then</span>&nbsp;(output_beam1&nbsp;@&nbsp;output_beam2)&nbsp;<br>
47 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">else</span>&nbsp;raise&nbsp;(<span class="constructor">Evaluation_Error</span>&nbsp;<span class="string">"Par"</span>)<br>
48 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br>
49 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">else</span>&nbsp;raise&nbsp;(<span class="constructor">Evaluation_Error</span>&nbsp;<span class="string">"Par"</span>)&nbsp;<span class="keyword">in</span><br>
50 <br>
51 <br>
52 </code><table><tr><td></td><td><span class="comment">(** val interpret_seq : faust_exp -&gt; faust_exp -&gt; beam -&gt; beam,
53 interprets seq(e1, e2) with input beam, produces output beam.*)</span></td></tr></table><code class="code"><br>
54 <span class="keyword">let</span>&nbsp;interpret_seq&nbsp;=&nbsp;<span class="keyword">fun</span>&nbsp;e1&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;e2&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;dimension_tree&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;input_beam&nbsp;<span class="keywordsign">-&gt;</span><br>
55 <br>
56 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;dimension&nbsp;information&nbsp;*)</span><br>
57 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;n&nbsp;=&nbsp;<span class="constructor">List</span>.length&nbsp;input_beam&nbsp;<span class="keyword">in</span><br>
58 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;subtree1&nbsp;=&nbsp;subtree_left&nbsp;dimension_tree&nbsp;<span class="keyword">in</span><br>
59 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;subtree2&nbsp;=&nbsp;subtree_right&nbsp;dimension_tree&nbsp;<span class="keyword">in</span><br>
60 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;d1&nbsp;=&nbsp;get_root&nbsp;subtree1&nbsp;<span class="keyword">in</span><br>
61 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;d2&nbsp;=&nbsp;get_root&nbsp;subtree2&nbsp;<span class="keyword">in</span><br>
62 <br>
63 <br>
64 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span>&nbsp;n&nbsp;=&nbsp;fst&nbsp;d1&nbsp;<span class="keyword">then</span><br>
65 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(<br>
66 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;evaluate&nbsp;the&nbsp;first&nbsp;expression&nbsp;*)</span><br>
67 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;output_beam1&nbsp;=&nbsp;eval&nbsp;e1&nbsp;subtree1&nbsp;input_beam&nbsp;<span class="keyword">in</span><br>
68 <br>
69 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;evaluate&nbsp;the&nbsp;second&nbsp;expression&nbsp;*)</span><br>
70 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span>&nbsp;<span class="constructor">List</span>.length&nbsp;output_beam1&nbsp;=&nbsp;fst&nbsp;d2&nbsp;<br>
71 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">then</span>&nbsp;eval&nbsp;e2&nbsp;subtree2&nbsp;output_beam1<br>
72 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">else</span>&nbsp;raise&nbsp;(<span class="constructor">Evaluation_Error</span>&nbsp;<span class="string">"Seq"</span>)<br>
73 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br>
74 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">else</span>&nbsp;raise&nbsp;(<span class="constructor">Evaluation_Error</span>&nbsp;<span class="string">"Seq"</span>)&nbsp;<span class="keyword">in</span><br>
75 <br>
76 <br>
77 </code><table><tr><td></td><td><span class="comment">(** val interpret_split : faust_exp -&gt; faust_exp -&gt; beam -&gt; beam,
78 interprets split(e1, e2) with input beam, produces output beam.*)</span></td></tr></table><code class="code"><br>
79 <span class="keyword">let</span>&nbsp;interpret_split&nbsp;=&nbsp;<span class="keyword">fun</span>&nbsp;e1&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;e2&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;dimension_tree&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;input_beam&nbsp;<span class="keywordsign">-&gt;</span><br>
80 <br>
81 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;dimension&nbsp;information&nbsp;*)</span><br>
82 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;n&nbsp;=&nbsp;<span class="constructor">List</span>.length&nbsp;input_beam&nbsp;<span class="keyword">in</span><br>
83 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;subtree1&nbsp;=&nbsp;subtree_left&nbsp;dimension_tree&nbsp;<span class="keyword">in</span><br>
84 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;subtree2&nbsp;=&nbsp;subtree_right&nbsp;dimension_tree&nbsp;<span class="keyword">in</span><br>
85 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;d1&nbsp;=&nbsp;get_root&nbsp;subtree1&nbsp;<span class="keyword">in</span><br>
86 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;d2&nbsp;=&nbsp;get_root&nbsp;subtree2&nbsp;<span class="keyword">in</span><br>
87 <br>
88 <br>
89 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span>&nbsp;n&nbsp;=&nbsp;fst&nbsp;d1&nbsp;<span class="keyword">then</span><br>
90 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(<br>
91 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;evaluate&nbsp;the&nbsp;first&nbsp;expression&nbsp;*)</span><br>
92 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;output_beam1&nbsp;=&nbsp;eval&nbsp;e1&nbsp;subtree1&nbsp;input_beam&nbsp;<span class="keyword">in</span><br>
93 <br>
94 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;beam&nbsp;matching&nbsp;*)</span><br>
95 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;ref_output_beam1&nbsp;=&nbsp;ref&nbsp;(beam_add_one_memory&nbsp;output_beam1)&nbsp;<span class="keyword">in</span><br>
96 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;input_beam2&nbsp;=&nbsp;<span class="constructor">List</span>.concat&nbsp;<br>
97 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(<span class="constructor">Array</span>.to_list&nbsp;(<span class="constructor">Array</span>.make&nbsp;((fst&nbsp;d2)/(<span class="constructor">List</span>.length&nbsp;output_beam1))&nbsp;!ref_output_beam1))&nbsp;<br>
98 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">in</span><br>
99 <br>
100 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;evaluate&nbsp;the&nbsp;second&nbsp;expression&nbsp;*)</span><br>
101 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span>&nbsp;<span class="constructor">List</span>.length&nbsp;input_beam2&nbsp;=&nbsp;fst&nbsp;d2<br>
102 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">then</span>&nbsp;eval&nbsp;e2&nbsp;subtree2&nbsp;input_beam2<br>
103 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">else</span>&nbsp;raise&nbsp;(<span class="constructor">Evaluation_Error</span>&nbsp;<span class="string">"Split"</span>)<br>
104 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br>
105 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">else</span>&nbsp;raise&nbsp;(<span class="constructor">Evaluation_Error</span>&nbsp;<span class="string">"Split"</span>)&nbsp;<span class="keyword">in</span><br>
106 <br>
107 <br>
108 </code><table><tr><td></td><td><span class="comment">(** val interpret_merge : faust_exp -&gt; faust_exp -&gt; beam -&gt; beam,
109 interprets merge(e1, e2) with input beam, produces output beam.*)</span></td></tr></table><code class="code"><br>
110 <span class="keyword">let</span>&nbsp;interpret_merge&nbsp;=&nbsp;<span class="keyword">fun</span>&nbsp;e1&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;e2&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;dimension_tree&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;input_beam&nbsp;<span class="keywordsign">-&gt;</span><br>
111 <br>
112 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;dimension&nbsp;information&nbsp;*)</span><br>
113 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;n&nbsp;=&nbsp;<span class="constructor">List</span>.length&nbsp;input_beam&nbsp;<span class="keyword">in</span><br>
114 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;subtree1&nbsp;=&nbsp;subtree_left&nbsp;dimension_tree&nbsp;<span class="keyword">in</span><br>
115 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;subtree2&nbsp;=&nbsp;subtree_right&nbsp;dimension_tree&nbsp;<span class="keyword">in</span><br>
116 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;d1&nbsp;=&nbsp;get_root&nbsp;subtree1&nbsp;<span class="keyword">in</span><br>
117 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;d2&nbsp;=&nbsp;get_root&nbsp;subtree2&nbsp;<span class="keyword">in</span><br>
118 <br>
119 <br>
120 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span>&nbsp;n&nbsp;=&nbsp;fst&nbsp;d1&nbsp;<span class="keyword">then</span><br>
121 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(<br>
122 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;evaluate&nbsp;the&nbsp;first&nbsp;expression&nbsp;*)</span><br>
123 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;output_beam1&nbsp;=&nbsp;eval&nbsp;e1&nbsp;subtree1&nbsp;input_beam&nbsp;<span class="keyword">in</span><br>
124 <br>
125 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;beam&nbsp;matching&nbsp;*)</span><br>
126 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;input_beam2&nbsp;=&nbsp;<br>
127 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(<br>
128 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;fois&nbsp;=&nbsp;(snd&nbsp;d1)/(fst&nbsp;d2)&nbsp;<span class="keyword">in</span><br>
129 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;ref_beam&nbsp;=&nbsp;ref&nbsp;(sublist&nbsp;output_beam1&nbsp;0&nbsp;(fst&nbsp;d2))&nbsp;<span class="keyword">in</span><br>
130 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">for</span>&nbsp;i&nbsp;=&nbsp;1&nbsp;<span class="keyword">to</span>&nbsp;fois&nbsp;-&nbsp;1&nbsp;<span class="keyword">do</span><br>
131 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;temp_beam&nbsp;=&nbsp;sublist&nbsp;output_beam1&nbsp;(i*(fst&nbsp;d2))&nbsp;(fst&nbsp;d2)&nbsp;<span class="keyword">in</span><br>
132 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ref_beam&nbsp;:=&nbsp;<span class="constructor">List</span>.map2&nbsp;signal_add&nbsp;(!ref_beam)&nbsp;temp_beam;<br>
133 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">done</span>;<br>
134 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;!ref_beam<br>
135 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br>
136 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">in</span><br>
137 <br>
138 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;evaluate&nbsp;the&nbsp;second&nbsp;expression&nbsp;*)</span><br>
139 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span>&nbsp;<span class="constructor">List</span>.length&nbsp;input_beam2&nbsp;=&nbsp;fst&nbsp;d2<br>
140 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">then</span>&nbsp;eval&nbsp;e2&nbsp;subtree2&nbsp;input_beam2<br>
141 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">else</span>&nbsp;raise&nbsp;(<span class="constructor">Evaluation_Error</span>&nbsp;<span class="string">"Merge"</span>)<br>
142 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br>
143 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">else</span>&nbsp;raise&nbsp;(<span class="constructor">Evaluation_Error</span>&nbsp;<span class="string">"Merge"</span>)&nbsp;<span class="keyword">in</span><br>
144 <br>
145 <br>
146 </code><table><tr><td></td><td><span class="comment">(** val interpret_rec : faust_exp -&gt; faust_exp -&gt; beam -&gt; beam,
147 interprets rec(e1, e2) with input beam, produces output beam.*)</span></td></tr></table><code class="code"><br>
148 <span class="keyword">let</span>&nbsp;interpret_rec&nbsp;=&nbsp;<span class="keyword">fun</span>&nbsp;e1&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;e2&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;dimension_tree&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;input_beam&nbsp;<span class="keywordsign">-&gt;</span><br>
149 <br>
150 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;dimension&nbsp;information&nbsp;*)</span><br>
151 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;subtree1&nbsp;=&nbsp;subtree_left&nbsp;dimension_tree&nbsp;<span class="keyword">in</span><br>
152 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;subtree2&nbsp;=&nbsp;subtree_right&nbsp;dimension_tree&nbsp;<span class="keyword">in</span><br>
153 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;d1&nbsp;=&nbsp;get_root&nbsp;subtree1&nbsp;<span class="keyword">in</span><br>
154 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;d2&nbsp;=&nbsp;get_root&nbsp;subtree2&nbsp;<span class="keyword">in</span><br>
155 <br>
156 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;estimate&nbsp;stockage&nbsp;size&nbsp;for&nbsp;delay&nbsp;*)</span><br>
157 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;delay_int&nbsp;=&nbsp;1&nbsp;+&nbsp;delay&nbsp;e2&nbsp;+&nbsp;delay&nbsp;e1&nbsp;<span class="keyword">in</span><br>
158 <br>
159 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;prepare&nbsp;stockage&nbsp;*)</span><br>
160 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;memory_hashtbl&nbsp;=&nbsp;<span class="constructor">Hashtbl</span>.create&nbsp;delay_int&nbsp;<span class="keyword">in</span><br>
161 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;rate_list&nbsp;=&nbsp;ref&nbsp;(<span class="constructor">Array</span>.to_list&nbsp;(<span class="constructor">Array</span>.make&nbsp;(snd&nbsp;d1)&nbsp;0))&nbsp;<span class="keyword">in</span><br>
162 <br>
163 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><table><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td><span class="comment">(** val apply_to : 'a -&gt; ('a -&gt; 'b) -&gt; 'b *)</span></td></tr></table><code class="code"><br>
164 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;apply_to&nbsp;=&nbsp;<span class="keyword">fun</span>&nbsp;t&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;f&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;f&nbsp;t&nbsp;<span class="keyword">in</span><br>
165 <br>
166 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><table><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td><span class="comment">(** val get_value_fun_list : (int -&gt; (int list) * (value list)) -&gt; (int -&gt; value) list *)</span></td></tr></table><code class="code">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
167 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;get_value_fun_list&nbsp;=&nbsp;<span class="keyword">fun</span>&nbsp;beam_fun&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<br>
168 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;tmp&nbsp;=&nbsp;<span class="keyword">fun</span>&nbsp;beam_fun&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;i&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;t&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<br>
169 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="constructor">List</span>.nth&nbsp;(snd&nbsp;(beam_fun&nbsp;t))&nbsp;i&nbsp;<span class="keyword">in</span><br>
170 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="constructor">List</span>.map&nbsp;(tmp&nbsp;beam_fun)&nbsp;(<span class="constructor">Array</span>.to_list&nbsp;(<span class="constructor">Array</span>.init&nbsp;(snd&nbsp;d1)&nbsp;(<span class="keyword">fun</span>&nbsp;n&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;n)))&nbsp;<span class="keyword">in</span><br>
171 <br>
172 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><table><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td><span class="comment">(** val make_signal : int -&gt; (int -&gt; value) -&gt; signal, combines rate and function. *)</span></td></tr></table><code class="code"><br>
173 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;make_signal&nbsp;=&nbsp;<span class="keyword">fun</span>&nbsp;rate&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;f&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;(rate,&nbsp;f)&nbsp;<span class="keyword">in</span><br>
174 <br>
175 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><table><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td><span class="comment">(** val output_beam_fun : int -&gt; (int list) * (value list), with
176 input : time
177 output: rate list * value list *)</span></td></tr></table><code class="code"><br>
178 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;<span class="keyword">rec</span>&nbsp;output_beam_fun&nbsp;=&nbsp;<span class="keyword">fun</span>&nbsp;t&nbsp;<span class="keywordsign">-&gt;</span><br>
179 <br>
180 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;initial&nbsp;value&nbsp;in&nbsp;constrctor&nbsp;"rec&nbsp;'~'"&nbsp;*)</span><br>
181 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span>&nbsp;t&nbsp;&lt;&nbsp;0&nbsp;<span class="keyword">then</span><br>
182 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;init_rate_list&nbsp;=&nbsp;<span class="constructor">Array</span>.to_list&nbsp;(<span class="constructor">Array</span>.make&nbsp;(snd&nbsp;d1)&nbsp;0)&nbsp;<span class="keyword">in</span><br>
183 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;value_list&nbsp;=&nbsp;<span class="constructor">Array</span>.to_list&nbsp;(<span class="constructor">Array</span>.make&nbsp;(snd&nbsp;d1)&nbsp;<span class="constructor">Zero</span>)&nbsp;<span class="keyword">in</span><br>
184 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(init_rate_list,&nbsp;value_list)<br>
185 <br>
186 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;check&nbsp;stockage&nbsp;at&nbsp;time&nbsp;t&nbsp;*)</span><br>
187 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">else</span>&nbsp;<span class="keyword">if</span>&nbsp;<span class="constructor">Hashtbl</span>.mem&nbsp;memory_hashtbl&nbsp;t&nbsp;<span class="keyword">then</span>&nbsp;<br>
188 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(!rate_list,&nbsp;<span class="constructor">Hashtbl</span>.find&nbsp;memory_hashtbl&nbsp;t)<br>
189 <br>
190 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;blocks&nbsp;:&nbsp;"a&nbsp;~&nbsp;b",&nbsp;calculate&nbsp;rate&nbsp;list&nbsp;and&nbsp;value&nbsp;list&nbsp;at&nbsp;time&nbsp;t&nbsp;*)</span><br>
191 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">else</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
192 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;mid_output_fun_list&nbsp;:&nbsp;(int&nbsp;-&gt;&nbsp;value)&nbsp;list&nbsp;*)</span><br>
193 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;mid_output_fun_list&nbsp;=&nbsp;get_value_fun_list&nbsp;output_beam_fun&nbsp;<span class="keyword">in</span><br>
194 <br>
195 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;b_input_fun_list&nbsp;:&nbsp;(int&nbsp;-&gt;&nbsp;value)&nbsp;list&nbsp;*)</span><br>
196 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;b_input_fun_list&nbsp;=&nbsp;<span class="constructor">List</span>.map&nbsp;<br>
197 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(<span class="keyword">fun</span>&nbsp;s&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="keyword">fun</span>&nbsp;t&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;s&nbsp;(t&nbsp;-&nbsp;1))&nbsp;<br>
198 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(sublist&nbsp;mid_output_fun_list&nbsp;0&nbsp;(fst&nbsp;d2))&nbsp;<span class="keyword">in</span><br>
199 <br>
200 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;b_input_beam&nbsp;:&nbsp;signal&nbsp;list&nbsp;*)</span><br>
201 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;b_input_beam&nbsp;=&nbsp;<span class="constructor">List</span>.map2&nbsp;make_signal&nbsp;<br>
202 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(sublist&nbsp;!rate_list&nbsp;0&nbsp;(fst&nbsp;d2))<br>
203 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b_input_fun_list&nbsp;<span class="keyword">in</span><br>
204 <br>
205 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;evaluation&nbsp;of&nbsp;block&nbsp;"b"&nbsp;*)</span><br>
206 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;b_output_beam&nbsp;=&nbsp;(eval&nbsp;e2&nbsp;subtree2&nbsp;b_input_beam)&nbsp;<span class="keyword">in</span><br>
207 <br>
208 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;evaluation&nbsp;of&nbsp;block&nbsp;"a"&nbsp;*)</span><br>
209 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;a_input_beam&nbsp;=&nbsp;b_output_beam&nbsp;@&nbsp;input_beam&nbsp;<span class="keyword">in</span><br>
210 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;mid_output_beam&nbsp;=&nbsp;eval&nbsp;e1&nbsp;subtree1&nbsp;a_input_beam&nbsp;<span class="keyword">in</span><br>
211 <br>
212 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;calculate&nbsp;rate&nbsp;list&nbsp;and&nbsp;value&nbsp;list&nbsp;at&nbsp;time&nbsp;t&nbsp;*)</span><br>
213 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;mid_output_rate_list&nbsp;=&nbsp;<span class="constructor">List</span>.map&nbsp;fst&nbsp;mid_output_beam&nbsp;<span class="keyword">in</span><br>
214 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;mid_output_value_list&nbsp;=&nbsp;<span class="constructor">List</span>.map&nbsp;(apply_to&nbsp;t)&nbsp;(<span class="constructor">List</span>.map&nbsp;snd&nbsp;mid_output_beam)&nbsp;<span class="keyword">in</span><br>
215 <br>
216 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;update&nbsp;stockage&nbsp;*)</span><br>
217 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;()&nbsp;=&nbsp;(rate_list&nbsp;:=&nbsp;mid_output_rate_list)&nbsp;<span class="keyword">in</span><br>
218 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;()&nbsp;=&nbsp;<span class="constructor">Hashtbl</span>.add&nbsp;memory_hashtbl&nbsp;t&nbsp;mid_output_value_list&nbsp;<span class="keyword">in</span><br>
219 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;()&nbsp;=&nbsp;<span class="constructor">Hashtbl</span>.remove&nbsp;memory_hashtbl&nbsp;(t&nbsp;-&nbsp;delay_int)&nbsp;<span class="keyword">in</span><br>
220 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(mid_output_rate_list,&nbsp;mid_output_value_list)&nbsp;<span class="keyword">in</span><br>
221 <br>
222 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;output_beam&nbsp;:&nbsp;signal&nbsp;list&nbsp;*)</span><br>
223 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;output_beam&nbsp;=&nbsp;<span class="constructor">List</span>.map2&nbsp;make_signal&nbsp;!rate_list&nbsp;(get_value_fun_list&nbsp;output_beam_fun)&nbsp;<span class="keyword">in</span><br>
224 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;output_beam&nbsp;<span class="keyword">in</span><br>
225 <br>
226 <br>
227 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><table><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td><span class="comment">(** Call for previous functions *)</span></td></tr></table><code class="code"><br>
228 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">match</span>&nbsp;exp_faust&nbsp;<span class="keyword">with</span><br>
229 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keywordsign">|</span><span class="constructor">Const</span>&nbsp;v&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;interpret_const&nbsp;v&nbsp;input_beam<br>
230 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keywordsign">|</span><span class="constructor">Ident</span>&nbsp;s&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;interpret_ident&nbsp;s&nbsp;input_beam<br>
231 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keywordsign">|</span><span class="constructor">Par</span>&nbsp;(e1,&nbsp;e2)&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;interpret_par&nbsp;e1&nbsp;e2&nbsp;dimension_tree&nbsp;input_beam<br>
232 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keywordsign">|</span><span class="constructor">Seq</span>&nbsp;(e1,&nbsp;e2)&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;interpret_seq&nbsp;e1&nbsp;e2&nbsp;dimension_tree&nbsp;input_beam<br>
233 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keywordsign">|</span><span class="constructor">Split</span>&nbsp;(e1,&nbsp;e2)&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;interpret_split&nbsp;e1&nbsp;e2&nbsp;dimension_tree&nbsp;input_beam<br>
234 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keywordsign">|</span><span class="constructor">Merge</span>&nbsp;(e1,&nbsp;e2)&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;interpret_merge&nbsp;e1&nbsp;e2&nbsp;dimension_tree&nbsp;input_beam<br>
235 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keywordsign">|</span><span class="constructor">Rec</span>&nbsp;(e1,&nbsp;e2)&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;interpret_rec&nbsp;e1&nbsp;e2&nbsp;dimension_tree&nbsp;input_beam</code></body></html>