99 lines
36 KiB
HTML
99 lines
36 KiB
HTML
<!-- vim: ft=html -->
|
|
<!-- TITLE: a moderately cursed dollcode implementation-->
|
|
<!-- DATE: 2024-10-24 23:10:14 -->
|
|
recently, dollcode (two track pharmacode except rewritten by autistic transgender girlthings) has become a thing frequently utilized by this one's friends.
|
|
this is inconvenient, because many of them have written their own transcoders for the format which can handle arbitrarily large numbers.
|
|
the only two translators (<a href='https://noe.sh/dollcode/'>this</a> and <a href='https://999eagle.moe/dollcode/'>this</a>) this one could find online did not support messages that were represented as numbers larger than the 64 bit integer limit.
|
|
thusly, it simply could not read some of its friend's messages.
|
|
<br><br>
|
|
the optimal solution to such a problem was probably either asking the sender what their message said or asking them for their transcoder program.
|
|
this one did neither.
|
|
<hr>
|
|
below, one may find a very good and reasonable dollcode translator tool. one may tell it is good and reasonable because it contains a y combinator written in python lambda statements.
|
|
<pre>
|
|
~/src/dollcode λ cat dollcode
|
|
<span class="Comment"><span class="-spell"><span class="-keyword"><span class="-nospell">#!/usr/bin/env -S bash -c 'python3 -c "__import__(\"sys\").setrecursionlimit(2**31-1); exec(open(\"$(which dollcode)\").read())" "$@"' _ </span></span></span></span>
|
|
<span class="-variable"><span class="-function"><span class="-function-builtin">print</span></span></span><span class="-punctuation-bracket"><span class="MatchParen">(</span></span><span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">d</span></span><span class="-punctuation-delimiter">,</span> <span class="-variable"><span class="-variable">ud</span></span><span class="-punctuation-delimiter">,</span> <span class="-variable"><span class="-variable">args</span></span><span class="-punctuation-delimiter">:</span>
|
|
<span class="-variable"><span class="-function">d</span></span><span class="-punctuation-bracket">(</span><span class="-variable"><span class="-function"><span class="-function-builtin"><span class="Type">int</span></span></span></span><span class="-punctuation-bracket">(</span><span class="-variable">args</span><span class="-punctuation-bracket">[</span><span class="Operator">-</span><span class="Number">1</span><span class="-punctuation-bracket">]</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span> <span class="-keyword">if</span> <span class="String">'-n'</span> <span class="-keyword-operator">in</span> <span class="-variable">args</span> <span class="-keyword">else</span>
|
|
<span class="-variable"><span class="-function">d</span></span><span class="-punctuation-bracket">(</span><span class="-variable"><span class="-function"><span class="-function-builtin"><span class="Type">int</span></span></span></span><span class="-punctuation-bracket">(</span><span class="String">''</span><span class="-punctuation-delimiter">.</span><span class="-variable"><span class="-variable"><span class="-function">join</span></span></span><span class="-punctuation-bracket">(</span><span class="-variable"><span class="-function"><span class="-function-builtin">map</span></span></span><span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">x</span></span><span class="-punctuation-delimiter">:</span> <span class="-variable"><span class="-function"><span class="-function-builtin"><span class="Type">str</span></span></span></span><span class="-punctuation-bracket">(</span><span class="-variable"><span class="-function"><span class="-function-builtin">hex</span></span></span><span class="-punctuation-bracket">(</span><span class="-variable"><span class="-function"><span class="-function-builtin">ord</span></span></span><span class="-punctuation-bracket">(</span><span class="-variable">x</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">[</span><span class="Number">2</span><span class="-punctuation-delimiter">:</span><span class="-punctuation-delimiter">:</span><span class="-punctuation-bracket">]</span><span class="-punctuation-bracket">)</span><span class="-punctuation-delimiter">,</span> <span class="-variable">args</span><span class="-punctuation-bracket">[</span><span class="Operator">-</span><span class="Number">1</span><span class="-punctuation-bracket">]</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-delimiter">,</span> <span class="Number">16</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span> <span class="-keyword">if</span> <span class="String">'-a'</span> <span class="-keyword-operator">in</span> <span class="-variable">args</span> <span class="-keyword">else</span>
|
|
<span class="-variable"><span class="-function">ud</span></span><span class="-punctuation-bracket">(</span><span class="-variable">args</span><span class="-punctuation-bracket">[</span><span class="Operator">-</span><span class="Number">1</span><span class="-punctuation-bracket">]</span><span class="-punctuation-bracket">)</span> <span class="-keyword">if</span> <span class="String">'-dn'</span> <span class="-keyword-operator">in</span> <span class="-variable">args</span> <span class="-keyword">else</span>
|
|
<span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">h</span></span><span class="-punctuation-delimiter">:</span> <span class="String">''</span><span class="-punctuation-delimiter">.</span><span class="-variable"><span class="-variable"><span class="-function">join</span></span></span><span class="-punctuation-bracket">(</span><span class="-variable"><span class="-function"><span class="-function-builtin">map</span></span></span><span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">i</span></span><span class="-punctuation-delimiter">:</span> <span class="-variable"><span class="-function"><span class="-function-builtin">chr</span></span></span><span class="-punctuation-bracket">(</span><span class="-variable"><span class="-function"><span class="-function-builtin"><span class="Type">int</span></span></span></span><span class="-punctuation-bracket">(</span><span class="-variable">h</span><span class="-punctuation-bracket">[</span><span class="-variable">i</span><span class="-punctuation-delimiter">:</span><span class="-variable">i</span><span class="Operator">+</span><span class="Number">2</span><span class="-punctuation-bracket">]</span><span class="-punctuation-delimiter">,</span> <span class="Number">16</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-delimiter">,</span> <span class="-variable"><span class="-function"><span class="-function-builtin"><span class="Type">range</span></span></span></span><span class="-punctuation-bracket">(</span><span class="Number">0</span><span class="-punctuation-delimiter">,</span> <span class="-variable"><span class="-function"><span class="-function-builtin">len</span></span></span><span class="-punctuation-bracket">(</span><span class="-variable">h</span><span class="-punctuation-bracket">)</span><span class="-punctuation-delimiter">,</span> <span class="Number">2</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">(</span><span class="-variable"><span class="-function"><span class="-function-builtin">hex</span></span></span><span class="-punctuation-bracket">(</span><span class="-variable"><span class="-function">ud</span></span><span class="-punctuation-bracket">(</span><span class="-variable">args</span><span class="-punctuation-bracket">[</span><span class="Operator">-</span><span class="Number">1</span><span class="-punctuation-bracket">]</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">[</span><span class="Number">2</span><span class="-punctuation-delimiter">:</span><span class="-punctuation-delimiter">:</span><span class="-punctuation-bracket">]</span><span class="-punctuation-bracket">)</span> <span class="-keyword">if</span> <span class="String">'-da'</span> <span class="-keyword-operator">in</span> <span class="-variable">args</span> <span class="-keyword">else</span>
|
|
<span class="String">"0x6e6174<span class="-string-escape">\'</span>s dollcode conversion tool<span class="-string-escape">\n</span>"</span>
|
|
<span class="String">"<span class="-string-escape">\t</span>-n: encode decimal number as dollcode<span class="-string-escape">\n</span>"</span>
|
|
<span class="String">"<span class="-string-escape">\t</span>-a: encode ascii string as dollcode<span class="-string-escape">\n</span>"</span>
|
|
<span class="String">"<span class="-string-escape">\t</span>-dn: decode dollcode as decimal<span class="-string-escape">\n</span>"</span>
|
|
<span class="String">"<span class="-string-escape">\t</span>-da: decode dollcode as ascii string"</span>
|
|
<span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">n</span></span><span class="-punctuation-delimiter">:</span> <span class="String">''</span><span class="-punctuation-delimiter">.</span><span class="-variable"><span class="-variable"><span class="-function">join</span></span></span><span class="-punctuation-bracket">(</span><span class="-variable"><span class="-function"><span class="-function-builtin">map</span></span></span><span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">n</span></span><span class="-punctuation-delimiter">:</span> <span class="String">''</span><span class="-punctuation-delimiter">.</span><span class="-variable"><span class="-variable"><span class="-function">join</span></span></span><span class="-punctuation-bracket">(</span><span class="-punctuation-bracket">[</span><span class="String">'▖'</span><span class="-punctuation-delimiter">,</span><span class="String">'▘'</span><span class="-punctuation-delimiter">,</span><span class="String">'▌'</span><span class="-punctuation-bracket">]</span><span class="-punctuation-bracket">[</span><span class="-variable"><span class="-function"><span class="-function-builtin"><span class="Type">int</span></span></span></span><span class="-punctuation-bracket">(</span><span class="-variable">n</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">]</span><span class="-punctuation-bracket">)</span><span class="-punctuation-delimiter">,</span> <span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">f</span></span><span class="-punctuation-delimiter">:</span> <span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">x</span></span><span class="-punctuation-delimiter">:</span> <span class="-variable"><span class="-function">f</span></span><span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">y</span></span><span class="-punctuation-delimiter">:</span> <span class="-variable"><span class="-function">x</span></span><span class="-punctuation-bracket">(</span><span class="-variable">x</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">(</span><span class="-variable">y</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span> <span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">x</span></span><span class="-punctuation-delimiter">:</span> <span class="-variable"><span class="-function">f</span></span><span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">y</span></span><span class="-punctuation-delimiter">:</span> <span class="-variable"><span class="-function">x</span></span><span class="-punctuation-bracket">(</span><span class="-variable">x</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">(</span><span class="-variable">y</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">f</span></span><span class="-punctuation-delimiter">:</span> <span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">n</span></span><span class="-punctuation-delimiter">:</span> <span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">x</span></span><span class="-punctuation-delimiter">,</span> <span class="-variable"><span class="-variable">y</span></span><span class="-punctuation-delimiter">:</span> <span class="-function">str</span><span class="-punctuation-bracket">(</span><span class="-variable"><span class="-function">f</span></span><span class="-punctuation-bracket">(</span><span class="-variable">x</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span> <span class="Operator">+</span> <span class="-variable"><span class="-function"><span class="-function-builtin"><span class="Type">str</span></span></span></span><span class="-punctuation-bracket">(</span><span class="-variable">y</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">(</span><span class="Operator">*</span><span class="-variable"><span class="-function"><span class="-function-builtin">divmod</span></span></span><span class="-punctuation-bracket">(</span><span class="-variable">n</span><span class="Operator">-</span><span class="Number">1</span><span class="-punctuation-delimiter">,</span> <span class="Number">3</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span> <span class="-keyword">if</span> <span class="-variable">n</span> <span class="-keyword">else</span> <span class="String">''</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">(</span><span class="-variable">n</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-delimiter">,</span>
|
|
<span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">d</span></span><span class="-punctuation-delimiter">:</span> <span class="-variable"><span class="-constant-builtin"><span class="-function"><span class="-function-builtin">__import__</span></span></span></span><span class="-punctuation-bracket">(</span><span class="String">'functools'</span><span class="-punctuation-bracket">)</span><span class="-punctuation-delimiter">.</span><span class="-variable"><span class="-variable"><span class="-function">reduce</span></span></span><span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">a</span></span><span class="-punctuation-delimiter">,</span> <span class="-variable"><span class="-variable">d</span></span><span class="-punctuation-delimiter">:</span> <span class="-variable">a</span> <span class="Operator">*</span> <span class="Number">3</span> <span class="Operator">+</span> <span class="-variable">d</span><span class="-punctuation-delimiter">,</span> <span class="-variable"><span class="-function"><span class="-function-builtin">map</span></span></span><span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">x</span></span><span class="-punctuation-delimiter">:</span> <span class="-punctuation-bracket">{</span><span class="String">'▖'</span><span class="-punctuation-delimiter">:</span> <span class="Number">1</span><span class="-punctuation-delimiter">,</span> <span class="String">'▘'</span><span class="-punctuation-delimiter">:</span> <span class="Number">2</span><span class="-punctuation-delimiter">,</span> <span class="String">'▌'</span><span class="-punctuation-delimiter">:</span> <span class="Number">3</span><span class="-punctuation-bracket">}</span><span class="-punctuation-bracket">[</span><span class="-variable">x</span><span class="-punctuation-bracket">]</span><span class="-punctuation-delimiter">,</span> <span class="-variable">d</span><span class="-punctuation-bracket">)</span><span class="-punctuation-delimiter">,</span> <span class="Number">0</span><span class="-punctuation-bracket">)</span><span class="-punctuation-delimiter">,</span>
|
|
<span class="-variable"><span class="-constant-builtin"><span class="-function"><span class="-function-builtin">__import__</span></span></span></span><span class="-punctuation-bracket">(</span><span class="String">'sys'</span><span class="-punctuation-bracket">)</span><span class="-punctuation-delimiter">.</span><span class="-variable"><span class="-variable">argv</span></span><span class="-punctuation-bracket">)</span>
|
|
<span class="-punctuation-bracket"><span class="MatchParen">)</span></span>
|
|
</pre>
|
|
also, it can be written in one line (ignoring the shebang):
|
|
<pre>
|
|
~/src/dollcode λ cat $(which dollcode)
|
|
<span class="Comment"><span class="-spell"><span class="-keyword"><span class="-nospell">#!/usr/bin/env -S bash -c 'python3 -c "__import__(\"sys\").setrecursionlimit(2**31-1); exec(open(\"$(which dollcode)\").read())" "$@"' _ </span></span></span></span>
|
|
<span class="-variable"><span class="-function"><span class="-function-builtin">print</span></span></span><span class="-punctuation-bracket">(</span><span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">d</span></span><span class="-punctuation-delimiter">,</span><span class="-variable"><span class="-variable">ud</span></span><span class="-punctuation-delimiter">,</span><span class="-variable"><span class="-variable">args</span></span><span class="-punctuation-delimiter">:</span><span class="-variable"><span class="-function">d</span></span><span class="-punctuation-bracket">(</span><span class="-variable"><span class="-function"><span class="-function-builtin"><span class="Type">int</span></span></span></span><span class="-punctuation-bracket">(</span><span class="-variable">args</span><span class="-punctuation-bracket">[</span><span class="Operator">-</span><span class="Number">1</span><span class="-punctuation-bracket">]</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-keyword">if</span><span class="String">'-n'</span><span class="-keyword-operator">in</span> <span class="-variable">args</span> <span class="-keyword">else</span> <span class="-variable"><span class="-function">d</span></span><span class="-punctuation-bracket">(</span><span class="-variable"><span class="-function"><span class="-function-builtin"><span class="Type">int</span></span></span></span><span class="-punctuation-bracket">(</span><span class="String">''</span><span class="-punctuation-delimiter">.</span><span class="-variable"><span class="-variable"><span class="-function">join</span></span></span><span class="-punctuation-bracket">(</span><span class="-variable"><span class="-function"><span class="-function-builtin">map</span></span></span><span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">x</span></span><span class="-punctuation-delimiter">:</span><span class="-variable"><span class="-function"><span class="-function-builtin"><span class="Type">str</span></span></span></span><span class="-punctuation-bracket">(</span><span class="-variable"><span class="-function"><span class="-function-builtin">hex</span></span></span><span class="-punctuation-bracket">(</span><span class="-variable"><span class="-function"><span class="-function-builtin">ord</span></span></span><span class="-punctuation-bracket">(</span><span class="-variable">x</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">[</span><span class="Number">2</span><span class="-punctuation-delimiter">:</span><span class="-punctuation-delimiter">:</span><span class="-punctuation-bracket">]</span><span class="-punctuation-bracket">)</span><span class="-punctuation-delimiter">,</span><span class="-variable">args</span><span class="-punctuation-bracket">[</span><span class="Operator">-</span><span class="Number">1</span><span class="-punctuation-bracket">]</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-delimiter">,</span><span class="Number">16</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-keyword">if</span><span class="String">'-a'</span><span class="-keyword-operator">in</span> <span class="-variable">args</span> <span class="-keyword">else</span> <span class="-variable"><span class="-function">ud</span></span><span class="-punctuation-bracket">(</span><span class="-variable">args</span><span class="-punctuation-bracket">[</span><span class="Operator">-</span><span class="Number">1</span><span class="-punctuation-bracket">]</span><span class="-punctuation-bracket">)</span><span class="-keyword">if</span><span class="String">'-dn'</span><span class="-keyword-operator">in</span> <span class="-variable">args</span> <span class="-keyword">else</span><span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">h</span></span><span class="-punctuation-delimiter">:</span><span class="String">''</span><span class="-punctuation-delimiter">.</span><span class="-variable"><span class="-variable"><span class="-function">join</span></span></span><span class="-punctuation-bracket">(</span><span class="-variable"><span class="-function"><span class="-function-builtin">map</span></span></span><span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">i</span></span><span class="-punctuation-delimiter">:</span><span class="-variable"><span class="-function"><span class="-function-builtin">chr</span></span></span><span class="-punctuation-bracket">(</span><span class="-variable"><span class="-function"><span class="-function-builtin"><span class="Type">int</span></span></span></span><span class="-punctuation-bracket">(</span><span class="-variable">h</span><span class="-punctuation-bracket">[</span><span class="-variable">i</span><span class="-punctuation-delimiter">:</span><span class="-variable">i</span><span class="Operator">+</span><span class="Number">2</span><span class="-punctuation-bracket">]</span><span class="-punctuation-delimiter">,</span><span class="Number">16</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-delimiter">,</span><span class="-variable"><span class="-function"><span class="-function-builtin"><span class="Type">range</span></span></span></span><span class="-punctuation-bracket">(</span><span class="Number">0</span><span class="-punctuation-delimiter">,</span><span class="-variable"><span class="-function"><span class="-function-builtin">len</span></span></span><span class="-punctuation-bracket">(</span><span class="-variable">h</span><span class="-punctuation-bracket">)</span><span class="-punctuation-delimiter">,</span><span class="Number">2</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">(</span><span class="-variable"><span class="-function"><span class="-function-builtin">hex</span></span></span><span class="-punctuation-bracket">(</span><span class="-variable"><span class="-function">ud</span></span><span class="-punctuation-bracket">(</span><span class="-variable">args</span><span class="-punctuation-bracket">[</span><span class="Operator">-</span><span class="Number">1</span><span class="-punctuation-bracket">]</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">[</span><span class="Number">2</span><span class="-punctuation-delimiter">:</span><span class="-punctuation-delimiter">:</span><span class="-punctuation-bracket">]</span><span class="-punctuation-bracket">)</span><span class="-keyword">if</span><span class="String">'-da'</span><span class="-keyword-operator">in</span> <span class="-variable">args</span> <span class="-keyword">else</span><span class="String">"0x6e6174<span class="-string-escape">\'</span>s dollcode conversion tool<span class="-string-escape">\n</span><span class="-string-escape">\t</span>-n: encode decimal number as dollcode<span class="-string-escape">\n</span><span class="-string-escape">\t</span>-a: encode ascii string as dollcode<span class="-string-escape">\n</span><span class="-string-escape">\t</span>-dn: decode dollcode as decimal<span class="-string-escape">\n</span><span class="-string-escape">\t</span>-da:decode dollcode as ascii string"</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">n</span></span><span class="-punctuation-delimiter">:</span><span class="String">''</span><span class="-punctuation-delimiter">.</span><span class="-variable"><span class="-variable"><span class="-function">join</span></span></span><span class="-punctuation-bracket">(</span><span class="-variable"><span class="-function"><span class="-function-builtin">map</span></span></span><span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">n</span></span><span class="-punctuation-delimiter">:</span><span class="String">''</span><span class="-punctuation-delimiter">.</span><span class="-variable"><span class="-variable"><span class="-function">join</span></span></span><span class="-punctuation-bracket">(</span><span class="-punctuation-bracket">[</span><span class="String">'▖'</span><span class="-punctuation-delimiter">,</span><span class="String">'▘'</span><span class="-punctuation-delimiter">,</span><span class="String">'▌'</span><span class="-punctuation-bracket">]</span><span class="-punctuation-bracket">[</span><span class="-variable"><span class="-function"><span class="-function-builtin"><span class="Type">int</span></span></span></span><span class="-punctuation-bracket">(</span><span class="-variable">n</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">]</span><span class="-punctuation-bracket">)</span><span class="-punctuation-delimiter">,</span><span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">f</span></span><span class="-punctuation-delimiter">:</span><span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">x</span></span><span class="-punctuation-delimiter">:</span><span class="-variable"><span class="-function">f</span></span><span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">y</span></span><span class="-punctuation-delimiter">:</span><span class="-variable"><span class="-function">x</span></span><span class="-punctuation-bracket">(</span><span class="-variable">x</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">(</span><span class="-variable">y</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">x</span></span><span class="-punctuation-delimiter">:</span><span class="-variable"><span class="-function">f</span></span><span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">y</span></span><span class="-punctuation-delimiter">:</span><span class="-variable"><span class="-function">x</span></span><span class="-punctuation-bracket">(</span><span class="-variable">x</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">(</span><span class="-variable">y</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">f</span></span><span class="-punctuation-delimiter">:</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">n</span></span><span class="-punctuation-delimiter">:</span><span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">x</span></span><span class="-punctuation-delimiter">,</span><span class="-variable"><span class="-variable">y</span></span><span class="-punctuation-delimiter">:</span><span class="-function">str</span><span class="-punctuation-bracket">(</span><span class="-variable"><span class="-function">f</span></span><span class="-punctuation-bracket">(</span><span class="-variable">x</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="Operator">+</span><span class="-variable"><span class="-function"><span class="-function-builtin"><span class="Type">str</span></span></span></span><span class="-punctuation-bracket">(</span><span class="-variable">y</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">(</span><span class="Operator">*</span><span class="-variable"><span class="-function"><span class="-function-builtin">divmod</span></span></span><span class="-punctuation-bracket">(</span><span class="-variable">n</span><span class="Operator">-</span><span class="Number">1</span><span class="-punctuation-delimiter">,</span><span class="Number">3</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-keyword">if</span> <span class="-variable">n</span> <span class="-keyword">else</span><span class="String">''</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">(</span><span class="-variable">n</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span><span class="-punctuation-delimiter">,</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">d</span></span><span class="-punctuation-delimiter">:</span><span class="-variable"><span class="-constant-builtin"><span class="-function"><span class="-function-builtin">__import__</span></span></span></span><span class="-punctuation-bracket">(</span><span class="String">'functools'</span><span class="-punctuation-bracket">)</span><span class="-punctuation-delimiter">.</span><span class="-variable"><span class="-variable"><span class="-function">reduce</span></span></span><span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">a</span></span><span class="-punctuation-delimiter">,</span><span class="-variable"><span class="-variable">d</span></span><span class="-punctuation-delimiter">:</span><span class="-variable">a</span><span class="Operator">*</span><span class="Number">3</span><span class="Operator">+</span><span class="-variable">d</span><span class="-punctuation-delimiter">,</span><span class="-variable"><span class="-function"><span class="-function-builtin">map</span></span></span><span class="-punctuation-bracket">(</span><span class="-keyword-function">lambda</span> <span class="-variable"><span class="-variable">x</span></span><span class="-punctuation-delimiter">:</span><span class="-punctuation-bracket">{</span><span class="String">'▖'</span><span class="-punctuation-delimiter">:</span><span class="Number">1</span><span class="-punctuation-delimiter">,</span><span class="String">'▘'</span><span class="-punctuation-delimiter">:</span><span class="Number">2</span><span class="-punctuation-delimiter">,</span><span class="String">'▌'</span><span class="-punctuation-delimiter">:</span><span class="Number">3</span><span class="-punctuation-bracket">}</span><span class="-punctuation-bracket">[</span><span class="-variable">x</span><span class="-punctuation-bracket">]</span><span class="-punctuation-delimiter">,</span><span class="-variable">d</span><span class="-punctuation-bracket">)</span><span class="-punctuation-delimiter">,</span><span class="Number">0</span><span class="-punctuation-bracket">)</span><span class="-punctuation-delimiter">,</span><span class="-variable"><span class="-constant-builtin"><span class="-function"><span class="-function-builtin">__import__</span></span></span></span><span class="-punctuation-bracket">(</span><span class="String">'sys'</span><span class="-punctuation-bracket">)</span><span class="-punctuation-delimiter">.</span><span class="-variable"><span class="-variable">argv</span></span><span class="-punctuation-bracket">)</span><span class="-punctuation-bracket">)</span>
|
|
</pre>
|
|
python is a very good language. this is observable in that it allows integers to have arbitrarily$[make-footnote "up to a value that the user can change at runtime"] many digits.
|
|
it isn't really sure why python allows this, but it is glad it does, because it is funny.
|
|
one may wonder: "why is the shebang like that?"
|
|
the answer is because it did not want to set the recursion limit inside of the actual program, and decided it would be amusing to have a really weird shebang instead.
|
|
<hr>
|
|
bafflingly, this program works.
|
|
<pre>
|
|
~ λ dollcode -a nat
|
|
▖▖▖▖▘▖▖▖▖▘▌▖▖▖▘
|
|
</pre>
|
|
<pre>
|
|
~ λ dollcode -da $(dollcode -a nat)
|
|
nat
|
|
</pre>
|
|
it is very efficient:
|
|
<pre>
|
|
~ λ dollcode -a "$(for i in {0..65536}; do echo -ne a; done)" >/dev/null & pid=$!; while kill -0 $pid 2>/dev/null; do pmap -x $pid | tail -n 1 | awk '{print ""$3/1024/1024 " GB"}'; sleep .5; done; wait $pid
|
|
[1] 11113
|
|
0.0247803 GB
|
|
0.261642 GB
|
|
0.625462 GB
|
|
0.982468 GB
|
|
1.34475 GB
|
|
1.69653 GB
|
|
2.07035 GB
|
|
2.43603 GB
|
|
2.80609 GB
|
|
3.16292 GB
|
|
3.53598 GB
|
|
3.90202 GB
|
|
4.27491 GB
|
|
4.63856 GB
|
|
5.02195 GB
|
|
5.37629 GB
|
|
5.75089 GB
|
|
6.13502 GB
|
|
6.48058 GB
|
|
6.85527 GB
|
|
7.24199 GB
|
|
7.6222 GB
|
|
7.96089 GB
|
|
8.33753 GB
|
|
8.719 GB
|
|
9.0616 GB
|
|
9.44017 GB
|
|
9.82001 GB
|
|
10.1397 GB
|
|
10.526 GB
|
|
10.9109 GB
|
|
11.0703 GB
|
|
10.956 GB
|
|
10.8826 GB
|
|
10.8184 GB
|
|
0 GB
|
|
[1] + done dollcode -a "$(for i in {0..65536}; do echo -ne a; done)" > /dev/null
|
|
</pre>$[make-footnote 'it had to kill firefox to perform this test']
|
|
<pre>
|
|
~ λ time dollcode -a "$(for i in {0..65536}; do echo -ne a; done)" >/dev/null
|
|
dollcode -a "$(for i in {0..65536}; do echo -ne a; done)" > /dev/null 13.35s user 4.77s system 99% cpu 18.168 total
|
|
</pre>$[make-footnote 'one must not worry, it is only like that for large inputs. this one is pretty sure there is some exponential time (and memory) complexity in there somewhere']
|
|
<br>
|
|
$[put-footnotes]
|