about summary refs log blame commit diff stats
path: root/html/mutable.mu.html
blob: 82c7ae1063efe5aa43b4dd40480686bfb3b49367 (plain) (tree)
class="s">"Constant">1</span> <span class="Delimiter">}</span> <span class="Comment"># still work to do</span> next-rank:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> queens first:square<span class="Special"> &lt;- </span>first queens existing-rank:num<span class="Special"> &lt;- </span>get first, <span class="Constant">rank:offset</span> next-rank<span class="Special"> &lt;- </span>add existing-rank, <span class="Constant">1</span> <span class="Delimiter">}</span> result<span class="Special"> &lt;- </span>copy <span class="Constant">0</span> next-file:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> done?:boolean<span class="Special"> &lt;- </span>greater-or-equal next-file, n <span class="muControl">break-if</span> done? curr:square<span class="Special"> &lt;- </span>merge next-rank, next-file <span class="Delimiter">{</span> curr-conflicts?:boolean<span class="Special"> &lt;- </span>conflict? curr, queens <span class="muControl">break-if</span> curr-conflicts? new-queens:&amp;:list:square<span class="Special"> &lt;- </span>push curr, queens sub-result:num<span class="Special"> &lt;- </span>nqueens n, new-queens result<span class="Special"> &lt;- </span>add result, sub-result <span class="Delimiter">}</span> next-file<span class="Special"> &lt;- </span>add next-file, <span class="Constant">1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] <span class="muRecipe">def</span> conflict? curr:square, queens:&amp;:list:square<span class="muRecipe"> -&gt; </span>result:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> result1:boolean<span class="Special"> &lt;- </span>conflicting-file? curr, queens <span class="muControl">reply-if</span> result1, result1 result2:boolean<span class="Special"> &lt;- </span>conflicting-diagonal? curr, queens <span class="muControl">reply</span> result2 ] <span class="muRecipe">def</span> conflicting-file? curr:square, queens:&amp;:list:square<span class="muRecipe"> -&gt; </span>result:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> curr-file:num<span class="Special"> &lt;- </span>get curr, <span class="Constant">file:offset</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> queens q:square<span class="Special"> &lt;- </span>first queens qfile:num<span class="Special"> &lt;- </span>get q, <span class="Constant">file:offset</span> file-match?:boolean<span class="Special"> &lt;- </span>equal curr-file, qfile <span class="muControl">reply-if</span> file-match?, <span class="Constant">1/conflict-found</span> queens<span class="Special"> &lt;- </span>rest queens <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="muControl">reply</span> <span class="Constant">0/no-conflict-found</span> ] <span class="muRecipe">def</span> conflicting-diagonal? curr:square, queens:&amp;:list:square<span class="muRecipe"> -&gt; </span>result:boolean [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> curr-rank:num<span class="Special"> &lt;- </span>get curr, <span class="Constant">rank:offset</span> curr-file:num<span class="Special"> &lt;- </span>get curr, <span class="Constant">file:offset</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> queens q:square<span class="Special"> &lt;- </span>first queens qrank:num<span class="Special"> &lt;- </span>get q, <span class="Constant">rank:offset</span> qfile:num<span class="Special"> &lt;- </span>get q, <span class="Constant">file:offset</span> rank-delta:num<span class="Special"> &lt;- </span>subtract qrank, curr-rank file-delta:num<span class="Special"> &lt;- </span>subtract qfile, curr-file rank-delta<span class="Special"> &lt;- </span>abs rank-delta file-delta<span class="Special"> &lt;- </span>abs file-delta diagonal-match?:boolean<span class="Special"> &lt;- </span>equal rank-delta, file-delta <span class="muControl">reply-if</span> diagonal-match?, <span class="Constant">1/conflict-found</span> queens<span class="Special"> &lt;- </span>rest queens <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="muControl">reply</span> <span class="Constant">0/no-conflict-found</span> ] <span class="muRecipe">def</span> main [ nqueens <span class="Constant">4</span> $dump-trace <span class="Constant">[app]</span> ] </pre> </body> </html> <!-- vim: set foldmethod=manual : -->