Created
February 10, 2026 07:39
-
-
Save Thevitebsk/af6e10fd9d5a82962ff8e7a16997763b to your computer and use it in GitHub Desktop.
yes this is actually this big
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests,bs4 | |
| langs=[];p=m=0 | |
| soup=bs4.BeautifulSoup(requests.get('https://esolangs.org/wiki/Semi-serious_language_list').text,'html.parser') | |
| for i in soup.find_all('a'): | |
| langs.append(str(i)) | |
| while p!=len(langs): | |
| if "/wiki/"not in str(langs[p]):langs.pop(p);p-=1 | |
| p+=1 | |
| p=0 | |
| langs=langs[2:139] | |
| def atol(x:str)-> str: | |
| x=x.split('href="/wiki/')[1] | |
| x=x.split('" title=')[0] | |
| return "https://esolangs.org/wiki/"+x | |
| for i in langs: | |
| soup=bs4.BeautifulSoup(requests.get(atol(str(i))).text,'html.parser') | |
| for j in soup.find_all('''div'''): | |
| if'<div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en">'in str(j):langs[p]=str(j) | |
| print("did",atol(str(i))) | |
| p+=1 | |
| p=0 | |
| with open('trainingdata.txt','w',encoding='utf-8')as f:f.write("\n\n".join(langs)) |
This file has been truncated, but you can view the full file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b>+-)</b> is a minimalistic esolang invented by <a href="/wiki/User:None1" title="User:None1">User:None1</a> and inspired by <a href="/wiki/Brainfuck" title="Brainfuck">brainfuck</a>. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Memory"><span class="tocnumber">1</span> <span class="toctext">Memory</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Commands"><span class="tocnumber">2</span> <span class="toctext">Commands</span></a></li> | |
| <li class="toclevel-1 tocsection-3"><a href="#Computational_class"><span class="tocnumber">3</span> <span class="toctext">Computational class</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-4"><a href="#+"><span class="tocnumber">3.1</span> <span class="toctext">+</span></a></li> | |
| <li class="toclevel-2 tocsection-5"><a href="#>_and_<"><span class="tocnumber">3.2</span> <span class="toctext">> and <</span></a></li> | |
| <li class="toclevel-2 tocsection-6"><a href="#-"><span class="tocnumber">3.3</span> <span class="toctext">-</span></a></li> | |
| <li class="toclevel-2 tocsection-7"><a href="#[_and_]"><span class="tocnumber">3.4</span> <span class="toctext">[ and ]</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-8"><a href="#Examples"><span class="tocnumber">4</span> <span class="toctext">Examples</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-9"><a href="#Calcuate_65"><span class="tocnumber">4.1</span> <span class="toctext">Calcuate 65</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-10"><a href="#External_resources"><span class="tocnumber">5</span> <span class="toctext">External resources</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Memory">Memory</span></h2> | |
| <p>There is a tape with three cells, each cell contains an unbounded signed integer. There is also a pointer that wraps around. | |
| </p> | |
| <h2><span class="mw-headline" id="Commands">Commands</span></h2> | |
| <p>In +-), there are three commands, both + and - matches ). | |
| </p> | |
| <ul><li><code>+</code>: Increment current cell unless the previous instruction executed is its matching ), then jump to the matching ) if the current cell is zero or the next character is ).</li> | |
| <li><code>-</code>: Decrement current cell unless the previous instruction executed is its matching ), then move the pointer to the right, then jump to the matching ) if the current cell is zero or the next character is ).</li> | |
| <li><code>)</code>: Jump to the matching + (or -) if current cell is nonzero and the previous character is ).</li></ul> | |
| <h2><span class="mw-headline" id="Computational_class">Computational class</span></h2> | |
| <p>It is <a class="mw-redirect" href="/wiki/Turing_complete" title="Turing complete">Turing complete</a> because it can be translated from <a class="mw-redirect" href="/wiki/3_cell_Brainfuck" title="3 cell Brainfuck">3 cell Brainfuck</a> (without I/O) easily. Proof is below (BF stands for 3 cell Brainfuck in the proof for convenience): | |
| </p> | |
| <h3><span id=".2B"></span><span class="mw-headline" id="+">+</span></h3> | |
| <p><code>+</code> in BF can simply be translated to <code>+)</code> in +-). | |
| </p> | |
| <h3><span id=".3E_and_.3C"></span><span class="mw-headline" id=">_and_<">> and <</span></h3> | |
| <p>We notice that <code>-)</code> in +-) is the same as <code>-></code> in BF, so <code>></code> is equivalent to <code>+-></code>, which is <code>+)-)</code> in +-). | |
| </p><p>Because the pointer wraps around, now that we get the translation of <code>></code>, we can simply translate <code><</code> by repeating <code>></code> twice, that is: | |
| </p> | |
| <pre>+)-)+)-) | |
| </pre> | |
| <h3><span class="mw-headline" id="-">-</span></h3> | |
| <p><code>-</code> is equivalent to <code>-><</code>. Because <code>-)</code> in +-) is the same as <code>-></code> in BF, <code>-</code> can be translated to <code>-)+)-)+)-)</code>. | |
| </p> | |
| <h3><span id=".5B_and_.5D"></span><span class="mw-headline" id="[_and_]">[ and ]</span></h3> | |
| <p>When not before a <code>)</code>, <code>+</code> in +-) is the same as <code>+[</code> in BF, so <code>[</code>, the same as <code>-+[><</code>, can be translated to <code>-)+)-)+)-)++)-)+)-)+)-)</code>. | |
| </p><p><code>]</code> can be translated to <code>)</code>. | |
| </p><p><i>Note: <code>><</code> is a placeholder that does nothing to force the loop to be nonempty. If the <code>><</code> doesn't exist, empty loops (<code>[]</code>) won't work, because it will be translated to <code>-)+)-)+)-)+)</code>, which will do nothing because the last <code>)</code> is right before a <code>+</code>.</i> | |
| </p><p><br/> | |
| </p> | |
| <table class="wikitable plainpres"> | |
| <caption>The whole translation table | |
| </caption> | |
| <tbody><tr> | |
| <th>BF</th> | |
| <th>+-) | |
| </th></tr> | |
| <tr> | |
| <td><pre>+</pre></td> | |
| <td><pre>+)</pre> | |
| </td></tr> | |
| <tr> | |
| <td><pre>-</pre></td> | |
| <td><pre>-)+)-)+)-)</pre> | |
| </td></tr> | |
| <tr> | |
| <td><pre>></pre></td> | |
| <td><pre>+)-)</pre> | |
| </td></tr> | |
| <tr> | |
| <td><pre><</pre></td> | |
| <td><pre>+)-)+)-)</pre> | |
| </td></tr> | |
| <tr> | |
| <td><pre>[</pre></td> | |
| <td><pre>-)+)-)+)-)++)-)+)-)+)-)</pre> | |
| </td></tr> | |
| <tr> | |
| <td><pre>]</pre></td> | |
| <td><pre>)</pre> | |
| </td></tr></tbody></table> | |
| <h2><span class="mw-headline" id="Examples">Examples</span></h2> | |
| <h3><span class="mw-headline" id="Calcuate_65">Calcuate 65</span></h3> | |
| <pre>+)+)+)+)+)+)+)+)-)+)-)+)-)++)-)+)-)+)-)+)-)+)+)+)+)+)+)+)+)+)-)+)-)-)+)-)+)-))+)-)+) | |
| </pre> | |
| <p>Translated from <a href="/wiki/Brainfuck" title="Brainfuck">brainfuck</a> <code>++++++++[>++++++++<-]>+</code>, which sets the second cell to 65. | |
| </p> | |
| <h2><span class="mw-headline" id="External_resources">External resources</span></h2> | |
| <ul><li><a class="external text" href="https://pastebin.com/E2Vj0KR5" rel="nofollow">Original interpreter in Python</a></li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20251202143642 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.018 seconds | |
| Real time usage: 0.068 seconds | |
| Preprocessor visited node count: 95/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 192/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:18393-0!canonical and timestamp 20251202143642 and revision id 169775. Rendering was triggered because: diff-page | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><a href="/wiki/Esolang:Featured_languages" title="Esolang:Featured languages"><span class="featured-icon" title="This is a featured language; *click* for more information."></span></a></p><div class="featured-text"> | |
| <dl><dd><i>This is a <a href="/wiki/Esolang:Featured_languages" title="Esolang:Featured languages">featured language</a>.</i></dd></dl> | |
| </div> | |
| <p><b>///</b> (pronounced "slashes"), or <b>Slashalash</b>, is a minimalist <a href="/wiki/Turing-complete" title="Turing-complete">Turing-complete</a> esoteric programming language, invented by Sophie Swett (<a href="/wiki/User:Ihope127" title="User:Ihope127">User:Ihope127</a>) in 2006 based on <a class="extiw" href="https://en.wikipedia.org/wiki/sed" title="wikipedia:sed">the "s/foo/bar/" notation that everybody seemed to be using in IRC</a>. The only operation is repeated string substitution, using the syntax <code>/<i>pattern</i>/<i>replacement</i>/</code>. Despite its extreme simplicity – there isn't even an obvious way to create a loop – it was proved <a href="/wiki/Turing-complete" title="Turing-complete">Turing-complete</a> by <a href="/wiki/%C3%98rjan_Johansen" title="Ørjan Johansen">Ørjan Johansen</a> in 2009, who created <a href="#Bitwise_Cyclic_Tag_interpreter">an interpreter</a> for the Turing-complete language <a href="/wiki/Bitwise_Cyclic_Tag" title="Bitwise Cyclic Tag">Bitwise Cyclic Tag</a>. | |
| </p><p>Both "///" and "Slashalash" are equally valid names for the language. The language was named /// in 2006, and the author gave the language the additional name Slashalash in 2022. The new name may be preferable since it's easier to search for. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Description"><span class="tocnumber">1</span> <span class="toctext">Description</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-2"><a href="#Pattern"><span class="tocnumber">1.1</span> <span class="toctext">Pattern</span></a></li> | |
| <li class="toclevel-2 tocsection-3"><a href="#Replacement"><span class="tocnumber">1.2</span> <span class="toctext">Replacement</span></a></li> | |
| <li class="toclevel-2 tocsection-4"><a href="#Substitution"><span class="tocnumber">1.3</span> <span class="toctext">Substitution</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-5"><a href="#Examples"><span class="tocnumber">2</span> <span class="toctext">Examples</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-6"><a href="#Hello,_world!"><span class="tocnumber">2.1</span> <span class="toctext">Hello, world!</span></a></li> | |
| <li class="toclevel-2 tocsection-7"><a href="#99_bottles_of_beer"><span class="tocnumber">2.2</span> <span class="toctext">99 bottles of beer</span></a> | |
| <ul> | |
| <li class="toclevel-3 tocsection-8"><a href="#Improved_version"><span class="tocnumber">2.2.1</span> <span class="toctext">Improved version</span></a></li> | |
| <li class="toclevel-3 tocsection-9"><a href="#user:tommyaweosme's_codegolfed_version"><span class="tocnumber">2.2.2</span> <span class="toctext">user:tommyaweosme's codegolfed version</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-2 tocsection-10"><a href="#Binary_to_unary_conversion"><span class="tocnumber">2.3</span> <span class="toctext">Binary to unary conversion</span></a></li> | |
| <li class="toclevel-2 tocsection-11"><a href="#Unary_to_binary_conversion"><span class="tocnumber">2.4</span> <span class="toctext">Unary to binary conversion</span></a></li> | |
| <li class="toclevel-2 tocsection-12"><a href="#Decimal_to_unary_conversion"><span class="tocnumber">2.5</span> <span class="toctext">Decimal to unary conversion</span></a></li> | |
| <li class="toclevel-2 tocsection-13"><a href="#Unary_to_decimal_conversion"><span class="tocnumber">2.6</span> <span class="toctext">Unary to decimal conversion</span></a></li> | |
| <li class="toclevel-2 tocsection-14"><a href="#Roman_to_unary_conversion"><span class="tocnumber">2.7</span> <span class="toctext">Roman to unary conversion</span></a></li> | |
| <li class="toclevel-2 tocsection-15"><a href="#Unary_to_roman_conversion"><span class="tocnumber">2.8</span> <span class="toctext">Unary to roman conversion</span></a></li> | |
| <li class="toclevel-2 tocsection-16"><a href="#Roman_Numeral_calculator"><span class="tocnumber">2.9</span> <span class="toctext">Roman Numeral calculator</span></a></li> | |
| <li class="toclevel-2 tocsection-17"><a href="#Thue-Morse_sequence"><span class="tocnumber">2.10</span> <span class="toctext">Thue-Morse sequence</span></a></li> | |
| <li class="toclevel-2 tocsection-18"><a href="#Fibonacci_sequence"><span class="tocnumber">2.11</span> <span class="toctext">Fibonacci sequence</span></a></li> | |
| <li class="toclevel-2 tocsection-19"><a href="#Looping_counter"><span class="tocnumber">2.12</span> <span class="toctext">Looping counter</span></a></li> | |
| <li class="toclevel-2 tocsection-20"><a href="#Simpler_counter"><span class="tocnumber">2.13</span> <span class="toctext">Simpler counter</span></a></li> | |
| <li class="toclevel-2 tocsection-21"><a href="#Bitwise_Cyclic_Tag_interpreter"><span class="tocnumber">2.14</span> <span class="toctext">Bitwise Cyclic Tag interpreter</span></a></li> | |
| <li class="toclevel-2 tocsection-22"><a href="#Quines"><span class="tocnumber">2.15</span> <span class="toctext">Quines</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-23"><a href="#Implementations"><span class="tocnumber">3</span> <span class="toctext">Implementations</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-24"><a href="#Perl_interpreter"><span class="tocnumber">3.1</span> <span class="toctext">Perl interpreter</span></a></li> | |
| <li class="toclevel-2 tocsection-25"><a href="#Python_interpreter"><span class="tocnumber">3.2</span> <span class="toctext">Python interpreter</span></a></li> | |
| <li class="toclevel-2 tocsection-26"><a href="#Haskell_interpreter"><span class="tocnumber">3.3</span> <span class="toctext">Haskell interpreter</span></a></li> | |
| <li class="toclevel-2 tocsection-27"><a href="#Other_implementations"><span class="tocnumber">3.4</span> <span class="toctext">Other implementations</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-28"><a href="#See_also"><span class="tocnumber">4</span> <span class="toctext">See also</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Description">Description</span></h2> | |
| <p>If the program is empty, execution halts. Otherwise, the first character is taken, and execution proceeds as follows: | |
| </p> | |
| <ul><li>If the character is <code>\</code>, the character after it (if any) is printed and both characters are removed from the program.</li> | |
| <li>If the character is <code>/</code>, it is removed, the <a href="#Pattern">pattern</a> and <a href="#Replacement">replacement</a> are identified and a <a href="#Substitution">substitution</a> is performed.</li> | |
| <li>Otherwise, the character is printed and removed.</li></ul> | |
| <p>The execution process then starts over again with the modified program. | |
| </p> | |
| <h3><span class="mw-headline" id="Pattern">Pattern</span></h3> | |
| <p>A substitution starts by reading characters in a loop to make up the <i>pattern</i>, as follows: | |
| </p> | |
| <ul><li>If the character read is <code>\</code>, the character after it is added to the pattern, and both characters are removed.</li> | |
| <li>If the character read is <code>/</code>, it is removed, and the pattern-reading process ends.</li> | |
| <li>Otherwise, the character is added to the pattern and removed.</li></ul> | |
| <p>If this process reaches the end of the program without reaching a terminating <code>/</code>, then the program halts. | |
| </p> | |
| <h3><span class="mw-headline" id="Replacement">Replacement</span></h3> | |
| <p>Otherwise, the same process is repeated again, making up the <i>replacement</i>. | |
| </p> | |
| <ul><li>If the character read is <code>\</code>, the character after it is added to the replacement, and both characters are removed.</li> | |
| <li>If the character read is <code>/</code>, it is removed, and the replacement-reading process ends.</li> | |
| <li>Otherwise, the character is added to the replacement and removed.</li></ul> | |
| <p>Again, if no terminating <code>/</code> is reached, the program halts. | |
| </p> | |
| <h3><span class="mw-headline" id="Substitution">Substitution</span></h3> | |
| <p>Now that the pattern and replacement have both been read, the substitution process begins. | |
| </p><p>If the pattern is empty, then the program loops forever (which is the mathematically obvious result of replacing all occurrences of the empty string). If there are no occurrences of the pattern in the rest of the program, then the substitution ends. Otherwise, the first occurrence in the text is replaced by the replacement, and the substitution repeats. | |
| </p><p>Note that a replacement which contains the pattern will cause an infinite loop; for example, <code>/foo/foobar/foo</code> will evolve as follows (one step per line): | |
| </p> | |
| <pre>/foo/foobar/foo | |
| foobar | |
| foobarbar | |
| foobarbarbar | |
| ... | |
| </pre> | |
| <p>As the substitution process never ends, the program never halts, and nothing is printed. | |
| </p><p>Such an infinite loop is possible even without a replacement containing the pattern, e.g. <code>/ab/bbaa/abb</code>: | |
| </p> | |
| <pre>/ab/bbaa/abb | |
| abb | |
| bbaab | |
| bbabbaa | |
| bbbbaabaa | |
| bbbbabbaaaa | |
| ... | |
| </pre> | |
| <p>The pattern that this sequence follows is <code>b<sup>n</sup>abba<sup>n</sup></code> → <code>b<sup>n+2</sup>aaba<sup>n</sup></code> → <code>b<sup>n+2</sup>abba<sup>n+2</sup></code>. | |
| </p> | |
| <h2><span class="mw-headline" id="Examples">Examples</span></h2> | |
| <h3><span id="Hello.2C_world.21"></span><span class="mw-headline" id="Hello,_world!"><a href="/wiki/Hello,_world!" title="Hello, world!">Hello, world!</a></span></h3> | |
| <p>A "Hello, world!" program and (cheating) quine: | |
| </p> | |
| <pre>Hello, world! | |
| </pre> | |
| <p>A slightly more elaborate "Hello, world!" | |
| </p> | |
| <pre>/ world! world!/Hello,/ world! world! world! | |
| </pre> | |
| <p>Here, the first occurrence of " world! world!" is replaced with "Hello,", yielding "Hello, world!". This is then printed. | |
| </p><p>An even more elaborate "Hello, world!" program, where the first replacement modifies the second: | |
| </p> | |
| <pre>/foo/Hello, world!//bar/foo/bar | |
| </pre> | |
| <p>First, <tt>foo</tt> is replaced with "Hello, world!", yielding <tt>/bar/Hello, world!/bar</tt>. This turns the <tt>bar</tt> into "Hello, world!" as well, which is then printed. | |
| </p><p>A yet even more elaborate "Hello, world!' | |
| </p> | |
| <pre>/a/\//ab/world!/ab world!/Hello, aworld! bworld! | |
| </pre> | |
| <p><tt>a</tt> is replaced with a slash, and then <tt>b</tt> is replaced with world. A slightly varied version of the second hello world is then run. | |
| </p> | |
| <h3><span class="mw-headline" id="99_bottles_of_beer"><a href="/wiki/99_bottles_of_beer" title="99 bottles of beer">99 bottles of beer</a></span></h3> | |
| <pre>/] | |
| [///#/ bottles of beer on the wall, | |
| //$/ bottles of beer | |
| Take one down, pass it around | |
| //%/ bottles of beer on the wall. | |
| /99#99$98%98#98$97%97#97$96%96#96$95%95#95$94%94#94$93%93] | |
| [#93$92%92#92$91%91#91$90%90#90$89%89#89$88%88#88$87%87#87] | |
| [$86%86#86$85%85#85$84%84#84$83%83#83$82%82#82$81%81#81$80] | |
| [%80#80$79%79#79$78%78#78$77%77#77$76%76#76$75%75#75$74%74] | |
| [#74$73%73#73$72%72#72$71%71#71$70%70#70$69%69#69$68%68#68] | |
| [$67%67#67$66%66#66$65%65#65$64%64#64$63%63#63$62%62#62$61] | |
| [%61#61$60%60#60$59%59#59$58%58#58$57%57#57$56%56#56$55%55] | |
| [#55$54%54#54$53%53#53$52%52#52$51%51#51$50%50#50$49%49#49] | |
| [$48%48#48$47%47#47$46%46#46$45%45#45$44%44#44$43%43#43$42] | |
| [%42#42$41%41#41$40%40#40$39%39#39$38%38#38$37%37#37$36%36] | |
| [#36$35%35#35$34%34#34$33%33#33$32%32#32$31%31#31$30%30#30] | |
| [$29%29#29$28%28#28$27%27#27$26%26#26$25%25#25$24%24#24$23] | |
| [%23#23$22%22#22$21%21#21$20%20#20$19%19#19$18%18#18$17%17] | |
| [#17$16%16#16$15%15#15$14%14#14$13%13#13$12%12#12$11%11#11] | |
| [$10%10#10$9%9#9$8%8#8$7%7#7$6%6#6$5%5#5$4%4#4$3%3#3$2%2#2] | |
| [$1 bottle of beer on the wall. | |
| 1 bottle of beer on the wall, | |
| 1 bottle of beer | |
| Take one down, pass it around | |
| No more bottles of beer on the wall. | |
| </pre> | |
| <p>Note the brackets, which are not part of the language itself: these are used to mark unnecessary ("comment") line breaks, and are removed at the beginning by the very first replacement of the program. The symbols #, $ and % make up a simple data compression scheme which shrinks most of the bulk from the program. | |
| </p><p>Since characters other than / and \ are used only for printing, they aren't necessary for writing programs. However, they might make good comments as well as data representations, as long as you don't try to execute them. You may want to write code to strip the comments out. | |
| </p> | |
| <h4><span class="mw-headline" id="Improved_version">Improved version</span></h4> | |
| <pre>/] | |
| [///#/ bottles of beer on the wall, | |
| //!/ bottles of beer | |
| Take one down, pass it around//$/! | |
| //%/ bottles of beer on the wall. | |
| //NL/ | |
| /] | |
| [/I/99#99$98%98#98$97%97#97$96%96#96$95%95#95$94%94#94$93%93#93$92%92#92$91%91#91$90%90#90!/] | |
| [/V/NL99%I/] | |
| [I] | |
| [/NL9/NL8/V] | |
| [/NL8/NL7/V] | |
| [/NL7/NL6/V] | |
| [/NL6/NL5/V] | |
| [/NL5/NL4/V] | |
| [/NL4/NL3/V] | |
| [/NL3/NL2/V] | |
| [/NL2/NL1/V] | |
| [/NL1/NL-/] | |
| [/NLNL-0#-0!//] | |
| [/0/No more/] | |
| [/NL-/NL//NL bottles/NL1 bottle/V | |
| </pre> | |
| <p>This program works similarly to the above one, but with some improvements. | |
| First, a substitution is made from NL to a newline. | |
| V is replaced with a section of the song, 10 verses long but spanning 11, in which all the numbers have the same tens digit (at first 9, which does not actually exist in the song), and I is replaced with the first such section, which is cut off at the beginning. | |
| The first section is printed. | |
| Then, a replacement changes the tens digits (identified by being preceded by a newline) to those of the next section, which is then printed. | |
| This repeats until the last section, where some extra substitutions handle the changes there. | |
| </p> | |
| <h4><span id="user:tommyaweosme.27s_codegolfed_version"></span><span class="mw-headline" id="user:tommyaweosme's_codegolfed_version"><a href="/wiki/User:Tommyaweosme" title="User:Tommyaweosme">user:tommyaweosme</a>'s <a href="/wiki/Golf" title="Golf">codegolfed</a> version</span></h4> | |
| <pre>/NL/ | |
| //@/ bottles of beer on the wallNL//^/bottles of beer//%/^NLtake one down pass it around//#/ %NL//$/NL99@99#98@98#97@97#96@96#95@95#94@94#93@93#92@92#91@91#90@90 %/$/NL9/NL8/$/NL8/NL7/$/NL7/NL6/$/NL6/NL5/%/NL5/NL4/$/NL4/NL3/$/NL3/NL2/$/NL2/NL1/$/NL11 bottles/NL* bottle//NL1/NL//0@0 %///*/1//e of beer | |
| take one/e of beer | |
| take it/$no more@no more ^ | |
| </pre> | |
| <h3><span class="mw-headline" id="Binary_to_unary_conversion"><a href="/wiki/Binary_to_unary_conversion" title="Binary to unary conversion">Binary to unary conversion</a></span></h3> | |
| <pre>/1/0*//*0/0**//0//100010 | |
| </pre> | |
| <p>The above also shows that a single substitution can blow up the size of the program exponentially, even if it halts. | |
| </p> | |
| <h3><span class="mw-headline" id="Unary_to_binary_conversion"><a href="/wiki/Talk:Binary_to_unary_conversion" title="Talk:Binary to unary conversion">Unary to binary conversion</a></span></h3> | |
| <pre>/*/>01//1>/1//10/01//011/1\0//01/_1//_///>0/>//>//********************************** | |
| </pre> | |
| <p>This program takes a number expressed in unary notation as a row of <code>*</code> and returns its binary representation (with the number zero represented as an empty string rather than as <code>0</code>). The symbols <code>></code> and <code>_</code> are auxiliary and can be changed (consistently) for any other symbols different than <code>0</code>, <code>1</code> and <code>*</code>. | |
| </p><p>The conversion is done in three logical steps: | |
| </p> | |
| <ol><li>The first three substitutions (<code>/*/>01/</code>, <code>/1>/1/</code> & <code>/10/01/</code>) transform a row of N <code>*</code> into a single <code>></code> followed by a row of N <code>0</code>s followed by a row of N <code>1</code>s. This preprocessing step puts a cursor (the <code>></code>) before a number expressed in unary notation (the row of <code>1</code>s) with enough preceding <code>0</code>s to apply the unary to binary conversion safely (since the binary representation of a number N always has at most N digits).</li> | |
| <li>The next three substitutions (<code>/011/10/</code>, <code>/01/_1/</code> & <code>/_//</code>) perform the unary to binary conversion (reversing the unary to binary conversion example above).</li> | |
| <li>The two remaining substitutions (<code>/>0/>/</code> & <code>/>//</code>) use the cursor <code>></code> to remove the unused preceding <code>0</code>s and the cursor itself.</li></ol> | |
| <h3><span class="mw-headline" id="Decimal_to_unary_conversion">Decimal to unary conversion</span></h3> | |
| <pre>/9/8*//8/7*//7/6*//6/5*//5/4*//4/3*//3/2*//2/1*//1/0*//*0/9*//0//40 | |
| </pre> | |
| <p>An improved extension of the binary to unary algorithm. | |
| </p> | |
| <h3><span class="mw-headline" id="Unary_to_decimal_conversion">Unary to decimal conversion</span></h3> | |
| <pre>/*/>01//1>/1//10/01//01111111111/1\0//0111111111/_9//011111111/_8//01111111/_7//0111111/_6//011111/_5//01111/_4//0111/_3//011/_2//01/_1//_///>0/>//>//**************************************** | |
| </pre> | |
| <p>or shorter: (same idea) | |
| </p> | |
| <pre>/*/>01//1>/1//10/01//01111111111/1\0//01111/_4//_411/%//%111/_9//%11/_8//%1/_7//%/_6//_41/_5//0111/_3//011/_2//01/_1//_///>0/>//>//**************************************** | |
| </pre> | |
| <h3><span class="mw-headline" id="Roman_to_unary_conversion">Roman to unary conversion</span></h3> | |
| <pre>/CM/DCD//M/DD//CD/CCCC//D/CCCCC//XC/LXL//C/LL//XL/XXXX//L/XXXXX//IX/VIV//X/VV//IV/IIII//V/IIIII//I/*/XXXIV | |
| </pre> | |
| <p>Adapted from [<a class="external text" href="https://www.youtube.com/watch?v=CcFv7Nb_51c%7Cthis" rel="nofollow">video</a>]. | |
| </p> | |
| <h3><span class="mw-headline" id="Unary_to_roman_conversion">Unary to roman conversion</span></h3> | |
| <pre>/*/I//IIIII/V//IIII/IV//VV/X//VIV/IX//XXXXX/L//XXXX/XL//LL/C//LXL/XC//CCCCC/D//CCCC/CD//DD/M//DCD/CM/********************************** | |
| </pre> | |
| <p>Adapted from [<a class="external text" href="https://www.youtube.com/watch?v=CcFv7Nb_51c%7Cthis" rel="nofollow">video</a>]. | |
| </p> | |
| <h3><span class="mw-headline" id="Roman_Numeral_calculator">Roman Numeral calculator</span></h3> | |
| <pre>[/cm/dcd//m/dd//cd/cccc//d/ccccc//xc/lxl//c/ll//xl/xxxx//l/xxxxx//ix/viv//x/vv//iv/iiii//v/iiiii//i/*//+///*-*/-//*-/*//*/I//IIIII/V//IIII/IV//VV/X//VIV/IX//XXXXX/L//XXXX/XL//LL/C//LXL/XC//CCCCC/D//CCCC/CD//DD/M//DCD/CM/] | |
| [clxv+xvi] | |
| </pre> | |
| <p>Roman conversion adapted from [<a class="external text" href="https://www.youtube.com/watch?v=CcFv7Nb_51c%7Cthis" rel="nofollow">video</a>].<br/> | |
| Made by <a href="/wiki/User:Xyzzy" title="User:Xyzzy">Xyzzy</a>.<br/> | |
| Input taken as lowercase, output as uppercase. | |
| </p> | |
| <h3><span class="mw-headline" id="Thue-Morse_sequence">Thue-Morse sequence</span></h3> | |
| <pre>/*/\/.\\0\/,\\,0,\\,1\/\/.\\1\/,\\,1,\\,0\/\/,\\,\/.\//********/.//.0 | |
| </pre> | |
| <p>This shows the first 256 digits of the Thue-Morse sequence. Modify number of asterisks to get any power of 2. | |
| </p> | |
| <pre>/>*/#>//>/\/.\/\/.0//#/\/.\\0\/,\\,0,\\,1\/\/.\\1\/,\\,1,\\,0\/\/,\\,\/.\//>******** | |
| </pre> | |
| <p>The same program adapted to get the "input" (formatted as a row of <code>*</code>) from the end of the string rather than from the middle. | |
| </p> | |
| <h3><span class="mw-headline" id="Fibonacci_sequence"><a href="/wiki/Fibonacci_sequence" title="Fibonacci sequence">Fibonacci sequence</a></span></h3> | |
| <pre>/!/\/.\\0\/,\\,0,\\,1\/\/.\\1\/,\\,0\/\/,\\,\/.\/\/+\\+\/=\\=.\\1-\/\/=\\=\/+\\+\//!!!!!!!!!/.///+\+///-/\\\///0/1//1/*/++.1 | |
| </pre> | |
| <p>This prints the first N Fibonacci numbers as sequences of asterisks separated by slashes (where N is the number of exclamation marks). | |
| </p> | |
| <pre>/>*/#>//>/\/.\/\/\/+\\+\/\/\/-\/\\\\\\\/\/\/0\/1\/\/1\/*\/++.1//#/\/.\\0\/,\\,0,\\,1\/\/.\\1\/,\\,0\/\/,\\,\/.\/\/+\\+\/=\\=.\\1-\/\/=\\=\/+\\+\//>********* | |
| </pre> | |
| <p>The same program adapted to get the "input" (formated as a row of <code>*</code>) from the end of the string rather than from the middle. | |
| </p> | |
| <h3><span class="mw-headline" id="Looping_counter">Looping counter</span></h3> | |
| <pre>/] | |
| [///+/ | |
| /] | |
| [/-\-/|\/|*|-|\/|\\|\\|*|\/|*|-|+|\/|||\\|\\|||\\|\\|||*|||\\|\/|||*|||-|||\] | |
| [/|*|\\|-|\/|\/|*|\\|-|\/|||\\|\\|||\\|\\|||*|||\\|\\|||\\|\\|||*|||\\|\/|||] | |
| [*|||-|||\/|\/|*|+|-|\/|\\|\/|*|\\|\\|+|*|\\|\/|*|\\|\\|-|\\|\/|\\|\/|*|\\|\] | |
| [\|-|\\|\/|*|\\|\\|+|*|*|\\|\\|+|*|\\|\/|\/|*|+|-|*|+|-|*|+|-|*|+|-|*|+|-|*|] | |
| [+|-|*|+|-|\/|*|\\|+|*|\/|\\|\\|*|\/|\/|\\|\\|*|\/|\\|\/|+|\\|\\|+|||*|\\|\/] | |
| [|*|+|+|\\|\/|\\|\/|+|\\|\\|+|||+|\\|\/|+|+|+|\\|\/|\\|\/|+|\\|\\|+|||-|\\|\] | |
| [/|-|+|+|\\|\/|\\|\/|+|\\|\\|+|||||\\|\/|\\|\\|||+|+|\\|\/|\\|\/|+|\\|\\|+||] | |
| [|\\|\\|\\|\/|\\|\/|\\|\\|\\|\/|+|+|\\|\/|\\|\/|+|\\|\\|+|||\\|\\|\\|\\|\\|\] | |
| [/|\\|\\|\\|\\|+|+|\\|\/|\/|*|+|*|*|+|*|*|+|*|*|-|*|-|\/|+|\\|+|||\/|\/|\/||] | |
| [|\\|\\|||\/|\\|||\\|\\|\\|\\|||\/|\/|||\\|\/|||\/|\\|||\\|\\|\\|\/|||\/|\/|] | |
| [-|\\|-|\/|-|-|\/|+|+|-|-|/] | |
| [/*-/\\*/] | |
| [*-+] | |
| [/|\\|\\|*|\/|*|-|/*\-//*\-/|\\|\\|*|\\|\\|*|\/|*|-|/] | |
| [/*+-/\/*\\+*\/*\\-\/\/*\\-\/*\\+**\\+*\//] | |
| [*+-*+-*+-*+-*+-*+-*+-] | |
| [/*\+*/\\*/] | |
| [/\\*/\/+\\+|*\/*++\/\/+\\+|+\/+++\/\/+\\+|-\/-++\/\/+\\+||\/\\|++\/\/+\\+|\] | |
| [\\/\/\\\/++\/\/+\\+|\\\\\/\\\\++\//] | |
| [*+**+**+*] | |
| [*-*-] | |
| [/+\+|//] | |
| [/|\\|/\|\\\\|//|\/|/\|\\\/|/] | |
| [/-\-/--/++-- | |
| </pre> | |
| <p>This program by <a href="/wiki/%C3%98rjan_Johansen" title="Ørjan Johansen">Ørjan Johansen</a> loops indefinitely, (slowly) printing longer and longer lines of asterisks. It was generated semi-automatically from a <a class="external text" href="http://oerjan.nvg.org/esoteric/slashes/Counter.hs" rel="nofollow">Haskell program</a> (but don't panic, to cut short on my usually lethal over-engineering I ended up using no monads outside the main function). | |
| </p><p>We use the same trick as in the bottles of beer program of inserting line breaks between <code>][</code>, which are removed at the beginning. We also change all <code>+</code>'s into newlines, although this only affects printing (and was done to save having more different characters in the main loop) | |
| </p><p>The "obvious" (and perhaps only) way of looping indefinitely in /// is by program self replication, which here happens into the <code>--</code> spots in the final line. One of the copies needs to be recopied, which means first re-escaping slashes and backslashes, but without clobbering the rest of the program this is hard to do without marking that copy in some way, which here is done by surrounding all the characters by <code>|</code>'s. We make sure not to have literal <code>|/|</code> or <code>|\|</code> anywhere else in the main program. | |
| </p><p>But then we first need to remove those <code>|</code>'s from the copy of the program that actually "runs" at the next iteration. We cannot do that with a simple substitution, because such a substitution is local and cannot see context enough to avoid clobbering the <i>other</i> copy which needs to preserve the <code>|</code>'s. (<i>This conclusion turns out to be wrong.</i> See the simplified program below.) | |
| </p><p>The information about which copy is which cannot be inside it, since they are initially identical. Instead we put <code>++</code> before the copy that is to be run next. Now to remove the <code>|</code>'s from that copy we have to gradually substitute, using the <code>++</code> to scan through the copy. | |
| </p><p>This requires iteration, but fortunately we don't need an unbounded loop, or else we would have an infinite recursion. Instead we calculate an upper bound for the length of the copy (making sure to include the increasing length of the counter), and make that many copies of the subprogram that scans <code>++</code> (at least) one step. | |
| </p><p>That subprogram itself needs to contain one substitution for each different character used in the main loop, which is why I have kept that number down to six, making the subprogram 71 characters long. We overestimate copied program length a bit for ease of calculation, (3*2<sup>7</sup>+2) on the first iteration, giving a total scanner length of 27406 characters. | |
| </p><p>Other than this, we make sure to print the counter as asterisks, and increment it in the next iteration program copies. | |
| </p> | |
| <h3><span class="mw-headline" id="Simpler_counter">Simpler counter</span></h3> | |
| <pre>/] | |
| /]//] /]//][//] | |
| [/|/<-\\\\>\\\\\\/] | |
| [/QT/] | |
| [|/R|N|/Q|T|/|/<-|\|\>|/<-|\|\|\|\>|\|\|\|\|/|/<|\->|/|/] | |
| [C|T|/C|\T|/C|T|/|/*|\ | |
| ] [|/I|\N|/|/I|\N|/**|\ | |
| ] [|/] | |
| [|/Q|\T|/Q|T|/R|N] | |
| [/] | |
| [/RN/QT//<-\\>/<-\\\\>\\\\//<\->//] | |
| [/CT/* | |
| /] | |
| [/Q\T/QT/RN | |
| </pre> | |
| <p>The original counter loop was based on the mistaken belief that it was impossible to distinguish two copies of program code without scanning through them. But after my morning coffee <a href="/wiki/%C3%98rjan_Johansen" title="Ørjan Johansen">I</a> realized that there was a simple way to distinguish them: Copy one of them again to another place. This will remove some backslashes from just that copy, and if we choose a suitable quoting scheme, we can then do just a few substitutions to turn one copy into the original quoted form, and the other into the final program. | |
| </p><p>This is much more efficient than scanning, and we also don't need to minimize the number of characters used for efficiency, so the program can use more mnemonic "tokens". | |
| </p><p>The quoting scheme used here is as follows for a character <code><i>c</i></code>: | |
| </p> | |
| <pre> |<i>c</i> original quoted program source | |
| <-\\>\\\<i>c</i> runtime quoted form | |
| <-\>\<i>c</i> after copying once | |
| <-><i>c</i> after copying twice | |
| <i>c</i> "runnable" code | |
| </pre> | |
| <p>Using three characters <code><-></code> gives a slightly shorter set of substitutions and saves a total of 5 characters in the source program compared to just <code><></code>, at the cost of a longer runtime program. A version using only <code><></code> can be found <a class="external text" href="http://oerjan.nvg.org/esoteric/slashes/counter3.sss" rel="nofollow">here</a>. | |
| </p><p>While it should be harmless to quote all characters, this is not necessary. <code>/</code> and <code>\</code> need quoting, and there should be a quoting break <i>inside</i> any "tokens" or other strings that are substituted in the main program, so that their quoted form is not affected unless that is what you actually want. As usual some care must be taken to avoid confusing any strings, in particular <code>|</code> and <code><-></code> cannot occur in the unquoted program with this scheme. | |
| </p> | |
| <h3><span class="mw-headline" id="Bitwise_Cyclic_Tag_interpreter"><a href="/wiki/Bitwise_Cyclic_Tag" title="Bitwise Cyclic Tag">Bitwise Cyclic Tag</a> interpreter</span></h3> | |
| <p><a class="external text" href="http://oerjan.nvg.org/esoteric/slashes/bct.sss" rel="nofollow">This interpreter</a> for the language <a href="/wiki/Bitwise_Cyclic_Tag" title="Bitwise Cyclic Tag">Bitwise Cyclic Tag</a> was generated using <a class="external text" href="http://oerjan.nvg.org/esoteric/slashes/BCT.hs" rel="nofollow">this Haskell program</a>. | |
| The BCT program and data can be changed by modifying the strings after <code>(P|</code> and <code>(D|</code> near the beginning. (The empty program and the program containing just 1 are not supported.) | |
| As the BCT page <a class="mw-redirect" href="/wiki/BCT#Computations_in_BCT" title="BCT">suggests is enough</a> for <a href="/wiki/Turing-complete" title="Turing-complete">Turing-completeness</a>, it (slowly!) prints out the sequence of deleted data bits as 0 = <code>/</code>, 1 = <code>\</code>. | |
| </p><p>All characters except <code>/</code> and <code>\</code> are replaced before the main loop is entered, showing that /// is <a href="/wiki/Turing-complete" title="Turing-complete">Turing-complete</a> even when restricted to those two characters. | |
| </p> | |
| <h3><span class="mw-headline" id="Quines">Quines</span></h3> | |
| <p>Since any /// program not containing <code>/</code> or <code>\</code> is trivially a quine, here is one containing <i>only</i> <code>/</code> and <code>\</code>. | |
| </p> | |
| <pre class="rectwrap">/\/\/\/\\\\/\\\\\\\/\\\\\\\/\\\\\\\/\\\\\\\\\\\\\\\\\\\\\\//\/\/\/\\\/\/\\////\\////\\\///\\////\\\///\\////\\\///\\////\\\///\\\///\\\///\\\///\\////\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\////\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\////\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\////\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\////\\////\\\///\\////\\\///\\////\\\///\\////\\\///\\\///\\\///\\////\\\///\\////\\\///\\\///\\////\\////\\////\\////\\\///\\////\\\///\\////\\////\\\///\\////\\////\\\///\\////\\\///\\////\\\///\\////\\\///\\\///\\\///\\////\\\///\\\///\\\///\\////\\\///\\\///\\////\\////\\////\\////\\\///\\////\\////\\\///\\////\\////\\\///\\////\\\///\\////\\\///\\////\\\///\\\///\\\///\\\///\\////\\\///\\\///\\////\\////\\\///\\\///\\\///\\////\\\///\\\///\\\///\\////\\\///\\\///\\\///\\////\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\////\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\////\\\///\\\///\\\///\\////\\\///\\\///\\\///\\\///\\////\\////\\////\\////\\\///\\////\\////\\\///\\////\\////\\\///\\////\\\///\\////\\\///\\////\\\///\\\///\\\///\\\///\\////\\\///\\\///\\\///\\////\\\///\\\///\\\///\\////\\\///\\\///\\\///\\////\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\////\\////\\////\\////\\\///\\////\\\///\\////\\\//\/\/\/\\\/\\\/\\////\//\//\/\/\/\\\\/\\//\\\/\\\/\\\/\\\\\\\/\\\\\\\/\\\/\\\\////\//\//\/\/\/\\\\/\\\/\\\/\\\/\\\\\\\\\\////\/\/\</pre> | |
| <p>A more readable quine I submitted to PPCG: | |
| </p> | |
| <pre class="rectwrap">/<\>/<\\\\>\\\\\\//P1/<>/<<>\><>/<<>\<>\<>\<>\><>\<>\<>\<>\<>\<>\<>/<>/P<>1<>/P<>2<>/<>/P<<>\<>\><>\<>\<>2<>/P<>1<>/<>/<<>\><>/<<<>\<>\>><>\<>\<>/<>/<<>\<>\><>/<>/P<>1//P<\\>\\2/P1//<\>/<<\\>>\\//<\\>//P1</pre> | |
| <h2><span class="mw-headline" id="Implementations">Implementations</span></h2> | |
| <h3><span class="mw-headline" id="Perl_interpreter">Perl interpreter</span></h3> | |
| <p>The below implementation is appropriately written in the Perl language, well-known for also supporting a /// construction. | |
| </p> | |
| <pre>#!/usr/bin/perl -w | |
| my $debug = | |
| ($#ARGV >= 0 and $ARGV[0] =~ m/^-d([1-2]?)$/ and shift and ($1 || 1)); | |
| $| = 1; | |
| $_ = join '', <>; | |
| while (1) { | |
| print "\n[", $_, "]" if $debug == 1; | |
| if (s!^([^/\\]+)!! or s!^\\(.)!!s) { | |
| print($1); | |
| print "\n[", $_, "]" if $debug == 2; | |
| } | |
| elsif (s!^/((?:[^/\\]|\\.)*)/((?:[^/\\]|\\.)*)/!!s) { | |
| my ($s,$d) = ($1,$2); | |
| $s =~ s/\\(.)/$1/gs; | |
| $d =~ s/\\(.)/$1/gs; | |
| while (s/(?:\Q$s\E)/$d/) { } | |
| } | |
| else { last; } | |
| } | |
| </pre> | |
| <h3><span class="mw-headline" id="Python_interpreter">Python interpreter</span></h3> | |
| <p>A very compact Python interpreter: | |
| </p> | |
| <pre>def slashes(s): | |
| while s: | |
| buff = ["","",1] | |
| for t in (0,1,2): | |
| while s: | |
| if s[0] == "/" : s = s[1:]; break | |
| if s[0] == "\\": s = s[1:] | |
| if t: buff[t-1] += s[0]; s = s[1:] | |
| else: yield s[0]; s = s[1:] | |
| while s and buff[0] in s: s = s.replace(*buff) | |
| </pre> | |
| <p>The interpreter returns a generator function that yields the output one character at a time. Example of usage: | |
| </p> | |
| <pre>output = "".join(slashes(r"/*/#<//<#/#//</\/.\/\/.0//#/\/.\\0\/,\\,0,\\,1\/\/.\\1\/,\\,1,\\,0\/\/,\\,\/.\//********")) | |
| </pre> | |
| <p>Note that since python uses <code>\</code> as escape character you need to use raw strings. | |
| </p> | |
| <h3><span class="mw-headline" id="Haskell_interpreter">Haskell interpreter</span></h3> | |
| <pre>import Data.List (isPrefixOf) | |
| run [] = [] | |
| run ('\\':x:xs) = x:run xs | |
| run ('/':xs) = run $ sub $ pat xs | |
| run (x:xs) = x:run xs | |
| pat ('\\':x:xs) = ([x],[],[]) <> pat xs | |
| pat ('/':xs) = repl xs | |
| pat (x:xs) = ([x],[],[]) <> pat xs | |
| repl ('\\':x:xs) = ([],[x],[]) <> repl xs | |
| repl ('/':xs) = ([],[],xs) | |
| repl (x:xs) = ([],[x],[]) <> repl xs | |
| sub args@(pat,repl,body) = if subStep args == body then body else sub(pat,repl,subStep args) | |
| subStep(_,_,[]) = [] | |
| subStep(pat,repl,body) | pat `isPrefixOf` body = repl++subStep(pat,repl,drop (length pat) body) | |
| | otherwise = head body:subStep(pat,repl,tail body) | |
| main = interact run | |
| </pre> | |
| <p><br/> | |
| </p> | |
| <h3><span class="mw-headline" id="Other_implementations">Other implementations</span></h3> | |
| <ul><li><a class="external text" href="http://oerjan.nvg.org/esoteric/slashes/dslashes.pl" rel="nofollow">Implementation in Perl</a> with more debug output options.</li> | |
| <li><a class="external text" href="http://zzo38computer.org/textfile/miscellaneous/slashes.js" rel="nofollow">Implementation in JavaScript</a> (public domain)</li> | |
| <li><a class="external text" href="https://github.com/CarlosLunaMota/Slashes" rel="nofollow">Implementation in Python</a> with many examples, several debug modes and syntax highlighting (public domain)</li> | |
| <li>More interpreters can be found on <a class="external text" href="http://codegolf.stackexchange.com/q/37014/6691" rel="nofollow">Programming puzzles & code golf Stack Exchange</a>.</li></ul> | |
| <h2><span class="mw-headline" id="See_also">See also</span></h2> | |
| <ul><li><a href="/wiki/Itflabtijtslwi" title="Itflabtijtslwi">Itflabtijtslwi</a> – /// with input</li> | |
| <li><a href="/wiki/REGXY" title="REGXY">REGXY</a> – similar syntax but uses regex and labels</li> | |
| <li><a href="/wiki/Fuun_DNA" title="Fuun DNA">Fuun DNA</a> also consumes replacement rules from the start of the program as it executes them</li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20251026171339 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.037 seconds | |
| Real time usage: 0.061 seconds | |
| Preprocessor visited node count: 139/1000000 | |
| Post‐expand include size: 263/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 4764/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 1.099 1 Template:Featured_language | |
| 100.00% 1.099 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:1636-0!canonical and timestamp 20251026171339 and revision id 166743. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><dl><dd><i>The title of this article is not correct because of technical limitations. The correct title is actually <b>:)</b></i>.</dd></dl> | |
| <p><br/> | |
| :) is an esolang created by <a href="/wiki/User:Martsadas" title="User:Martsadas">User:Martsadas</a> that only uses smileys<br/> | |
| <br/> | |
| Valid tokens are <code>:)</code>, <code>:P</code>, <code>:]</code>, <code>:></code>, <code>:D</code>, and <code>:O</code>.<br/> | |
| <br/> | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Valid_instructions:"><span class="tocnumber">1</span> <span class="toctext">Valid instructions:</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Numbers:"><span class="tocnumber">2</span> <span class="toctext">Numbers:</span></a></li> | |
| <li class="toclevel-1 tocsection-3"><a href="#Notes:"><span class="tocnumber">3</span> <span class="toctext">Notes:</span></a></li> | |
| <li class="toclevel-1 tocsection-4"><a href="#Example_programs:"><span class="tocnumber">4</span> <span class="toctext">Example programs:</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-5"><a href="#Hello,_World!:"><span class="tocnumber">4.1</span> <span class="toctext">Hello, World!:</span></a></li> | |
| <li class="toclevel-2 tocsection-6"><a href="#Truth-machine:"><span class="tocnumber">4.2</span> <span class="toctext">Truth-machine:</span></a></li> | |
| <li class="toclevel-2 tocsection-7"><a href="#99_bottles_of_beer:"><span class="tocnumber">4.3</span> <span class="toctext">99 bottles of beer:</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-8"><a href="#Interpreter"><span class="tocnumber">5</span> <span class="toctext">Interpreter</span></a></li> | |
| </ul> | |
| </div> | |
| <h3><span class="mw-headline" id="Valid_instructions:">Valid instructions:</span></h3> | |
| <p><br/> | |
| All instructions start with an instruction modification parameter kinda like <a href="/wiki/Whitespace" title="Whitespace">Whitespace</a>.<br/> | |
| </p> | |
| <table class="wikitable"> | |
| <caption>Instruction modification parameters | |
| </caption> | |
| <tbody><tr> | |
| <td>:)</td> | |
| <td>I/O | |
| </td></tr> | |
| <tr> | |
| <td>:P</td> | |
| <td>Cells | |
| </td></tr> | |
| <tr> | |
| <td>:]</td> | |
| <td>Arithmetic | |
| </td></tr> | |
| <tr> | |
| <td>:></td> | |
| <td>Repeat same IMP as last instruction | |
| </td></tr> | |
| <tr> | |
| <td>:D</td> | |
| <td>Flow control | |
| </td></tr></tbody></table> | |
| Instruction arguments are separated by <code>:></code>. | |
| Lines are separated by <code>:O</code>. | |
| <table class="wikitable"><caption>I/O | |
| </caption> | |
| <tbody><tr> | |
| <td>:)</td> | |
| <td>:) [c]</td> | |
| <td>Prints cell [c] as an ASCII character | |
| </td></tr> | |
| <tr> | |
| <td>:P</td> | |
| <td>:P [c]</td> | |
| <td>Prints cell [c] as a number | |
| </td></tr> | |
| <tr> | |
| <td>:]</td> | |
| <td>:] [c]</td> | |
| <td>Asks the user to input a number and stores it into cell [c] | |
| </td></tr> | |
| <tr> | |
| <td>:></td> | |
| <td>:> [c]</td> | |
| <td>Prints constant [c] as an ASCII character | |
| </td></tr> | |
| <tr> | |
| <td>:D</td> | |
| <td>:D [c]</td> | |
| <td>Asks the user to input a character and stores its ASCII value into cell [c] | |
| </td></tr></tbody></table> | |
| <code>:)</code> stores variables in cells. | |
| <table class="wikitable"> | |
| <caption>Cells | |
| </caption> | |
| <tbody><tr> | |
| <td>:)</td> | |
| <td>:) [c] :> [n]</td> | |
| <td>Sets cell [c] to value [n] | |
| </td></tr> | |
| <tr> | |
| <td>:P</td> | |
| <td>:P [a] :> [b]</td> | |
| <td>Sets cell [a] to the value of cell [b] | |
| </td></tr> | |
| <tr> | |
| <td>:]</td> | |
| <td>:]</td> | |
| <td>Moves the cell pointer left | |
| </td></tr> | |
| <tr> | |
| <td>:></td> | |
| <td>:></td> | |
| <td>Moves the cell pointer right | |
| </td></tr> | |
| <tr> | |
| <td>:D</td> | |
| <td>:D [c]</td> | |
| <td>Sets cell [c] to the cell pointer's position | |
| </td></tr></tbody></table> | |
| <table class="wikitable"> | |
| <caption>Arithmetic | |
| </caption> | |
| <tbody><tr> | |
| <td>:)</td> | |
| <td>:) [a] :> [b] :> [c]</td> | |
| <td>Sets cell [c] to cell [a] + cell [b] | |
| </td></tr> | |
| <tr> | |
| <td>:P</td> | |
| <td>:P [a] :> [b] :> [c]</td> | |
| <td>Sets cell [c] to cell [a] - cell [b] | |
| </td></tr> | |
| <tr> | |
| <td>:]</td> | |
| <td>:] [a] :> [b] :> [c]</td> | |
| <td>Sets cell [c] to cell [a] * cell [b] | |
| </td></tr> | |
| <tr> | |
| <td>:></td> | |
| <td>:> [a] :> [b] :> [c]</td> | |
| <td>Sets cell [c] to cell [a] / cell [b] | |
| </td></tr> | |
| <tr> | |
| <td>:D</td> | |
| <td>:D [a] :> [b] :> [c]</td> | |
| <td>Sets cell [c] to cell [a] % cell [b] | |
| </td></tr></tbody></table> | |
| <table class="wikitable"> | |
| <caption>Flow control | |
| </caption> | |
| <tbody><tr> | |
| <td>:)</td> | |
| <td>:) [n]</td> | |
| <td>Creates a new label [n] | |
| </td></tr> | |
| <tr> | |
| <td>:P</td> | |
| <td>:P [n]</td> | |
| <td>Goes to label [n] | |
| </td></tr> | |
| <tr> | |
| <td>:]</td> | |
| <td>:] [n] :> [a] :> [b]</td> | |
| <td>Goes to label [n] if cell [a] and cell [b] are equal | |
| </td></tr> | |
| <tr> | |
| <td>:></td> | |
| <td>:> [n] :> [a] :> [b]</td> | |
| <td>Goes to label [n] if cell [a] is greater than cell [b] | |
| </td></tr> | |
| <tr> | |
| <td>:D</td> | |
| <td>:D</td> | |
| <td>Halts the program | |
| </td></tr></tbody></table> | |
| <h3><span class="mw-headline" id="Numbers:">Numbers:</span></h3> | |
| <p><br/> | |
| Numbers in :) are stored in base 4. | |
| </p> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <td>:)</td> | |
| <td>0 | |
| </td></tr> | |
| <tr> | |
| <td>:P</td> | |
| <td>1 | |
| </td></tr> | |
| <tr> | |
| <td>:]</td> | |
| <td>2 | |
| </td></tr> | |
| <tr> | |
| <td>:D</td> | |
| <td>3 | |
| </td></tr></tbody></table> | |
| <h3><span class="mw-headline" id="Notes:">Notes:</span></h3> | |
| <p><br/> | |
| <b>The cell pointer</b><br/> | |
| </p> | |
| <ul><li>You can access the cell that the cell pointer points to by accessing cell 0.<br/></li> | |
| <li>The cell pointer can't move left when it's at 1.</li></ul> | |
| <p><b>Comments</b><br/> | |
| You can write a comment by using <code>;</code> which will make a single-line comment. | |
| </p> | |
| <h3><span class="mw-headline" id="Example_programs:">Example programs:</span></h3> | |
| <h4><span id="Hello.2C_World.21:"></span><span class="mw-headline" id="Hello,_World!:">Hello, World!:</span></h4> | |
| <pre class="rectwrap">:) :> :P :) :] :) :O ; H | |
| :) :> :P :] :P :P :O ; e | |
| :) :> :P :] :D :) :O ; l | |
| :) :> :P :] :D :) :O ; l | |
| :) :> :P :] :D :D :O ; o | |
| :) :> :] :D :) :O ; , | |
| :) :> :] :) :) :O ; [space] | |
| :) :> :P :P :P :D :O ; W | |
| :) :> :P :] :D :D :O ; o | |
| :) :> :P :D :) :] :O ; r | |
| :) :> :P :] :D :) :O ; l | |
| :) :> :P :] :P :) :O ; d | |
| :) :> :] :) :P :O ; ! | |
| </pre> | |
| <h4><span class="mw-headline" id="Truth-machine:">Truth-machine:</span></h4> | |
| <pre class="rectwrap">:) :] :D :O ; Get input | |
| :P :) :P :> :P :O ; Set another cell to 1 | |
| :D :) :] :O ; Make a new label | |
| :) :P :D :O ; Print the input | |
| :D :] :] :> :D :> :P :O ; Jump to the label if the input is equal to 1 | |
| :D :D :O ; Halt the program | |
| </pre> | |
| <h4><span class="mw-headline" id="99_bottles_of_beer:">99 bottles of beer:</span></h4> | |
| <pre class="rectwrap">:P :) :P :> :P :] :) :D :O | |
| :P :) :] :> :P :O | |
| :D :) :] :O | |
| :) :P :P :O | |
| ; Print ' bottles of beer on the wall' | |
| :) :> :] :) :) :O | |
| :) :> :P :] :) :] :O | |
| :) :> :P :] :D :D :O | |
| :) :> :P :D :P :) :O | |
| :) :> :P :D :P :) :O | |
| :) :> :P :] :D :) :O | |
| :) :> :P :] :P :P :O | |
| :) :> :P :D :) :D :O | |
| :) :> :] :) :) :O | |
| :) :> :P :] :D :D :O | |
| :) :> :P :] :P :] :O | |
| :) :> :] :) :) :O | |
| :) :> :P :] :) :] :O | |
| :) :> :P :] :P :P :O | |
| :) :> :P :] :P :P :O | |
| :) :> :P :D :) :] :O | |
| :) :> :] :) :) :O | |
| :) :> :P :] :D :D :O | |
| :) :> :P :] :D :] :O | |
| :) :> :] :) :) :O | |
| :) :> :P :D :P :) :O | |
| :) :> :P :] :] :) :O | |
| :) :> :P :] :P :P :O | |
| :) :> :] :) :) :O | |
| :) :> :P :D :P :D :O | |
| :) :> :P :] :) :P :O | |
| :) :> :P :] :D :) :O | |
| :) :> :P :] :D :) :O | |
| :) :> :] :] :O | |
| :) :P :P :O | |
| ; Print ' bottles of beer' | |
| :) :> :] :) :) :O | |
| :) :> :P :] :) :] :O | |
| :) :> :P :] :D :D :O | |
| :) :> :P :D :P :) :O | |
| :) :> :P :D :P :) :O | |
| :) :> :P :] :D :) :O | |
| :) :> :P :] :P :P :O | |
| :) :> :P :D :) :D :O | |
| :) :> :] :) :) :O | |
| :) :> :P :] :D :D :O | |
| :) :> :P :] :P :] :O | |
| :) :> :] :) :) :O | |
| :) :> :P :] :) :] :O | |
| :) :> :P :] :P :P :O | |
| :) :> :P :] :P :P :O | |
| :) :> :P :D :) :] :O | |
| :) :> :] :] :O | |
| ; Print 'take 1 down' | |
| :) :> :P :D :P :) :O | |
| :) :> :P :] :) :P :O | |
| :) :> :P :] :] :D :O | |
| :) :> :P :] :P :P :O | |
| :) :> :] :) :) :O | |
| :) :> :D :) :P :O | |
| :) :> :] :) :) :O | |
| :) :> :P :] :P :) :O | |
| :) :> :P :] :D :D :O | |
| :) :> :P :D :P :D :O | |
| :) :> :P :] :D :] :O | |
| :) :> :] :] :O | |
| ; Print 'pass it around' | |
| :) :> :P :D :) :) :O | |
| :) :> :P :] :) :P :O | |
| :) :> :P :D :) :D :O | |
| :) :> :P :D :) :D :O | |
| :) :> :] :) :) :O | |
| :) :> :P :] :] :P :O | |
| :) :> :P :D :P :) :O | |
| :) :> :] :) :) :O | |
| :) :> :P :] :) :P :O | |
| :) :> :P :D :) :] :O | |
| :) :> :P :] :D :D :O | |
| :) :> :P :D :P :P :O | |
| :) :> :P :] :D :] :O | |
| :) :> :P :] :P :) :O | |
| :) :> :] :] :O | |
| :) :> :] :] :O | |
| :] :P :P :> :] :> :P :O | |
| :D :> :] :> :P :> :] :O | |
| ; Print '1 bottle of beer on the wall | |
| ; 1 bottle of beer | |
| ; take 1 down | |
| ; pass it around' | |
| :) :> :D :) :P :O | |
| :) :> :] :) :) :O | |
| :) :> :P :] :) :] :O | |
| :) :> :P :] :D :D :O | |
| :) :> :P :D :P :) :O | |
| :) :> :P :D :P :) :O | |
| :) :> :P :] :D :) :O | |
| :) :> :P :] :P :P :O | |
| :) :> :] :) :) :O | |
| :) :> :P :] :D :D :O | |
| :) :> :P :] :P :] :O | |
| :) :> :] :) :) :O | |
| :) :> :P :] :) :] :O | |
| :) :> :P :] :P :P :O | |
| :) :> :P :] :P :P :O | |
| :) :> :P :D :) :] :O | |
| :) :> :] :) :) :O | |
| :) :> :P :] :D :D :O | |
| :) :> :P :] :D :] :O | |
| :) :> :] :) :) :O | |
| :) :> :P :D :P :) :O | |
| :) :> :P :] :] :) :O | |
| :) :> :P :] :P :P :O | |
| :) :> :] :) :) :O | |
| :) :> :P :D :P :D :O | |
| :) :> :P :] :) :P :O | |
| :) :> :P :] :D :) :O | |
| :) :> :P :] :D :) :O | |
| :) :> :] :] :O | |
| :) :> :D :) :P :O | |
| :) :> :] :) :) :O | |
| :) :> :P :] :) :] :O | |
| :) :> :P :] :D :D :O | |
| :) :> :P :D :P :) :O | |
| :) :> :P :D :P :) :O | |
| :) :> :P :] :D :) :O | |
| :) :> :P :] :P :P :O | |
| :) :> :] :) :) :O | |
| :) :> :P :] :D :D :O | |
| :) :> :P :] :P :] :O | |
| :) :> :] :) :) :O | |
| :) :> :P :] :) :] :O | |
| :) :> :P :] :P :P :O | |
| :) :> :P :] :P :P :O | |
| :) :> :P :D :) :] :O | |
| :) :> :] :] :O | |
| :) :> :P :D :P :) :O | |
| :) :> :P :] :) :P :O | |
| :) :> :P :] :] :D :O | |
| :) :> :P :] :P :P :O | |
| :) :> :] :) :) :O | |
| :) :> :D :) :P :O | |
| :) :> :] :) :) :O | |
| :) :> :P :] :P :) :O | |
| :) :> :P :] :D :D :O | |
| :) :> :P :D :P :D :O | |
| :) :> :P :] :D :] :O | |
| :) :> :] :] :O | |
| :) :> :P :D :) :) :O | |
| :) :> :P :] :) :P :O | |
| :) :> :P :D :) :D :O | |
| :) :> :P :D :) :D :O | |
| :) :> :] :) :) :O | |
| :) :> :P :] :] :P :O | |
| :) :> :P :D :P :) :O | |
| :) :> :] :) :) :O | |
| :) :> :P :] :) :P :O | |
| :) :> :P :D :) :] :O | |
| :) :> :P :] :D :D :O | |
| :) :> :P :D :P :P :O | |
| :) :> :P :] :D :] :O | |
| :) :> :P :] :P :) :O | |
| :) :> :] :] :O | |
| :) :> :] :] :O | |
| :) :> :D :) :) :O | |
| :) :> :] :) :) :O | |
| :) :> :P :] :) :] :O | |
| :) :> :P :] :D :D :O | |
| :) :> :P :D :P :) :O | |
| :) :> :P :D :P :) :O | |
| :) :> :P :] :D :) :O | |
| :) :> :P :] :P :P :O | |
| :) :> :P :D :) :D :O | |
| :) :> :] :) :) :O | |
| :) :> :P :] :D :D :O | |
| :) :> :P :] :P :] :O | |
| :) :> :] :) :) :O | |
| :) :> :P :] :) :] :O | |
| :) :> :P :] :P :P :O | |
| :) :> :P :] :P :P :O | |
| :) :> :P :D :) :] :O | |
| :) :> :] :) :) :O | |
| :) :> :P :] :D :D :O | |
| :) :> :P :] :D :] :O | |
| :) :> :] :) :) :O | |
| :) :> :P :D :P :) :O | |
| :) :> :P :] :] :) :O | |
| :) :> :P :] :P :P :O | |
| :) :> :] :) :) :O | |
| :) :> :P :D :P :D :O | |
| :) :> :P :] :) :P :O | |
| :) :> :P :] :D :) :O | |
| :) :> :P :] :D :) :O | |
| ; Halt | |
| :D :D :O | |
| </pre> | |
| <h2><span class="mw-headline" id="Interpreter">Interpreter</span></h2> | |
| <ul><li><a class="external text" href="https://github.com/KavehYousefi/Esoteric-programming-languages/tree/main/Smileyface" rel="nofollow">Common Lisp</a> implementation of the :) programming language.</li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20250724043213 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.024 seconds | |
| Real time usage: 0.087 seconds | |
| Preprocessor visited node count: 67/1000000 | |
| Post‐expand include size: 121/2097152 bytes | |
| Template argument size: 2/2097152 bytes | |
| Highest expansion depth: 3/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 5206/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 1.034 1 Template:Wrongtitle | |
| 100.00% 1.034 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:14756-0!canonical and timestamp 20250724043213 and revision id 90443. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b>0x29A</b> is an <a href="/wiki/Esoteric_programming_language" title="Esoteric programming language">esoteric programming language</a> created by <a class="new" href="/w/index.php?title=David_Lewis&action=edit&redlink=1" title="David Lewis (page does not exist)">David Lewis</a> in 2004. It uses a mixture of imperative and functional programming, forming a new paradigm the creator calls <i>dysfunctional programming</i>. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Memory"><span class="tocnumber">1</span> <span class="toctext">Memory</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Commands"><span class="tocnumber">2</span> <span class="toctext">Commands</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-3"><a href="#Stack-pushing_commands"><span class="tocnumber">2.1</span> <span class="toctext">Stack-pushing commands</span></a></li> | |
| <li class="toclevel-2 tocsection-4"><a href="#Looping_commands"><span class="tocnumber">2.2</span> <span class="toctext">Looping commands</span></a></li> | |
| <li class="toclevel-2 tocsection-5"><a href="#Stack-rearranging_commands"><span class="tocnumber">2.3</span> <span class="toctext">Stack-rearranging commands</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-6"><a href="#Function_evaluation"><span class="tocnumber">3</span> <span class="toctext">Function evaluation</span></a></li> | |
| <li class="toclevel-1 tocsection-7"><a href="#Computational_class"><span class="tocnumber">4</span> <span class="toctext">Computational class</span></a></li> | |
| <li class="toclevel-1 tocsection-8"><a href="#External_resources"><span class="tocnumber">5</span> <span class="toctext">External resources</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Memory">Memory</span></h2> | |
| <p>0x29A has a memory consisting of a one-byte register, which is initially zero, two variables called a and b that can contain functions, and a stack of functions, which is initially empty. The two variables are not accessible directly, but are used as a temporary store while popping and pushing functions in the stack. An empty stack behaves as if it contains the identity function ((sk)s). | |
| </p> | |
| <h2><span class="mw-headline" id="Commands">Commands</span></h2> | |
| <h3><span class="mw-headline" id="Stack-pushing_commands">Stack-pushing commands</span></h3> | |
| <p>0x29A contains the following six commands which push the functions of the same name onto the stack: | |
| </p> | |
| <pre>sk+-., | |
| </pre> | |
| <h3><span class="mw-headline" id="Looping_commands">Looping commands</span></h3> | |
| <p>0x29A features two looping commands, represented by the left and right square brackets. When a left square bracket is encountered, then if the register's value is zero, program flow continues at the matching right square bracket (the program halts if there is no matching right square bracket); otherwise program flow continues at the next instruction. When a right square bracket is encountered, then if the register's value is nonzero, program flow continues at the matching left square bracket (or at the beginning of the program if there is no matching left square bracket); otherwise program flow continues at the next instruction. | |
| </p> | |
| <h3><span class="mw-headline" id="Stack-rearranging_commands">Stack-rearranging commands</span></h3> | |
| <p>0x29A contains two commands that rearrange the stack and allow the creation of complex functions. | |
| </p><p>The command represented by the percentage sign pops two functions from the top of the stack, storing them in the variables a and b, and then pushes them back onto the stack in reverse. | |
| </p><p>The command represented by a tilde pops two functions from the top of the stack, storing them in the variables a and b, and the pushes (ba) onto the stack. | |
| </p> | |
| <h2><span class="mw-headline" id="Function_evaluation">Function evaluation</span></h2> | |
| <p>After each command is executed, the function at the top of the stack is evaluated if this is possible. The following rules are used when evaluating functions: | |
| </p> | |
| <ul><li>(((sx)y)z) becomes ((xz)(yz))</li> | |
| <li>((kx)y) becomes x</li> | |
| <li>((.x)y) becomes x, the value of the register is printed (as an ASCII character), and the register is set to 0</li> | |
| <li>((,x)y) becomes x, and the register is set to the ASCII value of a character from the input</li> | |
| <li>((+x)y) becomes x, and the register is incremented</li> | |
| <li>((-x)y) becomes x, and the register is decremented</li></ul> | |
| <h2><span class="mw-headline" id="Computational_class">Computational class</span></h2> | |
| <p>In the evaluation rule for s, it is not specified that either xz or yz are evaluated. This may be a bug. If it is not, Turing completeness is not obvious since a working combinator calculus can no longer be trivially embedded into the language. | |
| </p><p>Indeed function evaluation alone is then decidable and so not Turing complete. By checking about a hundred cases, we can show that every function either halts or reaches the recognizable growing pattern | |
| </p> | |
| <pre>(s<sup>2</sup>k)<sup><i>m</i></sup>(s<sup>3</sup>k(s<sup>2</sup>k))((s<sup>2</sup>k)<sup><i>n</i></sup>(s<sup>3</sup>k(s<sup>2</sup>k))) | |
| </pre> | |
| <p>where <code><i>f</i><sup><i>n</i></sup><i>x</i>=<i>f</i>(<i>f</i>(...(<i>x</i>)...))</code> and <code>k</code> stands for any of <code>k.,+-</code>. Note that <code>s<sup>2</sup>k<i>xy</i>=<i>xy</i></code> so this is just <code>sii(sii)</code> in disguise. | |
| </p><p>Nevertheless, even with this restriction there are enough ingredients to compile <a href="/wiki/Brainfuck" title="Brainfuck">Brainfuck</a> into the language. The basic idea is to represent a brainfuck tape as two functions, one for the part to the left of the pointer and another for the part to the right, while the cell at the pointer is kept in the register. | |
| </p><p>Each half-tape function, when applied to k, will increment the register by the saved amount, and then return the function for a shifted half-tape with the value popped off. | |
| </p><p>To shift a value of 3, say, onto a function f, is to replace f by | |
| </p> | |
| <pre>s(s+)(s(s+)(s(s+)(k f))) | |
| </pre> | |
| <p>This can be achieved with the commands | |
| </p> | |
| <pre>k%~ ss+~~%~ ss+~~%~ ss+~~%~ | |
| </pre> | |
| <p>To shift the register to a function, use | |
| </p> | |
| <pre> k%~ [ss+~~%~ -%~k~] | |
| </pre> | |
| <p>Finally, the output operator in 0x29A is destructive whereas the output operator in brainfuck is not, so one needs to clone the value before handing it to the output operator. This is done by making the functions twice (once in top-of-stack, once in next-to-top-of-stack), thereby destroying the register, running it once, restoring the register, running the output and running the second copy. | |
| </p><p>The translation rules are thus as follows: | |
| </p> | |
| <pre>+ -> +%~k~ | |
| - -> -%~k~ | |
| , -> ,%~k~ | |
| . -> k%~ kk~ [ss+~~%~ % ss+~~%~ % -%~k~] k~ .%~k~ ~ | |
| < -> k%~ [ss+~~%~ -%~k~] % k~ % | |
| > -> % k%~ [ss+~~%~ ~%~k~] % k~ | |
| [ -> [ | |
| ] -> ] | |
| </pre> | |
| <h2><span class="mw-headline" id="External_resources">External resources</span></h2> | |
| <ul><li><a class="external text" href="http://xyzzy.bravehost.com/0x29A.html" rel="nofollow">0x29A website</a></li> | |
| <li><a class="external text" href="http://userpage.fu-berlin.de/~mkarcher/0x29A/" rel="nofollow">A 0x29A implementation and a Brainfuck to 0x29A converter.</a></li> | |
| <li><a class="external text" href="http://oerjan.nvg.org/esoteric/AnaX29A.hs" rel="nofollow">A Haskell program</a> to classify 0x29A dysfunctional expressions.</li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20250724011237 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.011 seconds | |
| Real time usage: 0.012 seconds | |
| Preprocessor visited node count: 27/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:1084-0!canonical and timestamp 20250724011237 and revision id 22636. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b>1+</b>, initially conceived by Jeremy Tan (<a href="/wiki/User:Parcly_Taxel" title="User:Parcly Taxel">User:Parcly Taxel</a>) in 2012 (but with the final specification and interpreter written in 2014), is an esoteric programming language <i>where 1 is the only literal</i>. It is mostly inspired by <a href="/wiki/FALSE" title="FALSE">FALSE</a>, <a href="/wiki/Piet" title="Piet">Piet</a> and <a class="external text" href="https://en.wikipedia.org/wiki/Wang_B-machine" rel="nofollow">Wang's B-machine</a>. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Commands_and_syntax"><span class="tocnumber">1</span> <span class="toctext">Commands and syntax</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-2"><a href="#Undocumented_instruction"><span class="tocnumber">1.1</span> <span class="toctext">Undocumented instruction</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-3"><a href="#Examples"><span class="tocnumber">2</span> <span class="toctext">Examples</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-4"><a href="#Hello_world_program"><span class="tocnumber">2.1</span> <span class="toctext">Hello world program</span></a></li> | |
| <li class="toclevel-2 tocsection-5"><a href="#Infinite_Loop"><span class="tocnumber">2.2</span> <span class="toctext">Infinite Loop</span></a></li> | |
| <li class="toclevel-2 tocsection-6"><a href="#Cat_Program_(EOF_returns_0)"><span class="tocnumber">2.3</span> <span class="toctext">Cat Program (EOF returns 0)</span></a></li> | |
| <li class="toclevel-2 tocsection-7"><a href="#Fibonacci_sequence"><span class="tocnumber">2.4</span> <span class="toctext">Fibonacci sequence</span></a></li> | |
| <li class="toclevel-2 tocsection-8"><a href="#Factorial"><span class="tocnumber">2.5</span> <span class="toctext">Factorial</span></a></li> | |
| <li class="toclevel-2 tocsection-9"><a href="#Truth-Machine"><span class="tocnumber">2.6</span> <span class="toctext">Truth-Machine</span></a></li> | |
| <li class="toclevel-2 tocsection-10"><a href="#Infinite_Looping_Counter"><span class="tocnumber">2.7</span> <span class="toctext">Infinite Looping Counter</span></a></li> | |
| <li class="toclevel-2 tocsection-11"><a href="#Nested_Loop_Example"><span class="tocnumber">2.8</span> <span class="toctext">Nested Loop Example</span></a></li> | |
| <li class="toclevel-2 tocsection-12"><a href="#Quine"><span class="tocnumber">2.9</span> <span class="toctext">Quine</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-13"><a href="#Turing-Completeness"><span class="tocnumber">3</span> <span class="toctext">Turing-Completeness</span></a></li> | |
| <li class="toclevel-1 tocsection-14"><a href="#Constants"><span class="tocnumber">4</span> <span class="toctext">Constants</span></a></li> | |
| <li class="toclevel-1 tocsection-15"><a href="#See_Also"><span class="tocnumber">5</span> <span class="toctext">See Also</span></a></li> | |
| <li class="toclevel-1 tocsection-16"><a href="#Online_Interpreters"><span class="tocnumber">6</span> <span class="toctext">Online Interpreters</span></a></li> | |
| <li class="toclevel-1 tocsection-17"><a href="#External_resources"><span class="tocnumber">7</span> <span class="toctext">External resources</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Commands_and_syntax">Commands and syntax</span></h2> | |
| <p>1+ operates only on an initially empty stack of non-negative integers (negative integers cannot be represented, and indeed ensure that the jumps work; see below). Twelve of the language's thirteen commands do something to the stack: | |
| </p> | |
| <ul><li><b>1</b> pushes the number 1 onto the stack. This is the only literal; all other numbers are constructed with operators like <a href="/wiki/INTERCAL" title="INTERCAL">INTERCAL</a> does. Unlike INTERCAL, however, this restriction is derived from the concept of <a class="external text" href="https://oeis.org/A005245" rel="nofollow">integer complexity</a>, the minimum number of 1's needed to make a number <i>n</i> with only additions and multiplications.</li> | |
| <li><b>+</b> pops the top two numbers and pushes their sum.</li> | |
| <li><b>*</b> is the same as + but pushes the product instead.</li> | |
| <li><b>"</b> duplicates the top number.</li> | |
| <li><b>/</b> rotates the stack upward, sending the top number to the bottom.</li> | |
| <li><b>\</b> rotates the stack downward, sending the bottom number to the top.</li> | |
| <li><b>^</b> swaps the top two numbers.</li> | |
| <li><b><</b> pops the top two numbers and pushes 0 if the top number is less than the second-top number, 1 otherwise. This is the only conditional in 1+.</li> | |
| <li><b>.</b> and <b>,</b> read input as a number or Unicode character respectively and push that on.</li> | |
| <li><b>:</b> and <b>;</b> are corresponding commands for output, popping the top value and printing it as a number or Unicode character respectively.</li></ul> | |
| <ul><li><b>#</b> is the only control structure in 1+: it pops the top value <i>n</i> and sends program flow to immediately after the <i>n</i>th # in the current line of execution (where numbering starts from 0).</li></ul> | |
| <p>Subroutines are defined as <b>(name|symbols)</b> and are called as <b>(name)</b>; they can call other subroutines or themselves (thereby implementing recursion) and the point where they are defined causes their execution too. They are separate lines of execution, so the numbering of #'s in them starts from 0. They are positioned within the overall program such that they never depend on a subroutine that is defined later on. | |
| </p><p>Comments are placed in square brackets (<b>[ ]</b>). | |
| </p> | |
| <h3><span class="mw-headline" id="Undocumented_instruction">Undocumented instruction</span></h3> | |
| <p>There's one undocumented instruction in the original interpreter, <b>d</b>, that prints the whole stack in an obscured format. | |
| </p> | |
| <h2><span class="mw-headline" id="Examples">Examples</span></h2> | |
| <h3><span class="mw-headline" id="Hello_world_program"><a class="mw-redirect" href="/wiki/Hello_world" title="Hello world">Hello world</a> program</span></h3> | |
| <pre>11+"""1+"****"; [H] | |
| 111++""**1+(D|/"\"/^\)1++; [e] | |
| (D)11+""**++"";; [ll] | |
| 111+++"; [o] | |
| /"11+"""***+; [,] | |
| "11+"*+; [ ] | |
| "111++"/*\+; [W] | |
| \"; [o] | |
| 111+++; [r] | |
| (D)11+""**++; [l] | |
| +; [d] | |
| 11+""""****1+; [!] | |
| 111++"*1+; [\n] | |
| </pre> | |
| <p><br/> | |
| </p> | |
| <h3><span class="mw-headline" id="Infinite_Loop">Infinite Loop</span></h3> | |
| <pre>1##1# | |
| </pre> | |
| <h3><span id="Cat_Program_.28EOF_returns_0.29"></span><span class="mw-headline" id="Cat_Program_(EOF_returns_0)">Cat Program (EOF returns 0)</span></h3> | |
| <pre>1##,";1+1<1+# | |
| </pre> | |
| <h3><span class="mw-headline" id="Fibonacci_sequence">Fibonacci sequence</span></h3> | |
| <pre>111##":"\+1# | |
| </pre> | |
| <h3><span class="mw-headline" id="Factorial">Factorial</span></h3> | |
| <pre>.111##^"/*\1+\<1+# | |
| </pre> | |
| <h3><span class="mw-headline" id="Truth-Machine">Truth-Machine</span></h3> | |
| <pre>.1##":"1+1<1+# | |
| </pre> | |
| <h3><span class="mw-headline" id="Infinite_Looping_Counter">Infinite Looping Counter</span></h3> | |
| <pre>11##":1+1# | |
| </pre> | |
| <h3><span class="mw-headline" id="Nested_Loop_Example">Nested Loop Example</span></h3> | |
| <pre>11##111+#":1+"\"/<1+1<11++#"<*1+1# | |
| </pre> | |
| <p>The above code outputs <a class="external text" href="http://oeis.org/A002260" rel="nofollow">A002260</a> using a nested loop. | |
| </p> | |
| <h3><span class="mw-headline" id="Quine">Quine</span></h3> | |
| <p>Here's a quine in 1+ from the Code Golf Stack Exchange user dzaima, with some basic concepts and snippets from <a class="new" href="/w/index.php?title=User:TwilightSparkle&action=edit&redlink=1" title="User:TwilightSparkle (page does not exist)">User:TwilightSparkle</a>, Code Golf Stack Exchange user wizzwizz4, <a class="new" href="/w/index.php?title=User:A&action=edit&redlink=1" title="User:A (page does not exist)">User:A</a>, and Code Golf Stack Exchange user user202729. | |
| </p> | |
| <pre class="rectwrap">11+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+111+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+111+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+11+1+1+1+1+1+11+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+11+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+111+1+1+1+1+1+1+1+1+111+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+111+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+111+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+11+11+1+1+1+1+1+11+1+1+1+1+1+1+11+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+11+1+1+1+1+1+11+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+11+1+1+1+1+1+1+11+11+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+11+1+1+1+1+1+11+1+11+1+1+1+1+1+1+111+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+11+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+11+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+11+1+1+1+1+1+1+11+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+111+1+1+1+1+1+1+1+111+1+1+1+1+1+1+1+111+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+111+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+11+1+1+1+1+1+1+(|11+1<)\(1|11+1+"+1+"*;)($|1+11#(1)11+1+"+"1+*1+;1#1+"//"\^\<11+*#()*+\)(%|()#(1)($)"1+1<#)\(&|()#11+"*"*"++;\"1+1<#) </pre> | |
| <p>Here's a much shorter quine by Code Golf Stack Exchange user Jo King, where he uses his own design. | |
| </p> | |
| <pre class="rectwrap"> (|11+"*"+"1+\1+/)("|1/()11+^)(2|\""++1+/()""+^)++<+/(#|\##"\+;1#()\^\1#)+<+()()(")(2)(2)()()(")()(2)(")(2)()(")()(")()()()(2)(")()()()(2)()()(2)()(")()()()()(2)(2)(")()()()(2)()()(2)()(")(2)()(")(2)(")()(")()()()(2)(")(2)(2)()(")()(2)(")()()()(2)()()(2)()(")(")()(")()(")()()()(2)()()(2)()(")(2)()(2)()(2)(")()(")(2)(")()()(2)()(")()(2)(")(2)(2)()()(")()(2)(")()(2)(")(2)()(")()()()()(2)(2)(")()(2)(")(")(")(2)()(")(2)(")()()(2)()(")()(2)(")()()()(2)(")()(2)(")()(2)(")(")(")()()()(2)()()(2)()(")(2)()(2)()(2)(")()()()(2)()(")(2)(")(2)()(")()()()()(2)(2)(")()(2)(")()()()(2)(")()()()(2)(")(2)()(")(2)(")()()(2)()(")()()()(2)(")(2)()(2)()(2)(")(")(2)(")(2)()(")()()(2)()(")()(2)(")()()()(2)(")()()()(2)()()(2)()(")()(2)(")()()()(2)(")(")()(2)(")(")(2)()()(")(")()(2)(")()()()(2)(")()()()(2)(")(2)()(2)()(2)(")(2)(")(2)()()(2)(")(")(#)@</pre> | |
| <h2><span class="mw-headline" id="Turing-Completeness">Turing-Completeness</span></h2> | |
| <p>1+ is Turing-Complete as any Boolf*** program can be translated into 1+ program. | |
| </p><p>First, we need to push a single 2, which represents the seperator between the memory cells on the left of the pointer and the memory cells on the right of the pointer, and then a single 0, which is the "initial" memory cell. | |
| </p><p>Then, we will be able to translate the <code>@,.<></code> operations: | |
| </p> | |
| <pre>Boolf*** 1+ | |
| --------------------------- | |
| @ 1+1< | |
| , .1^< | |
| . ": | |
| < / | |
| > \ | |
| </pre> | |
| <p>In order to guarantee an infinite tape, the tape-extending instruction is also neccecary for 1+. This pushes a 0 onto the stack. | |
| </p> | |
| <pre>Boolf*** 1+ | |
| --------------------------- | |
| x(extended) 11+1< | |
| </pre> | |
| <p>[] will be a lot more trickier, as they involves flow control. You'll have to figure out which bracket matches which bracket first. Let's say the left bracket is the Lth bracket and the right bracket is the Rth bracket. Then that pair of brackets will be translated as follows: | |
| </p> | |
| <pre>Boolf*** 1+ | |
| --------------------------- | |
| [ "1+1<[Push R-L]*[Push L]+# | |
| ] "1+1<[Push R-L]*[Push L]+# | |
| </pre> | |
| <p>It's obvious to see it's possible to push every positive number and 0, thus 1+ is Turing-Complete. | |
| </p> | |
| <h2><span class="mw-headline" id="Constants">Constants</span></h2> | |
| <p><a class="external text" href="https://tio.run/##lVZNc9s2EL3rV2x4SEmTZiw7PTQS1VEyybST6fTAXDquDxAFW3ApkiVAOWlHv11dLAB@yhlXMyLBxe7bh8XuAo/swC4ft3@dTmJflbWCRxTEjRJ5fLGYVc0mFxlkOZMSfmOigH9nAFYqFVP4OpRiC3uc81NVi@Lh9g5Y/SADUgUQhQIBCfxaKP7A67hiteT44Wul26u7YEFqvzC5S7lapitAVwmwPPdFJEaznzmvlhYpgnS1AqGVC/7kVHxrcV/W4Kcg4R3iBagWs@3W14oaw5exUHwfgQys/hhZrwKR0U6V67pm31rbjjPJZSwxbD7r@x2DEQ0WQPpNote4bFRcYahUXiARFnrvwAtlvImzcst9x@iMsrctC@4N5/lXofwrkh3xbzelF06KJG5CEdFecLcxPZXD@RiKe/ALSBK4cjYAhzaOacv0CDyXvFWxoc/0mtF3cTmP0GsHAbApy5yzAjJWVI3cofcsluIfDssE@GWxaBU1A6sUWNdZjDFoXbdKxn6VwLzv6BmEbVMNEMYY10MMaA31c2jYze2bfDR3nI1H5m2e9Ki5auoCDmb7jrOZKTVKoDXwr4oXWwkfyj2WDdvkPIL3mPP7Kud7Xqj@jKmNtVZYEfs1sAW8h42GppxHQaQFbnFqp6tC19rCjDc43rhEskWuU2aHafGBUtNaWtYs7mbOmGXEjX8p/Y4alBOMTq2M2RjHZQr/u2G59H/fPPJMnQGx837PVVAGLR4G1kY2JUtbJfeiYHnr49M6/YIRUHXDtZWZTKGq@aH7pnaGdTeU6MQZSlxk@kgZQcGbN6ALnYAHNixToiw6C8vStFX4/PEPZOfBPLz401t6Wi1td4QyFwvVFi4SxK/L@fXNWyPRvnSRN3luBNlE4hh3MIaP@z6SQ4yH6SMiohWZD@Z4WNRqwEMs@hwrKrNwPvLBhryyasKqatPt4mYOYbsNRAx0hfuWGFEy/EaZYhqXzvZIK2r@Xc4hSFmNk9xtv1GgBuBONuwZpmvphqF2dflE@B/ruqx9D7vOD0obuIbdA4zNgyjrGIVGas6k64jKsUeLWsv/8YoGL/B60fd6M/FKXXIUDGcbwduJfrZ/Xh/Ztr5@his8GvBQ@HECQa39DAQqz0fKL@hP/Rp8eU/RAdatoDsD9DUiwSMtgNK1d61EPZO24lUCZhQ41/eIzBetvdJ9BdUX/SPS3YyuFvhamh4CIgz7hw/tNkVNO1E0Ou8EiKSMXb6aHzkeyNxRZDFct5uc4mcWPV3H007kHBm@SnQfgdevQZnhdA220GkVZvz9dWTnFpJ9ZyUy6UiY4aI9bXu7b7upKs1gWlfmvmNBvds7z163jJ3sXWVbDNoVq4b3ngQ6mjZC7m7Rv0pJuvdo29DTF0C3rozkHcSxn9PeLWqGnmFFRWN4Zf38f2Yt3qAjUCztlRMbEB4vcbZj9RrvsmZ77NF5Op1@@g8" rel="nofollow">Generator for this shortest way table.</a> | |
| </p><p>Here's the shortest known way to push a specific number (I'm too lazy to complete the table, find constants out yourself!). (See <a class="external text" href="https://esolangs.org/w/index.php?title=1%2B&oldid=66497" rel="nofollow">this revision</a> to see an alternative list of constants.) | |
| </p> | |
| <pre> Number Code | |
| ---------------------------------------------- | |
| 0 11+1< | |
| 1 1 | |
| 2 11+ | |
| 3 111++ | |
| 4 11+"* | |
| 5 111+"*+ | |
| 6 11+""*+ | |
| 7 111+""*++ | |
| 8 11+""** | |
| 9 11"++"* | |
| 10 11+"""**+ | |
| 11 11+"1+"*+ | |
| 12 11+"""*+* | |
| 13 11"+"""*+*+ | |
| 14 11+""""*+*+ | |
| 15 11"++"""*++ | |
| 16 11+"*"* | |
| 17 11"+"*"*+ | |
| 18 11+""*"*+ | |
| 19 11"+""*"*++ | |
| 20 11+"*""*+ | |
| 21 11"+"*""*++ | |
| 22 11+""*""*++ | |
| 23 11"+""*""*+++ | |
| 24 11+""""*+** | |
| 25 11"+"*+"* | |
| 26 11""+"*+"*+ | |
| 27 11"++""** | |
| 28 11""++""**+ | |
| 29 11+"1+""**+ | |
| 30 11"++"""**+ | |
| 31 11""++"""**++ | |
| 32 11+""*"** | |
| 33 11"+""*"**+ | |
| 34 11+"""*"**+ | |
| 35 11"+"""*"**++ | |
| 36 11+""*+"* | |
| 37 11"+""*+"*+ | |
| 38 11+"""*+"*+ | |
| 39 11"++""+"*+ | |
| 40 11+""*""*+* | |
| 41 11"+""*""*+*+ | |
| 42 11+""*+""*+ | |
| 43 11"+""*+""*++ | |
| 44 11+"""*""*++* | |
| 45 11"++""""*++* | |
| 46 11+""""*""*++*+ | |
| 47 11+"1+""""*++*+ | |
| 48 11+"*"*""++ | |
| 49 11"+""*++"* | |
| 50 11"+"*+"*"+ | |
| 51 11""+"*+""+*+ | |
| 52 11+"*""*""+++ | |
| 53 11"+"*""""++*++ | |
| 54 11"++""**"+ | |
| 55 11""++"""+**+ | |
| 56 11"+""*++""*+ | |
| 57 11"++"""**"++ | |
| 58 11+""*"1+"*+* | |
| 59 11"+""1+""**+*+ | |
| 60 11+"*""*+""++ | |
| 61 11"+"*""*+""+++ | |
| 62 11+""*""*+""+++ | |
| 63 11"++""""+*+* | |
| 64 11+""**"* | |
| 65 11"+"*""**+ | |
| 66 11+""*""**+ | |
| 67 11"+""*""**++ | |
| 68 11+"*"""**+ | |
| 69 11"+"*"""**++ | |
| 70 11+""*"""**++ | |
| 71 11"+""*"""**+++ | |
| 72 11+""**""*+ | |
| 73 11"+"""*+"**+ | |
| 74 11+"""**""*++ | |
| 75 11"+"*+"""++* | |
| 76 11+""""*+"*+* | |
| 77 11"+""""*+"*+*+ | |
| 78 11+""*+""*"++ | |
| 79 11"+""*+"""+*++ | |
| 80 11+"*"""*+* | |
| 81 11"++"*"* | |
| 82 11""++"*"*+ | |
| 83 11+"1+"*"*+ | |
| 84 11"++""*"*+ | |
| 85 11""++""*"*++ | |
| 86 11+"1+""*"*++ | |
| 87 11"++"""*"*++ | |
| 88 11+""""*""*++** | |
| 89 11+""**"1+"*+ | |
| 90 11"++"*""*+ | |
| 91 11""++"*""*++ | |
| 92 11+"1+"*""*++ | |
| 93 11"++""*""*++ | |
| 94 11""++""*""*+++ | |
| 95 11+"1+""*""*+++ | |
| 96 11+""*"**""++ | |
| 97 11"+""*"""++**+ | |
| 98 11"+""*++""+* | |
| 99 11"++"*"""*++ | |
| 100 11+"""**+"* | |
| 101 11"+"""**+"*+ | |
| 102 11+""""**+"*+ | |
| 103 11"++""*1+"*+ | |
| 104 11+"*""1+"**+ | |
| 105 11"+"*+""+"*+ | |
| 106 11""+"*+""+"*++ | |
| 107 11+""*1+""+"*++ | |
| 108 11"++""+"** | |
| 109 11""++""+"**+ | |
| 110 11+"""**+""*+ | |
| 111 11"++"""+"**+ | |
| 112 11+"*"""""*+++* | |
| 113 11+"1+"""+"**++ | |
| 114 11"++""""+"**++ | |
| 115 11"+"*+""+""*++ | |
| 116 11+"*""1+"*+* | |
| 117 11"++"""+"*+* | |
| 118 11""++"""+"*+*+ | |
| 119 11+"1+"""+"*+*+ | |
| 120 11+"*"1+""*+* | |
| 121 11+"1+"*+"* | |
| 122 11"+"1+"*+"*+ | |
| 123 11+""1+"*+"*+ | |
| 124 11+"*""1+""*+*+ | |
| 125 11"+"*+""** | |
| 126 11""+"*+""**+ | |
| 127 11+""*1+""**+ | |
| 128 11+""*""*** | |
| 129 11"+""*""***+ | |
| 130 11+"""*""***+ | |
| 131 11"+"""*""***++ | |
| 132 11+"""*""**+* | |
| 133 11"+"""*""**+*+ | |
| 134 11+"""""**"*+*+ | |
| 135 11"++"""""*++** | |
| 136 11+""*"""**+* | |
| 137 11"+""*"""**+*+ | |
| 138 11+"""*"""**+*+ | |
| 139 11"+"""*"""**+*++ | |
| 140 11+"""*"""**++* | |
| 141 11"+"""*"""**++*+ | |
| 142 11+""""*"""**++*+ | |
| 143 11+"1+"*+"""*++ | |
| 144 11+"""*+*"* | |
| 145 11"+"""*+*"*+ | |
| 146 11+""""*+*"*+ | |
| 147 11"++"""*+"*+ | |
| 148 11+"*"""++"*+ | |
| 149 11"+"*"""++"*++ | |
| 150 11"+"*+"""*+* | |
| 151 11""+"*+"""*+*+ | |
| 152 11+"""""*+"*+** | |
| 153 11"++""+""+"*++ | |
| 154 11+"*"1+"""*+*+ | |
| 155 11"+"*+""""*+*+ | |
| 156 11+"""*+*""*+ | |
| 157 11"+"""*+*""*++ | |
| 158 11+""""*+*""*++ | |
| 159 11"++"""*+""*++ | |
| 160 11+""*"""*+** | |
| 161 11"+""*"""*+**+ | |
| 162 11"++"*"*"+ | |
| 163 11""++"*""+*+ | |
| 164 11""++"*"*+"+ | |
| 165 11"++""*""+*+ | |
| 166 11+""1+"*"*+* | |
| 167 11"+""1+"*"*+*+ | |
| 168 11"++""*"*+"+ | |
| 169 11"+"""*+*+"* | |
| 170 11""+"""*+*+"*+ | |
| 171 11"++"*"""+*+ | |
| 172 11""++"*""*"+++ | |
| 173 11+"1+"*""*"+++ | |
| 174 11"++""*"""+*++ | |
| 175 11"+"*+""""*++* | |
| 176 11+"*""""*+"++* | |
| 177 11"+"*""""*+"++*+ | |
| 178 11+"""**"1+"*+* | |
| 179 11"+"""**"1+"*+*+ | |
| 180 11"++"*""*+"+ | |
| 181 11""++"*""*+"++ | |
| 182 11"+"""*+*+""*+ | |
| 183 11"++""*""*+"++ | |
| 184 11+""1+"*""*++* | |
| 185 11"+"*+""1+"**+ | |
| 186 11"++""*""*++"+ | |
| 187 11""++""*""*++"++ | |
| 188 11""++""*""*+++"+ | |
| 189 11"++""""*"++** | |
| 190 11""++"""""+*+**+ | |
| 191 11+"1+""""*"++**+ | |
| 192 11+""**"*""++ | |
| 193 11"+"*""""++**+ | |
| 194 11+""*""""++**+ | |
| 195 11"+"*""**+""++ | |
| 196 11+""""*+*+"* | |
| 197 11"+""""*+*+"*+ | |
| 198 11+"""""*+*+"*+ | |
| 199 11"++""1++"+"*+ | |
| 200 11+""""**+"** | |
| 201 11"+""""**+"**+ | |
| 202 11+"""""**+"**+ | |
| 203 11"+""*++""+"*+ | |
| 204 11+"""""**+"*+* | |
| 205 11"+"*+""+""+*+ | |
| 206 11"++""*1+"*+"+ | |
| 207 11"+"*"""**++""++ | |
| 208 11+"*"""""++*+* | |
| 209 11"++"*"1+""+*+ | |
| 210 11+"""**+""*"++ | |
| 211 11"+"""**+"""+*++ | |
| 212 11+""""**+"""+*++ | |
| 213 11"++""1+"""**++* | |
| 214 11+"""*1+""+"*++* | |
| 215 11"+"*+""+"""+*++ | |
| 216 11+""*+""** | |
| 217 11"+""*+""**+ | |
| 218 11+"""*+""**+ | |
| 219 11"++""+""**+ | |
| 220 11+""""**+""*+* | |
| 221 11"+"*+"1+""**+ | |
| 222 11+""*+"""**+ | |
| 223 11"+""*+"""**++ | |
| 224 11+"""*+"""**++ | |
| 225 11"++"""*++"* | |
| 226 11""++"""*++"*+ | |
| 227 11+""*1+""++"*+ | |
| 228 11+""*+""""**++ | |
| 229 11+"*"1+""++"*+ | |
| 230 11"+"*+"""++"*+ | |
| 231 11""+"*+"""++"*++ | |
| 232 11+""*""1+"*+** | |
| 233 11"+""*""1+"*+**+ | |
| 234 11"++"""+"*+"+* | |
| 235 11""++""+"""+*+*+ | |
| 236 11""++"""+"*+*+"+ | |
| 237 11"++"""+"""+*+*+ | |
| 238 11+""1+"""+"*+*+* | |
| 239 11+""""*+*+"1+"*+ | |
| 240 11+"*"""*+""++* | |
| 241 11"+"*"""*+""++*+ | |
| 242 11+""1+"*+"** | |
| 243 11"++""*"** | |
| 244 11""++""*"**+ | |
| 245 11+"1+""*"**+ | |
| 246 11"++"""*"**+ | |
| 247 11""++"""*"**++ | |
| 248 11+"1+"""*"**++ | |
| 249 11"++""""*"**++ | |
| 250 11"+"*+""*"+* | |
| 251 11""+"*+""**"++ | |
| 252 11"++"""*"*+* | |
| 253 11""++"""*"*+*+ | |
| 254 11+"""*+"""*+*+ | |
| 255 11"++""""*"*+*+ | |
| 256 11+"*"*"* | |
| 257 11+"+"*"*1+ | |
| 258 11+""+"*"*+ | |
| 260 11+"+""*"*+ | |
| 272 11+"+"*"1+* | |
| 289 111+"+"*+"* | |
| 324 111++"*"+"* | |
| 400 11+"+"1+*"* | |
| 512 11+"+"*"*"+ | |
| 625 11+"1++"*"* | |
| 729 111++""**"* | |
| 1024 11+"+"*"+"* | |
| 1296 11+"1+*"*"* | |
| 4096 11+"+"+"*"* | |
| 6561 111++"*"*"* | |
| 65536 11+"+"*"*"* | |
| </pre> | |
| <h2><span class="mw-headline" id="See_Also">See Also</span></h2> | |
| <ul><li><a href="/wiki/1%2B/Snippets" title="1+/Snippets">1+/Snippets</a></li> | |
| <li><a href="/wiki/1%2B/Minimalization" title="1+/Minimalization">1+/Minimalization</a></li> | |
| <li><a href="/wiki/1%2B/Programs" title="1+/Programs">1+/Programs</a></li></ul> | |
| <h2><span class="mw-headline" id="Online_Interpreters">Online Interpreters</span></h2> | |
| <p>Code must be written in the 'Input' box. | |
| </p> | |
| <ul><li><a class="external text" href="https://tio.run/##jVVbb5tIFH73rzgZPwABg3Gyahfih6ZSq64iK8q2DytMEIZxjZbbzgy5aNvf7p4BY8COvevYZObMd75zH8pXsSny2XY7ho0QJXcsqwxZlL6K8IWmpqiyVcrMqMissuDCev9u@v63d/b1lf27leSCspJRfE7WBZvYkySflDXfaDS@sCrOrFWSWzR/gp14DLYOPT1cw317dF/bha/SMFjwB2U0k9vcgNnUvkbEXRLRPKKQcPj4EW7/mvz5Aa7NKYI/fbgD27zC1efFN/h8f/d0NVqzIoMgWFeiYjQIIMnKggkoGTqA0jwSCdrdSfkrbxSiIk1pfcRbjZj@U9HRiBvAY5g3W1Uz4N@fo1FM11DktEwrrnLEzmGBW80ZAX6SNeQFcjPR7HeylOYq2jND9v1Jg4s5zLpj@ak9VMk3Hn6nDhDQoUV7Ux93BLx1klIQBawo0BcaVYLGPtEGLFKHviRCtTt5kpfoYVH2HPBs3wCFKR2Ihc8IQqjJaBirA20zSgtOdzKacvSvgWOMtax@bDIDHgxYcWHArQELPPd8mS@jS94UvzUYWwci2QhINEhTBPM5KKoyTM4t6HOwByK0Y4YlBhWrC@2YQTtimBwyPHiSoyxKVfNlCQeHSHQLNzAdsvQK9SVbhWmIjRnDioXR31Twi4NiDAoye8PJsQJhHqMh3EwdzOAbES260GufLuZ9p/6fM4dO1I@FAVEmexeL8inEqtbS541ssgWGLhsWq6N1xgrZRyjyFn4/FtntyOQc5k/CMUhbcYC3gdnDDNG0w@l9HG/qIqegWZ3Wu3xL7/K/9chAz5vY/mmsVWNZIUJBz8WwXPaBkzPIxxpIX4S07u2cNVqvz7hy03d7KvPcxnyzX8kZhTPGx8gh53OTtZb9k1izby9ccVU2HDZBgBdDJVQlx5cFZQ5OnHYm2UafpWBxnyHahNizoiHBy@4MjYM0dcuDuk8ZMmIohJzWcqVxHAEu4qIS5jNLsDhVnkQb1tKcsemhdjMoX1lFT8IOr6z6UhV5OzHYybbzgJPjm/iqFYl816jKD@X4xkBK1MMbGp2OPbmc@vJ@kquZfwTfv4f22GNKWeuH/tQeOh8rsEusyjv1@qo/MdX@Pivd3dG7rhAYBHmYyVcwwkkQZGGSBwFp@Fqnte3WtnVC8Is/6/LRIst66y7x/yWxddeSZ66r/rB1@acR13okxFY1oquajgji6o@uuySuqrmW66LK1qw7y8Qc/wI" rel="nofollow">1+ interpreter on tio.run</a></li> | |
| <li><a class="external text" href="https://tio.run/##jVVbb5tIFH7nV5zgByBgME5W7UL80FRq1VVkRdn2YYUJwjCu0QLDzgy5aNvf7p4BY7Ade9exyVy@8537oXoVa1pON5sRrIWouOc4VcyS/FXELyS3RV0sc2YntHAqyoXz/t3k/W/v3Osr93cnKwVhFSP4HK8oG7vjrBxXDZ@ijC6cmjNnmZUOKZ9gezwC14SBHK7hvru6b/TCV6kYHPiDMFLIbWnBdOJeI@IuS0iZEMg4fPwIt3@N//wA1/YEwZ8@3IFrX@Hq8/wbfL6/e7pSsqKiTAB/5cqK0QISmuckERktOWzvUvJPTRSFW8BTmLVb3bDg35@KkpIV0JJUec11jtgZzHFreArgJ1tBSZGbiXa/PctJqaM@O2bfnwy4mMG0v5afiqHzoH7j8XfigQomdOhgEuJOhWCV5QQEhSUB8kKSWpA0VPdIpAh5yYTuGr3uskIDaTXQH7ihBRrTehCLnxGEUJuRONX3pO0kp5xsz0jO0bwWji42Z81jXVjwYMGSCwtuLZjjfRDKcFl97Cb4bcBYE5DIDCPRXpQSmM1A07X92NyCOQN37wj12HGFTqX63DhmMI4YxocMD4HkqGilG6HM4N4lEt3CDUz2WQZ5@lIs4zzGikthyeLkbyL4hXoE3uVj@oaNIw3iMkU9uJl4GMA3HJr3njcmXcyGNv0vWw5taB5zC5JCFi6m5FOMOW1On9eywubouKxWzI3R66KyivAomIdDV2SpI5N3GD0JRx9dzQPe@TUoyraUepw5xPE2K7IF2tVpucu35C7/W07dkwvGbnga6zRYRkUsyDkfFoshcHwG@dgAyYuQ2oOtsVZn9RlTboZmT2ScO59vdivZoXBG@Qg5ZHeui05zeBJrD/XFS65jvcm6iHAs1ELXSnwHEOZhvxlngm0NWShLhwzJOsaSFS0JTrozNB7StBW/tfsk0pcKsey5SGkt7GeWYULqMkvWrCuSM3oClG6b4yuryUnY4ZBqxqgouy7B6nW9B@yW0Ma3psjky0XXfmjGkRBSohzOZDQ6DeRyEsqJJFfT8Ai@e/HssMeUMr8Pw049ND7VYBdMpQfgbD/RyOEuKP24GAwoBEZRGRckiiRcjaIizsooUlu@zmZjs3FdU1Xxiz/n8tFRF83WX@D/S9U1fUfe@b7@wzXln6H6zqOqurqhmrphIkL1zUffX6i@bviO76PIxm6KycYQ/wI" rel="nofollow">Older 1+ interpreter where integer output has trailing newline</a></li></ul> | |
| <h2><span class="mw-headline" id="External_resources">External resources</span></h2> | |
| <ul><li><a class="external text" href="http://parclytaxel.tumblr.com/post/86487154484/the-1-programming-language" rel="nofollow">Tumblr mirror of the specification</a></li> | |
| <li><a class="external text" href="http://parclytaxel.tumblr.com/post/87085714319/interpreter-for-1-in-python" rel="nofollow">Interpreter for the language in Python</a></li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20250723232516 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.017 seconds | |
| Real time usage: 0.022 seconds | |
| Preprocessor visited node count: 75/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 9896/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:9324-0!canonical and timestamp 20250723232516 and revision id 96179. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><dl><dd><i>The title of this article is not correct because of technical limitations. The correct title is actually <b>><></b></i>.</dd> | |
| <dd><span class="dablink"><i>Not to be confused with <a href="/wiki/Fysh" title="Fysh">Fysh</a>.</i></span></dd></dl> | |
| <p><b>><></b> (pronounced as if it were spelled as “fish”) is a <a href="/wiki/Push-down_automaton" title="Push-down automaton">stack-based</a>, reflective, two-dimensional esoteric programming language. It draws inspiration from, among others, <a href="/wiki/Befunge" title="Befunge">Befunge</a>. It was invented by <a href="/wiki/User:Harpyon" title="User:Harpyon">User:Harpyon</a> in 2009. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Concepts"><span class="tocnumber">1</span> <span class="toctext">Concepts</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-2"><a href="#Code_execution"><span class="tocnumber">1.1</span> <span class="toctext">Code execution</span></a> | |
| <ul> | |
| <li class="toclevel-3 tocsection-3"><a href="#Mirrors"><span class="tocnumber">1.1.1</span> <span class="toctext">Mirrors</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-2 tocsection-4"><a href="#Stacks"><span class="tocnumber">1.2</span> <span class="toctext">Stacks</span></a> | |
| <ul> | |
| <li class="toclevel-3 tocsection-5"><a href="#The_register"><span class="tocnumber">1.2.1</span> <span class="toctext">The register</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-2 tocsection-6"><a href="#Input/output"><span class="tocnumber">1.3</span> <span class="toctext">Input/output</span></a></li> | |
| <li class="toclevel-2 tocsection-7"><a href="#Errors"><span class="tocnumber">1.4</span> <span class="toctext">Errors</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-8"><a href="#Instructions"><span class="tocnumber">2</span> <span class="toctext">Instructions</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-9"><a href="#Movement_and_execution"><span class="tocnumber">2.1</span> <span class="toctext">Movement and execution</span></a></li> | |
| <li class="toclevel-2 tocsection-10"><a href="#Literals_and_operators"><span class="tocnumber">2.2</span> <span class="toctext">Literals and operators</span></a></li> | |
| <li class="toclevel-2 tocsection-11"><a href="#Stack_manipulation"><span class="tocnumber">2.3</span> <span class="toctext">Stack manipulation</span></a></li> | |
| <li class="toclevel-2 tocsection-12"><a href="#Input/output_2"><span class="tocnumber">2.4</span> <span class="toctext">Input/output</span></a></li> | |
| <li class="toclevel-2 tocsection-13"><a href="#Reflection/miscellaneous"><span class="tocnumber">2.5</span> <span class="toctext">Reflection/miscellaneous</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-14"><a href="#Examples"><span class="tocnumber">3</span> <span class="toctext">Examples</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-15"><a href="#Hello,_world!"><span class="tocnumber">3.1</span> <span class="toctext">Hello, world!</span></a></li> | |
| <li class="toclevel-2 tocsection-16"><a href="#Cat_Program"><span class="tocnumber">3.2</span> <span class="toctext">Cat Program</span></a></li> | |
| <li class="toclevel-2 tocsection-17"><a href="#FizzBuzz"><span class="tocnumber">3.3</span> <span class="toctext">FizzBuzz</span></a></li> | |
| <li class="toclevel-2 tocsection-18"><a href="#Fibonacci_sequence"><span class="tocnumber">3.4</span> <span class="toctext">Fibonacci sequence</span></a></li> | |
| <li class="toclevel-2 tocsection-19"><a href="#Lucas_sequence"><span class="tocnumber">3.5</span> <span class="toctext">Lucas sequence</span></a></li> | |
| <li class="toclevel-2 tocsection-20"><a href="#Factorial"><span class="tocnumber">3.6</span> <span class="toctext">Factorial</span></a></li> | |
| <li class="toclevel-2 tocsection-21"><a href="#Quine"><span class="tocnumber">3.7</span> <span class="toctext">Quine</span></a></li> | |
| <li class="toclevel-2 tocsection-22"><a href="#Square_root"><span class="tocnumber">3.8</span> <span class="toctext">Square root</span></a></li> | |
| <li class="toclevel-2 tocsection-23"><a href="#Brainfuck_interpreter"><span class="tocnumber">3.9</span> <span class="toctext">Brainfuck interpreter</span></a></li> | |
| <li class="toclevel-2 tocsection-24"><a href="#Basic_calculator"><span class="tocnumber">3.10</span> <span class="toctext">Basic calculator</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-25"><a href="#Interpreters"><span class="tocnumber">4</span> <span class="toctext">Interpreters</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-26"><a href="#fish.py"><span class="tocnumber">4.1</span> <span class="toctext">fish.py</span></a></li> | |
| <li class="toclevel-2 tocsection-27"><a href="#fishlanguage"><span class="tocnumber">4.2</span> <span class="toctext">fishlanguage</span></a></li> | |
| <li class="toclevel-2 tocsection-28"><a href="#Mousetail's_Fish_Interpreter"><span class="tocnumber">4.3</span> <span class="toctext">Mousetail's Fish Interpreter</span></a></li> | |
| <li class="toclevel-2 tocsection-29"><a href="#go-fish"><span class="tocnumber">4.4</span> <span class="toctext">go-fish</span></a></li> | |
| <li class="toclevel-2 tocsection-30"><a href="#fish.java"><span class="tocnumber">4.5</span> <span class="toctext">fish.java</span></a></li> | |
| <li class="toclevel-2 tocsection-31"><a href="#fishr"><span class="tocnumber">4.6</span> <span class="toctext">fishr</span></a></li> | |
| <li class="toclevel-2 tocsection-32"><a href="#fish-jit"><span class="tocnumber">4.7</span> <span class="toctext">fish-jit</span></a></li> | |
| <li class="toclevel-2 tocsection-33"><a href="#Older_interpreters"><span class="tocnumber">4.8</span> <span class="toctext">Older interpreters</span></a> | |
| <ul> | |
| <li class="toclevel-3 tocsection-34"><a href="#Python"><span class="tocnumber">4.8.1</span> <span class="toctext">Python</span></a></li> | |
| <li class="toclevel-3 tocsection-35"><a href="#Delphi"><span class="tocnumber">4.8.2</span> <span class="toctext">Delphi</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-2 tocsection-36"><a href="#More"><span class="tocnumber">4.9</span> <span class="toctext">More</span></a></li> | |
| </ul> | |
| </li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Concepts">Concepts</span></h2> | |
| <p>><> is a two-dimensional language, meaning the code is not necessarily executed in a linear manner. Using various instructions, the direction the code is read can be changed to either up, down, left or right. It is also a stack-based language, so all operations are performed on a stack. You can also store and retrieve values in the codebox, so making a proper compiler is very hard, if not impossible. | |
| </p><p>What makes ><> unique is the fact that it supports multiple stacks. A program starts off with one stack, where values are pushed and popped. The program can however create a new stack on top of the original one, with a specific amount of values moved over from the original stack. The program can create as many new stacks as it wants to. When a stack is removed, the values residing on it are moved to the top of the underlying stack. <a href="#Stacks">Example here</a>. Each stack is effectively a new scope in the program; this allows for writing functions and snippets to drop into code easily. | |
| </p> | |
| <h3><span class="mw-headline" id="Code_execution">Code execution</span></h3> | |
| <p>><> code is laid out in a two-dimensional <i>codebox</i>. The codebox is infinite in all directions, positive and negative. It is traversed by the instruction pointer, or the IP. | |
| </p> | |
| <dl><dd><i>Note</i>: all coordinates for the codebox are given as (character,line), i.e., (column,row).</dd></dl> | |
| <p>The instruction pointer starts out at (0,0), i.e. the top-left of the script. It initially moves towards the right, but its direction can be changed using a variety of instructions. When the IP reaches the end of the code in any direction, it will wrap around, or "jump" to the opposite side. The IP will never reach the negative side of the code; this makes this space useful for storing values. Execution will not stop until a <code>;</code> instruction is met, or an error occurs. | |
| </p><p>In the following example, the IP moves upwards, wraps around to the bottom, moves leftwards, wraps around to the right side, goes upwards, then leftwards, and stops. | |
| </p> | |
| <pre>^ ; < | |
| < ^ | |
| </pre> | |
| <h4><span class="mw-headline" id="Mirrors">Mirrors</span></h4> | |
| <p>Mirrors are special kinds of instructions that will change the direction of the IP depending on the direction it already has. For example, if the IP is moving rightwards and meets a <code>\</code> instruction, it will be "reflected" (unrelated to <a class="extiw" href="https://en.wikipedia.org/wiki/Reflection_(computer_programming)" title="wikipedia:Reflection (computer programming)">reflection</a>) downwards. If the IP meets it going downwards, it will be reflected to the right, and so on. Meeting <code>_</code> horizontally or <code>|</code> vertically equals a <a href="/wiki/Nop" title="Nop">NOP</a>, but meeting them vertically and horizontally, respectively, will invert the direction, and <code>#</code> will do so unconditionally. | |
| </p> | |
| <h3><span class="mw-headline" id="Stacks">Stacks</span></h3> | |
| <p>><> is stack-based, and thus every instruction except movement-related and the end-execution instruction (<code>;</code>) do something to the stack. You can push numbers and input, perform modifications and pop output using various instructions. You can also create new stacks, this using the <code>[</code> instruction. Creating a new stack pulls a specified number of items from the current stack onto the new one. The new stack is completely isolated from the previous one, and an arbitrary amount of stacks can be created on top of each other. When the <code>]</code> instruction is met, the current stack is popped and its values are moved back to the underlying stack. If the current stack is the last stack, <code>]</code> simply empties the stack and registry. | |
| </p> | |
| <pre>12345 3[ r ] rnnnnn; | |
| ^ ^ ^ ^ ^ | |
| | | | | | Output: 12543. The three top values were reversed! | |
| | | | | | |
| | | | | The second stack is removed, putting its values back to the first stack. | |
| | | | | |
| | | | The second stack is reversed. | |
| | | | |
| | | A second stack is created, pulling 3 values from the first stack | |
| | | |
| | Numbers 1-5 are pushed onto the first stack. | |
| </pre> | |
| <h4><span class="mw-headline" id="The_register">The register</span></h4> | |
| <p>The <code>&</code> instruction is used to store and retrieve values in a <i>register</i>. If the register is empty, <code>&</code> stores a value in it. When the register holds a value, <code>&</code> pushes it back onto the stack. | |
| </p><p>When creating new stacks, new registers are also created. However, the values aren't moved around; each stack starts off with an empty register, and when the stack is removed, the register is dropped. | |
| </p> | |
| <h3><span id="Input.2Foutput"></span><span class="mw-headline" id="Input/output">Input/output</span></h3> | |
| <p>><> has three input/output instructions: <code>i</code> for input and <code>o</code>/<code>n</code> for output. The <code>i</code> instruction simply reads a character from stdin. If no more input is available, <code>i</code> pushes <code>-1</code>. Note that there is no instruction to input a number, you will have to parse the characters yourself. | |
| </p><p>While parsing numbers is not very hard, it makes for slow and possibly glitchy programs. Most programs requiring number input reads it from the stack at program start. This is done with an interpreter that supports pre-populating the stack with values. Doing so with the fish.py interpreter looks like this: | |
| </p> | |
| <pre>$ ./fish.py --code "2*n;" --value 10 | |
| 20 | |
| </pre> | |
| <p>Output is a bit easier, as you have two instructions: <code>o</code> and <code>n</code>. They will pop a value and output it as a character and a number, respectively. The output is naturally written to stdout. | |
| </p> | |
| <h3><span class="mw-headline" id="Errors">Errors</span></h3> | |
| <p>The following events will cause an error in ><>: | |
| </p> | |
| <ul><li>Division by zero</li> | |
| <li>Reaching an invalid instruction</li> | |
| <li>Trying to pop or modify on the stack when it is empty or has too few values</li> | |
| <li>If the interpreter does not support arbitrary-precision numbers, an overflow results in an error</li></ul> | |
| <p>Although there are multiple reasons an error may occur, there is only one error message: <i>something smells fishy...</i> | |
| </p> | |
| <h2><span class="mw-headline" id="Instructions">Instructions</span></h2> | |
| <p>The following is merely a draft of the instructions in ><>, and is subject to change. | |
| </p> | |
| <h3><span class="mw-headline" id="Movement_and_execution">Movement and execution</span></h3> | |
| <table> | |
| <tbody><tr> | |
| <td width="50px"> <code>></code> <code><</code> <code>^</code> <code>v</code> | |
| </td> | |
| <td>Change the direction of the instruction pointer (right, left, up, down respectively) | |
| </td></tr> | |
| <tr> | |
| <td width="58px"> <code>/</code> <code>\</code> <code>|</code> <code>_</code> <code>#</code> | |
| </td> | |
| <td><a href="#Mirrors">Mirrors</a>; the IP will change direction depending on what direction it already has. | |
| </td></tr> | |
| <tr> | |
| <td width="50px"> <code>x</code> | |
| </td> | |
| <td>Random direction. | |
| </td></tr> | |
| <tr> | |
| <td width="50px"> <code>!</code> | |
| </td> | |
| <td>Trampoline - skip the following instruction. | |
| </td></tr> | |
| <tr> | |
| <td width="50px"> <code>?</code> | |
| </td> | |
| <td>Conditional trampoline - pop one value off the stack. The next instruction is only executed if the popped value is non-zero. | |
| </td></tr> | |
| <tr> | |
| <td width="50px"><code>.</code> | |
| </td> | |
| <td>Jump - pop <code>y</code> and <code>x</code> off the stack, and move the IP to <code>(x,y)</code> in the codebox. The current direction is retained. Note that you have to jump to the cell before the instructions you want to execute, as the IP will move one position next tick before executing. | |
| </td></tr> | |
| </tbody></table> | |
| <h3><span class="mw-headline" id="Literals_and_operators">Literals and operators</span></h3> | |
| <table> | |
| <tbody><tr> | |
| <td width="58px"> <code>0-9</code> <code>a-f</code> | |
| </td> | |
| <td>Push the corresponding value in base 16 onto the stack. | |
| </td></tr> | |
| <tr> | |
| <td width="58px"> <code>+</code> <code>-</code> <code>*</code> <code>,</code> <code>%</code> | |
| </td> | |
| <td>Addition, subtraction, multiplication, division and modulo, respectively. Pop <code>x</code> and <code>y</code> off the stack, and push <code>y</code> <i>operator</i> <code>x</code>. Division is float division (meaning <code>94,n;</code> outputs <code>2.25</code> and not <code>2</code>). Division by 0 raises an error. | |
| </td></tr> | |
| <tr> | |
| <td width="50px"> <code>=</code> | |
| </td> | |
| <td>Equals. Pop <code>x</code> and <code>y</code> off the stack, and push <code>1</code> if <code>y = x</code>, and <code>0</code> otherwise. | |
| </td></tr> | |
| <tr> | |
| <td width="50px"> <code>)</code> <code>(</code> | |
| </td> | |
| <td>Greater than and less than, respectively. Pop <code>x</code> and <code>y</code> off the stack, and push <code>1</code> if <code>y</code> <i>operator</i> <code>x</code>, and <code>0</code> otherwise. | |
| </td></tr> | |
| <tr> | |
| <td width="50px"> <code>'</code> <code>"</code> | |
| </td> | |
| <td>Single and double quote - enable string parsing. String parsing pushes every character found to the stack until it finds a closing quote. | |
| </td></tr> | |
| </tbody></table> | |
| <h3><span class="mw-headline" id="Stack_manipulation">Stack manipulation</span></h3> | |
| <table> | |
| <tbody><tr> | |
| <td width="50px"> <code>:</code> | |
| </td> | |
| <td>Duplicate the top value on the stack. | |
| </td></tr> | |
| <tr> | |
| <td width="50px"> <code>~</code> | |
| </td> | |
| <td>Remove the top value from the stack. | |
| </td></tr> | |
| <tr> | |
| <td width="50px"> <code>$</code> | |
| </td> | |
| <td>Swap the top two values on the stack | |
| </td></tr> | |
| <tr> | |
| <td width="50px"> <code>@</code> | |
| </td> | |
| <td>Swap the top three values on the stack, shifting them rightwards (e.g. if your stack is <code>1,2,3,4</code>, calling <code>@</code> results in <code>1,4,2,3</code>) | |
| </td></tr> | |
| <tr> | |
| <td width="50px"> <code>}</code> <code>{</code> | |
| </td> | |
| <td>Shift the entire stack to the right and left, respectively. (e.g. when having <code>1,2,3,4</code>, calling <code>}</code> results in <code>4,1,2,3</code> while <code>{</code> results in <code>2,3,4,1</code>) | |
| </td></tr> | |
| <tr> | |
| <td width="50px"> <code>r</code> | |
| </td> | |
| <td>Reverse the stack. | |
| </td></tr> | |
| <tr> | |
| <td width="50px"> <code>l</code> | |
| </td> | |
| <td>Push the length of the stack onto the stack. | |
| </td></tr> | |
| <tr> | |
| <td width="50px"> <code>[</code> | |
| </td> | |
| <td>Pop <code>x</code> off the stack and create a new stack, moving <code>x</code> values from the old stack onto the new one. See <a href="#Stacks">Stacks</a>. | |
| </td></tr> | |
| <tr> | |
| <td width="50px"> <code>]</code> | |
| </td> | |
| <td>Remove the current stack, moving its values to the top of the underlying stack. | |
| </td></tr> | |
| </tbody></table> | |
| <h3><span id="Input.2Foutput_2"></span><span class="mw-headline" id="Input/output_2">Input/output</span></h3> | |
| <p>See <a href="#Input/output">Input/output</a>. | |
| </p> | |
| <table> | |
| <tbody><tr> | |
| <td width="50px"> <code>o</code> <code>n</code> | |
| </td> | |
| <td>Pop and output as a character and a number, respectively. Output is written to stdout. | |
| </td></tr> | |
| <tr> | |
| <td width="50px"> <code>i</code> | |
| </td> | |
| <td>Read one character from stdin and push it to the stack. The character should not be shown when read from console. When no more input is available, <code>-1</code> is pushed. | |
| </td></tr> | |
| </tbody></table> | |
| <h3><span id="Reflection.2Fmiscellaneous"></span><span class="mw-headline" id="Reflection/miscellaneous">Reflection/miscellaneous</span></h3> | |
| <table> | |
| <tbody><tr> | |
| <td width="50px"> <code>&</code> | |
| </td> | |
| <td>Pop the top value off the stack and put it in the <i>register</i>. Calling <code>&</code> again will take the value in the register and put it back on the stack. See <a href="#The_register">The register</a>. | |
| </td></tr> | |
| <tr> | |
| <td width="50px"> <code>g</code> | |
| </td> | |
| <td>Pop <code>y</code> and <code>x</code> off the stack, and push the value at <code>x,y</code> in the codebox. Empty cells are equal to <code>0</code>. | |
| </td></tr> | |
| <tr> | |
| <td width="50px"> <code>p</code> | |
| </td> | |
| <td>Pop <code>y</code>, <code>x</code>, and <code>v</code> off the stack, and change the value at <code>x,y</code> to <code>v</code>. E.g. <code>123p</code> puts <code>1</code> at <code>2,3</code> in the codebox. | |
| </td></tr> | |
| <tr> | |
| <td width="50px"> <code>;</code> | |
| </td> | |
| <td>End execution. | |
| </td></tr> | |
| </tbody></table> | |
| <p>The space character is simply a <a href="/wiki/Nop" title="Nop">NOP</a> and is allowed anywhere. | |
| </p> | |
| <h2><span class="mw-headline" id="Examples">Examples</span></h2> | |
| <p>All the examples are executed using the fish.py interpreter. | |
| </p> | |
| <h3><span id="Hello.2C_world.21"></span><span class="mw-headline" id="Hello,_world!"><a href="/wiki/Hello,_world!" title="Hello, world!">Hello, world!</a></span></h3> | |
| <p>A program that prints "Hello, world!". By <a href="/wiki/User:MihaiEso" title="User:MihaiEso">User:MihaiEso</a> | |
| </p> | |
| <pre>>"Hello, world!"0r>o:?v; | |
| ^ < | |
| </pre> | |
| <p>Smallest possible version. By <a href="/wiki/User:BrainFuckGirl" title="User:BrainFuckGirl">User:BrainFuckGirl</a> | |
| </p> | |
| <pre>"!dlrow ,olleH"l?!;oe0. | |
| </pre> | |
| <p>An example without string parsing, using only the math instructions. By <a href="/wiki/User:MihaiEso" title="User:MihaiEso">User:MihaiEso</a>, golfed by <a href="/wiki/User:BrainFuckGirl" title="User:BrainFuckGirl">User:BrainFuckGirl</a> | |
| </p> | |
| <pre>98*oaa*1+o9c*o9c*oba*\ | |
| 1+ob4*o84*of2+7*oba*1\ | |
| +of4+6*oc9*oaa*ob3*o;\ | |
| </pre> | |
| <p>Another version without string parsing. By <a href="/wiki/User:BrainFuckGirl" title="User:BrainFuckGirl">User:BrainFuckGirl</a> | |
| </p> | |
| <pre>98*ob3*aa*:1+o9c*:\ | |
| o;!*4b*48+8o::-3:+\!6o:|ooo | |
| </pre> | |
| <h3><span class="mw-headline" id="Cat_Program"><a class="mw-redirect" href="/wiki/Cat_Program" title="Cat Program">Cat Program</a></span></h3> | |
| <p>A cat program by <a href="/wiki/User:Ractangle" title="User:Ractangle">User:Ractangle</a> and <a href="/wiki/User:BrainFuckGirl" title="User:BrainFuckGirl">User:BrainFuckGirl</a>, requiring pre-populating the stack with values: | |
| </p> | |
| <pre>0rv o< | |
| >:?^; | |
| </pre> | |
| <p>Alternative version by <a href="/wiki/User:Ractangle" title="User:Ractangle">User:Ractangle</a>, reading from stdin: | |
| </p> | |
| <pre>>i:1+?v; | |
| ^ o< | |
| </pre> | |
| <p>A tiny cat program reading from stdin. Made by <a href="/wiki/User:BrainFuckGirl" title="User:BrainFuckGirl">User:BrainFuckGirl</a> | |
| </p> | |
| <pre>i:0(?;o | |
| </pre> | |
| <h3><span class="mw-headline" id="FizzBuzz"><a href="/wiki/FizzBuzz" title="FizzBuzz">FizzBuzz</a></span></h3> | |
| <pre>0voa ~/?=0:\ | |
| voa oooo'Buzz'~< / | |
| >1+:aa*1+=?;::5%:{3%:@*?\?/'zziF'oooo/ | |
| ^oa n:~~/ | |
| </pre> | |
| <p>This outputs: | |
| </p> | |
| <pre>1 | |
| 2 | |
| Fizz | |
| ... | |
| 98 | |
| Fizz | |
| Buzz | |
| </pre> | |
| <h3><span class="mw-headline" id="Fibonacci_sequence"><a href="/wiki/Fibonacci_sequence" title="Fibonacci sequence">Fibonacci sequence</a></span></h3> | |
| <pre>10::n' 'o&+&$10. | |
| </pre> | |
| <p>This outputs the <a href="/wiki/Fibonacci_sequence" title="Fibonacci sequence">Fibonacci</a> numbers until stopped: | |
| </p> | |
| <pre>0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 ... | |
| </pre> | |
| <p>(When using fish.py, you can use the <code>-t 0.01</code> flag to slow down execution, to avoid being spammed with the endless Fibonacci sequence) | |
| </p> | |
| <h3><span class="mw-headline" id="Lucas_sequence">Lucas sequence</span></h3> | |
| <pre>2n' 'ol?/21>::! | |
| $&+&\ / | |
| </pre> | |
| <p>This outputs the Lucas numbers until stopped: | |
| </p> | |
| <pre>2 1 3 4 7 11 18 29 47 76 123 199 322 521 843 1364 2207 3571 5778 ... | |
| </pre> | |
| <h3><span class="mw-headline" id="Factorial"><a href="/wiki/Factorial" title="Factorial">Factorial</a></span></h3> | |
| <p>Calculates the factorial of the input number. Assumes the input is a non-negative integer. You need to pre-populate the stack with the input. | |
| </p> | |
| <pre> :?\~11>*l1\ | |
| -1:/ ;n\?- / | |
| </pre> | |
| <p>With an input of 10, this outputs: | |
| </p> | |
| <pre>3628800 | |
| </pre> | |
| <h3><span class="mw-headline" id="Quine"><a href="/wiki/Quine" title="Quine">Quine</a></span></h3> | |
| <p>Outputs its own source code. | |
| </p> | |
| <pre>"r00gol?!;40. | |
| </pre> | |
| <p>This outputs: | |
| </p> | |
| <pre>"r00gol?!;40. | |
| </pre> | |
| <p>Another one, but this one is multi-line. | |
| </p> | |
| <pre>0>:a$f8+$p1+:5-?vv | |
| ^ <>~0v | |
| v < < | |
| >0v ;^?-6:+1~< | |
| v < < | |
| >$:{:}$go$ 1+:f9+-?^^ | |
| </pre> | |
| <h3><span class="mw-headline" id="Square_root">Square root</span></h3> | |
| <p>Calculates and outputs the square root of the input number (requires pre-populating the stack). | |
| </p> | |
| <pre>>:>:r:@@:@,\; | |
| ~$\!?={:,2+/n | |
| </pre> | |
| <p>With an input of 64, this outputs: | |
| </p> | |
| <pre>8 | |
| </pre> | |
| <h3><span class="mw-headline" id="Brainfuck_interpreter"><a href="/wiki/Brainfuck" title="Brainfuck">Brainfuck</a> interpreter</span></h3> | |
| <p>Program and input seperated by <code>!</code>. | |
| </p> | |
| <pre>v | |
| 1 | |
| 0 | |
| >$ >$ \ | |
| >:@$:@i:0(?^$:2=?^$:3b*-0=?\v/ >:&$:1=?v>$@p&0(?v$1+ | |
| \ 02]p00~~<> :'+'=?^\ $$ >1-0p | |
| \01-\ /^?='>': < d+ | |
| v <} v?= \ > :'<'=?^\ %e | |
| v}]p$p4r}:r:$4[2@:/f1+/ /^?='-': < \/ | |
| >{1+:00g=?\:1g:e-?^~:}0a. > :'['=?^\ | |
| / -1-:/ /^?=']': < | |
| >1+:00g=?;:1g0$. > :'.'=?^\ | |
| ^ ~< $\.51$~~ ~^?=',': < | |
| '['~ 20g:3g ?^>$4g^ | |
| ']'~ 20g:3g0=?^^ | |
| ^ < \ | |
| '+'~ 20g:3g1+3$@p^ | |
| ','~ 30g:1+30p2g 20g3p/ | |
| '-'~ 20g:3g1-3$@p^ | |
| '.'~ 20g3go / | |
| '<'~ 20g1-20p\ | |
| ^ < | |
| '>'~ 20g1+20p/ | |
| </pre> | |
| <pre>echo '++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.' | ./fish.py brainfuck.fish | |
| Hello World! | |
| </pre> | |
| <pre>echo '-,+[-[>>++++[>++++++++<-]<+<-[>+>+>-[>>>]<[[>+<-]>>+>]<<<<<-]]>>>[-]+>--[-[<->+++[-]]]<[++++++++++++<[>-[>+>>]>[+[<+>-]>+>>]<<<<<-]>>[<+>-]>[-[-<<[-]>>]<<[<<->>-]>>]<<[<<+>>-]]<[-]<.[-]<-,+]!Esolangs' | ./fish.py brainfuck.fish | |
| Rfbynatf | |
| </pre> | |
| <h3><span class="mw-headline" id="Basic_calculator">Basic calculator</span></h3> | |
| <p>Can only add, subtract, multiply and divide. Input structure goes like: "{int}{operator}{int}=" and in char mode. | |
| </p> | |
| <pre>01-2.;;;>?!vc4*-{a*+}!;v~;n; | |
| ;v~~:~:<~|.!~,+a<bc6-10<;;;; | |
| i :1+?!^!;:~:~:~:~:~:~:~:~:~ | |
| v>r!;:~>:~!v!;!;!;!;!;!;!;!; | |
| \0}0&:~!!>!|474159+,-,*~!;!; | |
| v!~:)-10\*@|!@-1=+1*a6:$;!;! | |
| >:c4*-!;^;;>&:?v~&:~>>0}!;!; | |
| v<;!;!~:~:&$&~$<;;;;;;;;;n;; | |
| >5:*0p64*0.;;;;;;;;;;;;;;,;; | |
| </pre> | |
| <p>With an input "652*4523=" it outputs: | |
| </p> | |
| <pre>2948996 | |
| </pre> | |
| <p>Note: division is '/' or ',' as the program handles the slash. | |
| </p> | |
| <h2><span class="mw-headline" id="Interpreters">Interpreters</span></h2> | |
| <h3><span class="mw-headline" id="fish.py">fish.py</span></h3> | |
| <p>The "official" interpreter, or the one written by the author. The latest version is available <a class="external text" href="https://gist.github.com/anonymous/6392418" rel="nofollow">here.</a> Requires python versions 2.7 or 3.2 or later. For usage information, run it with the --help switch. | |
| </p> | |
| <h3><span class="mw-headline" id="fishlanguage">fishlanguage</span></h3> | |
| <p>An <a class="external text" href="https://suppen.no/fishlanguage/" rel="nofollow">online interpreter</a>, written in TypeScript. Features animation of the instruction pointer moving through the program, configurable execution speed, and display of stack contents. (Formerly found at <a class="external text" href="https://web.archive.org/web/20210307003039/https://fishlanguage.com/" rel="nofollow">fishlanguage.com</a>.) | |
| </p> | |
| <h3><span id="Mousetail.27s_Fish_Interpreter"></span><span class="mw-headline" id="Mousetail's_Fish_Interpreter">Mousetail's Fish Interpreter</span></h3> | |
| <p>Another <a class="external text" href="https://mousetail.github.io/Fish/" rel="nofollow">online interpreter</a> in Typescript. Able to create sharable links, pause execution, and see the state of multiple stacks at the same time. Inputs do not reset when repeatedly testing a program. | |
| </p> | |
| <h3><span class="mw-headline" id="go-fish">go-fish</span></h3> | |
| <p>An interpreter written by <a class="external text" href="https://github.com/redstarcoder" rel="nofollow">redstarcoder</a>. It follows the same behaviour as the fish.py interpreter, but can also follow the fishlanguage.com behaviour with "-m" set. <a class="external text" href="https://github.com/redstarcoder/go-fish" rel="nofollow">Download at GitHub.</a> | |
| </p> | |
| <h3><span class="mw-headline" id="fish.java">fish.java</span></h3> | |
| <p>An interpreter written by <a href="/wiki/User:Cxarli" title="User:Cxarli">User:Cxarli</a>. It has the same console arguments as the "official" interpreter. <a class="external text" href="https://github.com/Cxarli/Fish-Interpreter" rel="nofollow">Get the source from GitHub here.</a> <i>(<a href="/wiki/Template:Deadlink" title="Template:Deadlink">dead link</a>)</i> | |
| </p> | |
| <h3><span class="mw-headline" id="fishr">fishr</span></h3> | |
| <p>An interpreter written in Rust, by <a class="external text" href="https://github.com/noirotm" rel="nofollow">Marc Noirot</a>. It has roughly the same console arguments as the "official" interpreter. <a class="external text" href="https://github.com/noirotm/fishr" rel="nofollow">Get the source from GitHub here.</a> | |
| </p> | |
| <h3><span class="mw-headline" id="fish-jit">fish-jit</span></h3> | |
| <p>A just-in-time compiling interpreter, written in RPython. Stack values are stored as arbitrary precision fractions, and converted to float only when displaying. <a class="external text" href="https://github.com/primo-ppcg/fish-jit" rel="nofollow">Get the source from GitHub here.</a> | |
| </p> | |
| <h3><span class="mw-headline" id="Older_interpreters">Older interpreters</span></h3> | |
| <p>The following interpreters were written towards an older version of ><> that featured multithreading. The multithreading capabilities were removed and replaced with multiple stacks support, which was deemed more useful (not that esoteric languages are useful in the first place). These interpreters may not work with some updated instructions, like <code>p</code>, <code>[</code> and <code>]</code>. You can of course still use these interpreters using <a class="external text" href="http://esolangs.org/w/index.php?title=Fish&oldid=22153" rel="nofollow">the old documentation.</a> | |
| </p> | |
| <h5><span class="mw-headline" id="Python">Python</span></h5> | |
| <p>The old version of the official python interpreter is available through <a class="external text" href="https://gist.github.com/827726/04f88e5c46b6856413ad2c1859356c21c4511d4d" rel="nofollow">Gist.</a> <i>(<a href="/wiki/Template:Deadlink" title="Template:Deadlink">dead link</a>)</i> | |
| </p><p>Invoke it by first making sure you have installed python, and typing <code>python fish.py <script> [tick]</code> into your system's command line. Script is replaced with a .fish file, and tick is optional and defines a delay in seconds between each instruction, to slow down execution for debugging etc. It should work with both python 2.x and 3.x, as well as both Windows, Linux and Mac. | |
| </p> | |
| <h5><span class="mw-headline" id="Delphi">Delphi</span></h5> | |
| <p>Another interpreter, written in Delphi, is a result of a so-called 'code-golf challenge'. It interprets every instruction (except the threading related instructions) in about 1290 characters of source code. (A version with threading support is also available on the same site.) | |
| <a class="external text" href="http://codegolf.stackexchange.com/questions/1595/interpret-fish/1637#1637" rel="nofollow">Get it here!</a> | |
| </p><p>Compile the code into a console application with any Unicode-enabled version of Delphi (a port to the FreePascalCompiler FPC is trivial). Invoke the resulting executable and supply the path to a .fish file on the command line. Speed can be limited by increasing the Sleep() time in the code. | |
| </p> | |
| <h3><span class="mw-headline" id="More">More</span></h3> | |
| <p>There are several interpreters in a multitude of languages available in the StackExchange code-golf <a class="external text" href="http://codegolf.stackexchange.com/questions/1595/interpret-fish/" rel="nofollow">challenge.</a> | |
| </p> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20260118111028 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.038 seconds | |
| Real time usage: 0.040 seconds | |
| Preprocessor visited node count: 162/1000000 | |
| Post‐expand include size: 266/2097152 bytes | |
| Template argument size: 7/2097152 bytes | |
| Highest expansion depth: 5/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 4.223 1 -total | |
| 61.14% 2.582 1 Template:Wrongtitle | |
| 14.54% 0.614 1 Template:Distinguish/Confusion | |
| 11.72% 0.495 2 Template:Deadlink | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:3441-0!canonical and timestamp 20260118111029 and revision id 173764. Rendering was triggered because: edit-page | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b>A0A0</b> is a <a href="/wiki/Category:Queue-based" title="Category:Queue-based">queue-based</a>, <a href="/wiki/Category:Self-modifying" title="Category:Self-modifying">self-modifying</a> programming language created by <a href="/wiki/User:Snowyowl" title="User:Snowyowl">User:Snowyowl</a> in <a href="/wiki/Category:2013" title="Category:2013">2013</a>. | |
| </p><p>It is named after a commonly used pair of commands. When the name is read aloud, it should ideally be sung in a major third. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Language_overview"><span class="tocnumber">1</span> <span class="toctext">Language overview</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Sample_Programs"><span class="tocnumber">2</span> <span class="toctext">Sample Programs</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-3"><a href='#"Hello,_world!"'><span class="tocnumber">2.1</span> <span class="toctext">"Hello, world!"</span></a></li> | |
| <li class="toclevel-2 tocsection-4"><a href="#cat"><span class="tocnumber">2.2</span> <span class="toctext">cat</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-5"><a href="#Implementations"><span class="tocnumber">3</span> <span class="toctext">Implementations</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Language_overview">Language overview</span></h2> | |
| <p>Each line of code in the source of an A0A0 program represents a queue of commands. Commands consist of a single letter and a signed integer, which is the argument for that command and also the only datatype. | |
| To interpret a command, the interpreter works in the following order: | |
| </p> | |
| <ol><li>Pop one command from the current line.</li> | |
| <li>Execute that command.</li> | |
| <li>If the command was not a <code>G</code> (goto) command, go to the next line.</li></ol> | |
| <p>(Note: this might be obvious, but given that several commands can alter the content of the current line, it's important to be specific.) | |
| </p><p>Any unrecognised commands have no effect (it should be assumed that they are reserved for future use even when they aren't). Spaces and tabs are ignored, but newlines are not. | |
| </p><p>For any signed integer <i>n</i>, the commands that take <i>n</i> as an argument are: | |
| </p> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <td colspan="2"><b>Control</b> | |
| </td></tr> | |
| <tr> | |
| <td>A<i>n</i> | |
| </td> | |
| <td>Appends a copy of the entire current line to the line <i>n</i> lines below it. | |
| </td></tr> | |
| <tr> | |
| <td>C<i>n</i> | |
| </td> | |
| <td>Clears all commands from the line <i>n</i> below the current line. | |
| </td></tr> | |
| <tr> | |
| <td>G<i>n</i> | |
| </td> | |
| <td>Goto the line <i>n</i> below this one, instead of continuing automatically to the next line. <code>G1</code> has no net effect and can be used as a no-op. | |
| </td></tr> | |
| <tr> | |
| <td>V<i>n</i> | |
| </td> | |
| <td>Sets the argument of the next command on the current line to <i>n</i>. Note that the value of <i>n</i> is linked to the operand; its initial value will only take effect if no operand exists when executing the command. | |
| </td></tr> | |
| <tr> | |
| <td colspan="2"><b>Operations</b> | |
| <p>All operations change the value of the <i>operand</i>. The operand is the argument of the first <code>V</code> instruction on the current line. If there is no operand, these commands do nothing. | |
| </p> | |
| </td></tr> | |
| <tr> | |
| <td>S<i>n</i> | |
| </td> | |
| <td>Adds <i>n</i> to the operand. | |
| </td></tr> | |
| <tr> | |
| <td>D<i>n</i> | |
| </td> | |
| <td>Subtracts <i>n</i> from the operand. | |
| </td></tr> | |
| <tr> | |
| <td>M<i>n</i> | |
| </td> | |
| <td>Multiplies the the operand by <i>n</i>. | |
| </td></tr> | |
| <tr> | |
| <td>L<i>n</i> | |
| </td> | |
| <td>Sets the operand to 1 if it is larger than <i>n</i>, -1 if it is smaller, and 0 if it is equal to <i>n</i>. | |
| </td></tr> | |
| <tr> | |
| <td colspan="2"><b>I/O</b> | |
| </td></tr> | |
| <tr> | |
| <td>I<i>n</i> | |
| </td> | |
| <td>Reads an integer from standard input and sets the operand to it. | |
| <p>If <i>n</i> is 0, reads an integer in base 10. If <i>n</i> is 1, reads a single character and returns its ASCII value. Any other arguments produce undefined behaviour. | |
| </p> | |
| </td></tr> | |
| <tr> | |
| <td>O<i>n</i> | |
| </td> | |
| <td>Writes the value of <i>n</i> to standard output as a base-10 integer. | |
| </td></tr> | |
| <tr> | |
| <td>P<i>n</i> | |
| </td> | |
| <td>Writes the ASCII character corresponding to <i>n</i> mod 256 to standard output. | |
| </td></tr></tbody></table> | |
| <p>The initial program code is padded in both directions by an infinite number of empty lines. Whenever the program encounters an empty line, it immediately terminates. (Hence the practicality of "padding lines", that do nothing useful but also do not cause the program to terminate.) | |
| </p><p>Execution starts at the first line by default; however, if any line starts with a <code>></code> symbol, execution starts at that line instead. (This allows debuggers to output the program state formatted as A0A0 source code.) | |
| </p> | |
| <h2><span class="mw-headline" id="Sample_Programs">Sample Programs</span></h2> | |
| <h3><span id=".22Hello.2C_world.21.22"></span><span class="mw-headline" id='"Hello,_world!"'>"<a href="/wiki/Hello,_world!" title="Hello, world!">Hello, world!</a>"</span></h3> | |
| <pre>P72 | |
| P101 | |
| P108 | |
| P108 | |
| P111 | |
| P44 | |
| P32 | |
| P119 | |
| P111 | |
| P114 | |
| P108 | |
| P100 | |
| P33 | |
| </pre> | |
| <h3><span class="mw-headline" id="cat"><a class="mw-redirect" href="/wiki/Cat" title="Cat">cat</a></span></h3> | |
| <pre>A0 A0 | |
| A0 C3 G1 G1 A0 | |
| A0 I1 V0 P0 A0 | |
| A0 A1 G-3 G-3 A0 | |
| G-3 | |
| </pre> | |
| <p>This program shows one way of creating a loop in A0A0. Only the third line deals with input and output; the rest of the program serves to form a loop. | |
| </p> | |
| <h2><span class="mw-headline" id="Implementations">Implementations</span></h2> | |
| <ul><li><a class="external text" href="https://gist.github.com/dc6914d587bed8fa8d5e" rel="nofollow">Ruby interpreter</a> by <a class="new" href="/w/index.php?title=User:Andkerosine&action=edit&redlink=1" title="User:Andkerosine (page does not exist)">User:Andkerosine</a></li> | |
| <li><a class="external text" href="https://gist.github.com/KotlinIsCool/4f20440329ccff930b5f21668dd27795" rel="nofollow">Java interpreter</a> <i>(<a href="/wiki/Template:Deadlink" title="Template:Deadlink">dead link</a>)</i> by KotlinIsCool</li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20251213175140 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.012 seconds | |
| Real time usage: 0.013 seconds | |
| Preprocessor visited node count: 21/1000000 | |
| Post‐expand include size: 37/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.885 1 Template:Deadlink | |
| 100.00% 0.885 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:8732-0!canonical and timestamp 20251213175140 and revision id 170579. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p>Aardvark is a language created by <a class="new" href="/w/index.php?title=DanielDG&action=edit&redlink=1" title="DanielDG (page does not exist)">DanielDG</a> to abuse the <i>async/await</i> syntax. The only datatype in Aardvark is asynchronous <i>tasks</i> (a.k.a. <i>futures</i> or <i>promises</i>), and the only type of control flow is <i>async/await</i>. Despite that, Aardvark is <a class="mw-redirect" href="/wiki/Turing_complete" title="Turing complete">Turing complete</a>. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Asynchronous_functions"><span class="tocnumber">1</span> <span class="toctext">Asynchronous functions</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Syntax"><span class="tocnumber">2</span> <span class="toctext">Syntax</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-3"><a href="#Functions"><span class="tocnumber">2.1</span> <span class="toctext">Functions</span></a></li> | |
| <li class="toclevel-2 tocsection-4"><a href="#Await_operator"><span class="tocnumber">2.2</span> <span class="toctext">Await operator</span></a></li> | |
| <li class="toclevel-2 tocsection-5"><a href="#Output"><span class="tocnumber">2.3</span> <span class="toctext">Output</span></a></li> | |
| <li class="toclevel-2 tocsection-6"><a href="#Variables"><span class="tocnumber">2.4</span> <span class="toctext">Variables</span></a></li> | |
| <li class="toclevel-2 tocsection-7"><a href="#Comments"><span class="tocnumber">2.5</span> <span class="toctext">Comments</span></a></li> | |
| <li class="toclevel-2 tocsection-8"><a href="#Grammar"><span class="tocnumber">2.6</span> <span class="toctext">Grammar</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-9"><a href="#Builtin_Functions"><span class="tocnumber">3</span> <span class="toctext">Builtin Functions</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-10"><a href="#void()"><span class="tocnumber">3.1</span> <span class="toctext">void()</span></a></li> | |
| <li class="toclevel-2 tocsection-11"><a href="#ready(task,_default)"><span class="tocnumber">3.2</span> <span class="toctext">ready(task, default)</span></a></li> | |
| <li class="toclevel-2 tocsection-12"><a href="#poll(task,_default)"><span class="tocnumber">3.3</span> <span class="toctext">poll(task, default)</span></a></li> | |
| <li class="toclevel-2 tocsection-13"><a href="#yield()"><span class="tocnumber">3.4</span> <span class="toctext">yield()</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-14"><a href="#Examples"><span class="tocnumber">4</span> <span class="toctext">Examples</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-15"><a href="#Hello,_World!"><span class="tocnumber">4.1</span> <span class="toctext">Hello, World!</span></a></li> | |
| <li class="toclevel-2 tocsection-16"><a href="#Infinite_loop"><span class="tocnumber">4.2</span> <span class="toctext">Infinite loop</span></a></li> | |
| <li class="toclevel-2 tocsection-17"><a href="#Infinite_triangle"><span class="tocnumber">4.3</span> <span class="toctext">Infinite triangle</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-18"><a href="#Computational_class"><span class="tocnumber">5</span> <span class="toctext">Computational class</span></a></li> | |
| <li class="toclevel-1 tocsection-19"><a href="#External_resources"><span class="tocnumber">6</span> <span class="toctext">External resources</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Asynchronous_functions">Asynchronous functions</span></h2> | |
| <p>Asynchronous functions and <i>async/await</i> are very common features of modern programming languages. If you are unfamiliar with asynchronous functions, you should probably read about them in some other language, like Python, JavaScript, or C#, before learning Aardvark. But in a nutshell, asynchronous functions are <i>pausable</i> functions. A regular function runs until reaching a return statement and then exits. An asynchronous function can also choose to pause itself, saving its current state and returning to the caller, who can then decide whether to resume it or not. | |
| </p> | |
| <h2><span class="mw-headline" id="Syntax">Syntax</span></h2> | |
| <p>Aardvark's syntax is similar to C. | |
| </p> | |
| <h3><span class="mw-headline" id="Functions">Functions</span></h3> | |
| <pre>async functionName(param1, param2, ...) { code } | |
| </pre> | |
| <p>Defines an asynchronous function. Each program contains a function called <i>main</i>, which is its entry point. | |
| </p> | |
| <pre>return someValue | |
| </pre> | |
| <p>Returns from a function. | |
| </p> | |
| <pre>functionName(arg1, arg2, ...) | |
| </pre> | |
| <p>Calls a function. Since Aardvark's functions are asynchronous, they don't actually run when you call them. Instead, they return a <i>task</i> object, which you have to <i>await</i> in order to run. | |
| </p> | |
| <h3><span class="mw-headline" id="Await_operator">Await operator</span></h3> | |
| <pre>await someTask | |
| </pre> | |
| <p>Runs a task to completion and returns its result. If the <i>await</i>ed task pauses itself, the current task also pauses (as well as any task awaiting it). Once the current task resumes, it immediately resumes the <i>await</i>ed task.<br/> | |
| If you await the same task twice, it will run only the first time and return the same result immediately the second time. | |
| </p> | |
| <h3><span class="mw-headline" id="Output">Output</span></h3> | |
| <pre>print "Print with no newline." | |
| println "Print with a newline." | |
| </pre> | |
| <p>Prints a string. Note that <i>print</i> and <i>println</i> have to be followed by a string literal. | |
| </p> | |
| <h3><span class="mw-headline" id="Variables">Variables</span></h3> | |
| <pre>variableName = value | |
| </pre> | |
| <p>Sets a local variable. | |
| </p> | |
| <h3><span class="mw-headline" id="Comments">Comments</span></h3> | |
| <pre>// This is a comment. | |
| /* This is also a comment. */ | |
| </pre> | |
| <h3><span class="mw-headline" id="Grammar">Grammar</span></h3> | |
| <p>Here's the whole grammar of Aardvark in EBNF. In case this grammar is ambiguous, Aardvark uses a "greedy" parser. | |
| </p> | |
| <pre>program = ws {function ws} | |
| function = 'async' ws ident ws '(' ws {ident ws ',' ws} [ident ws] ')' ws '{' ws {statement ws} '}' | |
| statement = expression | ident ws '=' ws expression | 'return' ws expression | 'print' ws string | 'println' ws string | |
| expression = ident | '(' ws expression ws ')' | 'await' ws expression | ident ws '(' ws {expression ws ',' ws} [expression ws] ')' | |
| ident = (alphabetic_char | '_') {alphanumeric_char | '_'} | |
| string = '"' {char_except('"', '\\') | '\\n' | '\\"' | '\\\\' } '"' | |
| ws = {whitespace_char | newline | '//' {char} newline | '/*' {char} '*/'} | |
| </pre> | |
| <h2><span class="mw-headline" id="Builtin_Functions">Builtin Functions</span></h2> | |
| <p>Aardvark has four builtin functions. Like all other functions, they are asynchronous, so you have to use the <i>await</i> operator to run them. The following list describes what they do when awaited. | |
| </p> | |
| <h3><span id="void.28.29"></span><span class="mw-headline" id="void()">void()</span></h3> | |
| <p>Does nothing and returns another void() task. void() is also what functions with no <i>return</i> statement return. | |
| </p> | |
| <h3><span id="ready.28task.2C_default.29"></span><span class="mw-headline" id="ready(task,_default)">ready(task, default)</span></h3> | |
| <p>Checks if <i>task</i> has already completed. If it has, returns its result; otherwise, returns <i>default</i>. | |
| </p> | |
| <h3><span id="poll.28task.2C_default.29"></span><span class="mw-headline" id="poll(task,_default)">poll(task, default)</span></h3> | |
| <p>A more powerful version of ready(). If <i>task</i> has already completed, returns its result; otherwise, tries to run it. If <i>task</i> returns, poll() returns its result; if <i>task</i> pauses, poll() doesn't try to run it further and returns <i>default</i> instead. | |
| </p> | |
| <h3><span id="yield.28.29"></span><span class="mw-headline" id="yield()">yield()</span></h3> | |
| <p>Pauses once, and then (when resumed) returns void(). Because of how the <i>await</i> operator works, any function that awaits yield() pauses, too. Currently, this is the only way to pause a function. | |
| </p> | |
| <h2><span class="mw-headline" id="Examples">Examples</span></h2> | |
| <h3><span id="Hello.2C_World.21"></span><span class="mw-headline" id="Hello,_World!">Hello, World!</span></h3> | |
| <pre>async main() { | |
| println "Hello, World!" | |
| } | |
| </pre> | |
| <h3><span class="mw-headline" id="Infinite_loop">Infinite loop</span></h3> | |
| <pre>async main() { | |
| await main() | |
| } | |
| </pre> | |
| <h3><span class="mw-headline" id="Infinite_triangle">Infinite triangle</span></h3> | |
| <pre>// Prints a line of asterisks. | |
| // Accepts an asterisk-printing task: either line() or void() (which prints 0 asterisks). | |
| // Prints as many asterisks as that task, plus one. | |
| // Returns a copy of itself. | |
| async line(ln) { | |
| print "*" | |
| return line(await ln) | |
| } | |
| // Prints an infinite triangle, given a task that prints the first line. | |
| async triangle(ln) { | |
| await ln | |
| println "" | |
| await triangle(line(await ln)) | |
| } | |
| // Prints an infinite triangle. | |
| async main() { | |
| await triangle(line(void())) | |
| } | |
| </pre> | |
| <p>Outputs: | |
| </p> | |
| <pre>* | |
| ** | |
| *** | |
| **** | |
| ***** | |
| (...) | |
| </pre> | |
| <h2><span class="mw-headline" id="Computational_class">Computational class</span></h2> | |
| <p>Aardvark is Turing-complete since it can simulate Rule 124 (<a class="external text" href="https://en.wikipedia.org/wiki/Rule_110" rel="nofollow">Rule 110</a> backward), which is known to be Turing-complete. | |
| </p> | |
| <h2><span class="mw-headline" id="External_resources">External resources</span></h2> | |
| <ul><li><a class="external text" href="https://github.com/LordHavelockVetinari/aardvark" rel="nofollow">An Interpreter</a>, including some examples and a Rule 124 simulator.</li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20250723225312 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.016 seconds | |
| Real time usage: 0.017 seconds | |
| Preprocessor visited node count: 59/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:16370-0!canonical and timestamp 20250723225312 and revision id 107243. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b>Argh!</b> and its successor <b>Aargh!</b>, both invented by <a class="new" href="/w/index.php?title=Sascha_Wilde&action=edit&redlink=1" title="Sascha Wilde (page does not exist)">Sascha Wilde</a>, are <a href="/wiki/Befunge" title="Befunge">Befunge</a>-like <a href="/wiki/Esoteric_programming_language" title="Esoteric programming language">esoteric programming languages</a>, laid out in two dimensions. Each is limited to 80 columns wide, but Aargh! has an unlimited number of rows, whereas Argh! is limited to 40. The idea was to make sure Aargh! was <a href="/wiki/Turing-complete" title="Turing-complete">Turing-complete</a>. | |
| </p><p>Each character of the grid is either a one-cell wide command or value. The language also supports a stack of unbounded size. It has 27 documented commands. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Instructions"><span class="tocnumber">1</span> <span class="toctext">Instructions</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Examples"><span class="tocnumber">2</span> <span class="toctext">Examples</span></a></li> | |
| <li class="toclevel-1 tocsection-3"><a href="#Computational_class"><span class="tocnumber">3</span> <span class="toctext">Computational class</span></a></li> | |
| <li class="toclevel-1 tocsection-4"><a href="#External_resources"><span class="tocnumber">4</span> <span class="toctext">External resources</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Instructions">Instructions</span></h2> | |
| <p>Argh! has the following commands: | |
| </p> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <th>Letter | |
| </th> | |
| <th><a href="/wiki/Befunge" title="Befunge">Befunge</a> equivalent | |
| </th> | |
| <th>Description | |
| </th></tr> | |
| <tr> | |
| <td>A</td> | |
| <td></td> | |
| <td>add value of the cell above the current cell to the value on top of the stack (see "R") | |
| </td></tr> | |
| <tr> | |
| <td>a</td> | |
| <td></td> | |
| <td>add value of the cell below the current cell to the value on top of the stack | |
| </td></tr> | |
| <tr> | |
| <td>D</td> | |
| <td></td> | |
| <td>delete top value off stack | |
| </td></tr> | |
| <tr> | |
| <td>d</td> | |
| <td><code>:</code></td> | |
| <td>duplicate top value on stack | |
| </td></tr> | |
| <tr> | |
| <td>E</td> | |
| <td></td> | |
| <td>insert value of system EOF in cell above | |
| </td></tr> | |
| <tr> | |
| <td>e</td> | |
| <td></td> | |
| <td>insert value of system EOF in cell below | |
| </td></tr> | |
| <tr> | |
| <td>F</td> | |
| <td></td> | |
| <td>fetch (pop) value from top of stack and store to cell above | |
| </td></tr> | |
| <tr> | |
| <td>f</td> | |
| <td></td> | |
| <td>fetch (pop) value from top of stack and store to cell below | |
| </td></tr> | |
| <tr> | |
| <td>G</td> | |
| <td></td> | |
| <td>get one byte from stdin and store in cell above | |
| </td></tr> | |
| <tr> | |
| <td>g</td> | |
| <td></td> | |
| <td>get one byte from stdin and store in cell below | |
| </td></tr> | |
| <tr> | |
| <td>H</td> | |
| <td></td> | |
| <td>jump (move instruction pointer) left to the next cell whose value matches the value on top of the stack, and set execution direction to "left" | |
| </td></tr> | |
| <tr> | |
| <td>h</td> | |
| <td><code><</code></td> | |
| <td>set execution direction to "left" | |
| </td></tr> | |
| <tr> | |
| <td>J</td> | |
| <td></td> | |
| <td>jump down to the next cell whose value matches the value on top of the stack, and set execution direction to "down" | |
| </td></tr> | |
| <tr> | |
| <td>j</td> | |
| <td><code>v</code></td> | |
| <td>set execution direction to "down" | |
| </td></tr> | |
| <tr> | |
| <td>K</td> | |
| <td></td> | |
| <td>jump up to the next cell whose value matches the value on top of the stack, and set execution direction to "up" | |
| </td></tr> | |
| <tr> | |
| <td>k</td> | |
| <td><code>^</code></td> | |
| <td>set execution direction to "up" | |
| </td></tr> | |
| <tr> | |
| <td>L</td> | |
| <td></td> | |
| <td>jump right to the next cell whose value matches the value on top of the stack, and set execution direction to "right" | |
| </td></tr> | |
| <tr> | |
| <td>l</td> | |
| <td><code>></code></td> | |
| <td>set execution direction to "right" | |
| </td></tr> | |
| <tr> | |
| <td>P</td> | |
| <td></td> | |
| <td>send value above the current cell to stdout (does not remove the value<sup>[<a class="external text" href="http://xkcd.com/285/" rel="nofollow"><i>citation needed</i></a>]</sup>) | |
| </td></tr> | |
| <tr> | |
| <td>p</td> | |
| <td></td> | |
| <td>send value below the current cell to stdout | |
| </td></tr> | |
| <tr> | |
| <td>q</td> | |
| <td><code>@</code></td> | |
| <td>quit: end program execution | |
| </td></tr> | |
| <tr> | |
| <td>R</td> | |
| <td></td> | |
| <td>reduce the value on top of the stack by the value of the cell above (see "A") | |
| </td></tr> | |
| <tr> | |
| <td>r</td> | |
| <td></td> | |
| <td>reduce the value on top of the stack by the value of the cell below | |
| </td></tr> | |
| <tr> | |
| <td>S</td> | |
| <td></td> | |
| <td>store (push) value of the cell above the current cell to stack (does not remove the value<sup>[<a class="external text" href="http://xkcd.com/285/" rel="nofollow"><i>citation needed</i></a>]</sup>) | |
| </td></tr> | |
| <tr> | |
| <td>s</td> | |
| <td></td> | |
| <td>store (push) value of the cell below the current cell to stack | |
| </td></tr> | |
| <tr> | |
| <td>X</td> | |
| <td></td> | |
| <td>if the value on top of the stack is negative, turn the execution direction 90 degrees to the left | |
| </td></tr> | |
| <tr> | |
| <td>x</td> | |
| <td></td> | |
| <td>if the value on top of the stack is positive, turn the execution direction 90 degrees to the right | |
| </td></tr> | |
| <tr> | |
| <td>#</td> | |
| <td></td> | |
| <td>behaves just like 'j', but only if its position in the code/data array is 0,0 (the left/top corner) and only if there is a '!' in the cell on its right side. | |
| </td></tr></tbody></table> | |
| <p>A program that tries to leave the grid or execute a value that isn't a command causes the language's standard error message, "Argh!" or "Aargh!" as appropriate, to be emitted, followed by the program terminating. | |
| </p> | |
| <h2><span class="mw-headline" id="Examples">Examples</span></h2> | |
| <p>The following program prints out "hello, world": | |
| </p> | |
| <pre>j world | |
| lppppppPPPPPPsrfj | |
| hello, * j | |
| qPh | |
| </pre> | |
| <p>Execution begins with the j in the top left corner, which indicates the starting direction of execution is down. The next command is an l, which means to now process commands to the right. Each p indicates that the value below it should be printed; each P indicates that the value above it should be printed. | |
| </p><p>The next part is more interesting: the goal is to output a linefeed (<a href="/wiki/ASCII" title="ASCII">ASCII</a> value 10, often written as "\n"). This special character has to be generated: the s stores the character below (<"*", ASCII 42) on the stack, the r reduces the value on the stack by the value of the character below (42 minus " ", ASCII 32, is 10), the f fetches the top value from the stack and inserts it below, so the cell below the f will hold the value 10, which is ASCII linefeed. The following j lead us down (we already know this) and the h sets the execution direction to go left and the P finally prints the linefeed. The q (for quit) command ends the program. | |
| </p><p>This program is a truth-machine: | |
| </p> | |
| <pre>lglj | |
| j | |
| jShh | |
| lrllxpq | |
| 0jph0 | |
| j1k | |
| lPk | |
| </pre> | |
| <h2><span class="mw-headline" id="Computational_class">Computational class</span></h2> | |
| <p>Suppose that the instruction pointer moves downwards into an <code>f</code>. If the top of the stack starts with a number of <code>f</code> followed by a <code>k</code>, then each <code>f</code>s in turn will be written to the grid below the previous <code>f</code> (below the original <code>f</code> for the first one), then the instruction pointer will start moving upwards and will write the content of the stack below each of the <code>f</code>s on the way back up. For example, after encountering an <code>f</code> moving downwards with the top of the stack starting with <code>fffkpqrs</code>, those eight stack elements will be popped and place <code>s</code>, <code>r</code>, <code>q</code>, <code>p</code> below the original <code>f</code>. The same trick can be accomplished moving upwards with <code>F</code> and <code>j</code>. | |
| </p><p>Now, suppose that there is a column of <code>j</code> above an <code>f</code>. If the top of the stack starts with <code>fkk?F?</code> (where a <code>?</code> could be any value), then the <code>fkk?</code> will place a <code>?</code> and <code>k</code> below the <code>f</code>, the instruction pointer will bounce off a <code>j</code>, the original <code>f</code> will run again and place an <code>F</code> below itself, which will then replace the original <code>F</code> with a <code>?</code> – but then the instruction pointer will bounce off the <code>k</code> and encounter an <code>F</code>, meaning that a crafted sequence on the top of the stack can replace the <code>f</code> and the elements above it with anything. In particular, it can write an <code>f</code> further up the column of <code>j</code>. Alternatively, by adding more <code>f</code> at the start of the process, it is possible to move the <code>f</code> down the column of <code>j</code>, adding <code>j</code> in between. | |
| </p><p>This basic technique makes it possible to represent a counter using a column of <code>j</code> followed by <code>f</code> (in each case, jumping back upwards with <code>K</code> when the increment/decrement is complete – the element below <code>K</code> on the stack specifies what symbol to look for), controlling the counter using the state of the stack upon moving down the column of <code>j</code>: | |
| </p> | |
| <ul><li><b>Increment</b>: <code>ffkkF??fjK</code></li> | |
| <li><b>Decrement</b>: <code>fkk?F?Ff?K</code></li></ul> | |
| <p>A zero test can be done by moving sideways across the position of the column that represents 0, with a <code>K</code> on top of the stack. In the below example, the test starts by entering along the row of <code>l</code>, and most of the characters are in the grid before the test is performed, but the <code>K</code> is added during the test: | |
| </p> | |
| <pre>zero nonzero | |
| j j | |
| j j | |
| lfll llljlll | |
| K f | |
| K | |
| </pre> | |
| <p>If the counter is discovered to be zero, the <code>K</code> and its jump label will be left on the stack, but can trivially be popped using, e.g., <code>F</code> while moving horizontally. | |
| </p><p>In Aargh!, which has unbounded vertical height, this makes it possible to produce counters that can store arbitrary nonnegative integers and can be incremented, decremented and zero-tested, which is enough power to implement various sorts of <a class="mw-redirect" href="/wiki/Counter_machine" title="Counter machine">counter machine</a>. The limited width of the grid is an issue for some constructions (as it means a limited number of counters are supported, and there is not enough room to create fully arbitrary control flow); however, it is sufficient to implement <a href="/wiki/The_Waterfall_Model" title="The Waterfall Model">The Waterfall Model</a>, which has very simple control flow (with the idea being to zero-test all the counters in sequence, pushing a sequence that represents a zeroing trigger onto the stack when a counter is found to be zero or a steady decrement if none of them are). Commands like <code>L</code> can be used for <a href="/wiki/Wire-crossing_problem" title="Wire-crossing problem">wire crossings</a>, and only three columns are needed to push a constant string onto the stack, e.g. <code>pqrs</code> can be pushed like this (starting by moving upwards from the bottom <code>k</code>): | |
| </p> | |
| <pre>ks | |
| kSh | |
| rk | |
| lSk | |
| kq | |
| kSh | |
| pk | |
| lSk | |
| k | |
| </pre> | |
| <p>The only remaining problem is to steer the IP to the appropriate counter to increment/decrement/zero-test, which can be done using <code>x</code> and <code>X</code> to read the strings that were pushed onto the stack. | |
| </p><p>As such, Aargh! is <a href="/wiki/Turing-complete" title="Turing-complete">Turing-complete</a>. (Argh! is a <a href="/wiki/Bounded-storage_machine" title="Bounded-storage machine">bounded-storage machine</a> unless the grid cells support arbitrarily large integers.) | |
| </p> | |
| <h2><span class="mw-headline" id="External_resources">External resources</span></h2> | |
| <ul><li><a class="external text" href="http://www.sha-bang.de/index.php?page=12_eso" rel="nofollow">Argh! website</a> (in German)</li> | |
| <li><a class="external text" href="http://www.sha-bang.de/content/12_eso/Argh-Spec.txt" rel="nofollow">Argh! and Aargh! language specification</a></li> | |
| <li><a class="external text" href="http://hg.intevation.org/argh" rel="nofollow">Argh! Mercurial Repository</a></li> | |
| <li><a class="external text" href="http://freshmeat.net/projects/argh/?branch_id=51939" rel="nofollow">Argh! project on Freshmeat.net</a></li> | |
| <li><a class="external text" href="http://sourceforge.net/projects/arghwxhaskell/" rel="nofollow">Interpreter in wxHaskell</a></li> | |
| <li><a class="external text" href="https://github.com/graue/esofiles/tree/master/argh!/" rel="nofollow">Argh!</a> in <a href="/wiki/The_Esoteric_File_Archive" title="The Esoteric File Archive">the Esoteric File Archive</a></li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20260210063823 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.018 seconds | |
| Real time usage: 0.029 seconds | |
| Preprocessor visited node count: 30/1000000 | |
| Post‐expand include size: 110/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 8.355 1 -total | |
| 98.16% 8.201 2 Template:Cn | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:996-0!canonical and timestamp 20260210063823 and revision id 155314. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b>Addition Automaton</b> is an <a href="/wiki/Esoteric_programming_language" title="Esoteric programming language">esoteric programming language</a> developed/discovered by <a href="/wiki/User:Ais523" title="User:Ais523">User:ais523</a> in <a href="/wiki/Category:2023" title="Category:2023">2023</a>, after a study into how useful base-conversion operators would be for implementing Turing tarpits. It is quite similar to a one-dimensional <a href="/wiki/Cellular_automaton" title="Cellular automaton">cellular automaton</a> (it is easy to compile between an addition and cellular automaton in either direction, although typically with a large increase in size). | |
| </p><p>The language comes in a few different "halt flavours"; these are identical except for their halting behaviour, which differs from flavour to flavour (but programs will behave identically up until the point that they halt). | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Specification"><span class="tocnumber">1</span> <span class="toctext">Specification</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Computational_class"><span class="tocnumber">2</span> <span class="toctext">Computational class</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-3"><a href="#Arbitrary_b"><span class="tocnumber">2.1</span> <span class="toctext">Arbitrary <i>b</i></span></a></li> | |
| <li class="toclevel-2 tocsection-4"><a href="#Small_values_of_b"><span class="tocnumber">2.2</span> <span class="toctext">Small values of <i>b</i></span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-5"><a href="#External_resources"><span class="tocnumber">3</span> <span class="toctext">External resources</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Specification">Specification</span></h2> | |
| <p>Each Addition Automaton program is designed for a specific numeric base <i>b</i> (an integer that's 2 or greater). The program consists of a <i>transition table</i>, which maps each of the <i>b</i> possible digits to a non-negative integer, and an <i>initial value</i>, which is a non-negative integer. A program must map the digit 0 to the integer 0; a program that does not do this is syntactically incorrect (implementations may diagnose this error, or if they prefer may react with <a class="mw-redirect" href="/wiki/Undefined_behaviour" title="Undefined behaviour">undefined behaviour</a>). | |
| </p><p>Execution of the program is based around a <i>state value</i>, a non-negative integer (whose initial value is specified by the program). An implementation repeatedly performs the following steps, until the program halts: | |
| </p> | |
| <ul><li>Disassembly: The state value is expressed as a list of digits in base <i>b</i>.</li> | |
| <li>Transition: For each digit in the resulting list, replace that digit with the integer it is mapped to in the transition table.</li> | |
| <li>Reassembly: Multiply each integer in the resulting list by the appropriate power of <i>b</i>, so that it has the same place value that it had originally (i.e. if a digit <i>d</i> originally came from the <i>b</i><sup><i>x</i></sup> position of the number and thus had a value of <i>d</i>×<i>b</i><sup><i>x</i></sup>, and the transition gave it a new value <i>v</i>, calculate <i>v</i>×<i>b</i><sup><i>x</i></sup>). Then add all those products together to form a new state value.</li></ul> | |
| <p>An alternative, less formal, way to think about this operation is that you are doing a "find and replace" operation on the digits of the state value in base <i>b</i>, but the replacements are arbitrary non-negative integers and thus could be more than one digit long (which causes them to carry into the more significant digits). | |
| </p><p>There are multiple flavours of the language, each of which has different rules for when it halts. Any given implementation should implement exactly one of these (for a given set of command-line options), and document which: | |
| </p> | |
| <dl><dt>Lax loop detection</dt> | |
| <dd>The program halts if the current state value is exactly equal to a power of <i>b</i> multiplied by any previous state value. (If this situation occurs, the program is necessarily in an infinite loop.)</dd> | |
| <dt>Strict loop detection</dt> | |
| <dd>The program halts if the current state value is exactly equal to any previous state value.</dd> | |
| <dt>Halt-on-zero</dt> | |
| <dd>The program halts if the state value becomes zero.</dd> | |
| <dt>No halting</dt> | |
| <dd>The program runs forever, and inspection of its internal state is needed to know whether it "should have halted".</dd></dl> | |
| <p>It should be noted that multiplying the internal state value by a power of <i>b</i> never has any influence on the program's future behaviour (except when using strict loop detection) – the "trailing zeroes" map to themselves and thus have no influence on the rest of the program. Likewise, if the internal state is divisible by <i>b</i> or a power of it, it is possible to remove those trailing zeroes. As such, optimizing implementations may want to remove trailing zeroes in order to save memory (which is part of the reason why lax loop detection is a permitted halting flavour – loop detection is useful, but strict loop detection could block the optimization). | |
| </p> | |
| <h2><span class="mw-headline" id="Computational_class">Computational class</span></h2> | |
| <h3><span class="mw-headline" id="Arbitrary_b">Arbitrary <i>b</i></span></h3> | |
| <p>If arbitrary values of <i>b</i> are allowed, Addition Automaton is trivially <a class="mw-redirect" href="/wiki/Turing_complete" title="Turing complete">Turing complete</a>, being able to fairly directly implement a wide range of languages. In fact, it is possible to almost directly implement a <a href="/wiki/Turing_machine" title="Turing machine">Turing machine</a> itself; for a Turing machine with <i>T</i> states and <i>S</i> symbols, let <i>b</i> be <i>S</i>(<i>T</i>+1), and use a 1-based numbering of the Turing machine states but a 0-based numbering of the symbols. The transition table is designed as follows: | |
| </p> | |
| <ul><li>For digits <i>s</i> less than <i>S</i>, map them to <i>bs</i>. (This maps 0 to 0, as required.)</li> | |
| <li>Other digits are of the form <i>St+s</i> (with 1≤<i>t</i>≤<i>T</i>, 0≤<i>s</i><<i>S</i>). Consider which way the Turing machine moves when reading <i>s</i> in state <i>t</i>, and the resulting symbol <i>s'</i> and state <i>t'</i>: | |
| <ul><li>If the Turing machine moves to the left, map <i>St+s</i> to <i>St'b</i><sup>2</sup>+<i>s'b</i>.</li> | |
| <li>If the Turing machine moves to the right, map <i>St+s</i> to <i>St'</i> + <i>s'b</i>.</li></ul></li></ul> | |
| <p>The encoding of the state value (and thus initial value) is to use a digit 0≤<i>s</i><<i>S</i> to represent a tape element with symbol <i>s</i> that does not currently hold the Turing machine head, and a digit <i>St+s</i> (with 1≤<i>t</i>≤<i>T</i>, 0≤<i>s</i><<i>S</i>) to represent a tape head in state <i>t</i> reading symbol <i>s</i>. The digits of the state value thus represent the tape of the Turing machine, although it moves one place-value in the more significant direction every iteration (ensuring among other things that the Turing machine never runs out of tape). | |
| </p><p>When using lax loop detection, state 0 can be used as a halt state. For strict loop detection, the Turing machine can halt by first deleting all the symbols on the tape, and then moving to the right in an infinite loop. For halt-on-zero, the Turing machine must halt by first deleting all symbols on the tape, and only then changing to state 0. | |
| </p> | |
| <h3><span class="mw-headline" id="Small_values_of_b">Small values of <i>b</i></span></h3> | |
| <p>Addition Automaton is also Turing-complete with some fairly small values of <i>b</i>. The smallest value is not currently known, and probably depends on the halting flavour in use. | |
| </p><p>One approach for writing Addition Automaton with small <i>b</i> is to emulate a <a href="/wiki/Cellular_automaton" title="Cellular automaton">cellular automaton</a>. For example, the version of <a class="mw-redirect" href="/wiki/Rule_110" title="Rule 110">rule 110</a> that starts from a finitely initialised tape can be implemented with <i>b</i>=8 (using a transition table for which all elements are either 0 or 421<sub>8</sub>). However, that version of the cellular automaton is not Turing-complete; to be Turing-complete, rule 110 requires memory to be initialized with an infinitely repeating pattern, a finite section, and then a different infinitely repeating pattern. It is actually possible to implement this in Addition Automaton, via using a couple of digits (one for each side) to lazily initialize memory before the repeating pattern there is disturbed, but doing that requires <i>b</i>=10. Additionally, when doing this, there is no way for the Addition Automaton to recognise rule 110's halt state. | |
| </p><p><i>b</i>=10 is, however, known to be possible (when using lax loop detection) via using a different approach; it is possible to compile <a href="/wiki/Echo_Tag" title="Echo Tag">Echo Tag</a> (with arbitrary <i>n</i>) into Addition Automaton (with a transition table that depends only on the value of <i>n</i> – the Echo Tag productions are specified using the initial string rather than being part of the transition table). 2-Echo Tag can be implemented with the following transition table: | |
| </p> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <th>Digit</th> | |
| <th>Maps to | |
| </th></tr> | |
| <tr> | |
| <td>1</td> | |
| <td>10000 | |
| </td></tr> | |
| <tr> | |
| <td>2</td> | |
| <td>2 | |
| </td></tr> | |
| <tr> | |
| <td>3</td> | |
| <td>200000400 | |
| </td></tr> | |
| <tr> | |
| <td>4</td> | |
| <td>0 | |
| </td></tr> | |
| <tr> | |
| <td>5</td> | |
| <td>2020202000 | |
| </td></tr> | |
| <tr> | |
| <td>6</td> | |
| <td>600 | |
| </td></tr> | |
| <tr> | |
| <td>7</td> | |
| <td>620 | |
| </td></tr> | |
| <tr> | |
| <td>8</td> | |
| <td>1600 | |
| </td></tr> | |
| <tr> | |
| <td>9</td> | |
| <td>620 | |
| </td></tr></tbody></table> | |
| <p>The value of <i>n</i> affects cases 3 and 5; increasing <i>n</i> by one adds another four <code>0</code>s between the <code>2</code> and <code>4</code> in case 3, and another <code>2020</code> in case 5. | |
| </p><p>The basic idea is for the Echo Tag productions to be represented as <code>1</code>s and <code>2</code>s that bounce around between a pair of <code>6</code>s, which creates the cycle needed for cyclic tag. Each production is represented using a pair of consecutive positions that might have or might not have a <code>1</code>/<code>2</code>; a 1 is represented by both being absent, and a 0 by the position that hits the <code>6</code> earlier being absent but the position that hits the <code>6</code> later being present. The data queue is also represented using <code>2</code>s; a 1 in the data queue is <code>2020</code> and a 0 is just zeroes. The data queue and productions hit a <code>6</code> simultaneously from opposite sides; when the production has a 1, the <code>2020</code> from the data queue will bounce off the <code>6</code> just like the <code>2</code>s in the productions do, and become <code>0101</code>; when the production has a 0, the second <code>2</code> will get deleted because the rule for <code>9</code> is the same as the rule for <code>7</code>, so it will just become <code>0100</code>. Towards the most significant end of the data queue is a <code>2</code> whose place-value has a different parity than the others, which serves to append to the end of the queue when it gets hit by a <code>1</code> (and thus becomes a <code>3</code>); when it gets hit it will move to a more significant position, leaving behind zeroes (effectively enqueueing <i>n</i> 0s to the end of the Echo Tag queue). However, it will also leave behind a <code>4</code> for one cycle. If the production contained a 1 (and thus the <code>3</code> was hit by an <code>0101</code> rather than an <code>0100</code>), this <code>4</code> will get hit by the second <code>1</code> and become a <code>5</code>, which changes values added to the data queue from being 0s to being 1s. Otherwise, the <code>4</code> deletes itself on the next cycle and leaves the 0s in place. | |
| </p><p>Here's an example of how this particular transition table behaves, implementing the 2-Echo Tag program [1,1,1,0] with a starting data queue of [1,1]. (For readability, trailing zeroes are removed, and the number is expressed in little-endian decimal so that the productions, on the left-hand side here, do not move around): | |
| </p> | |
| <pre>60000028022202 | |
| 600020083202 | |
| 602000085200002 | |
| 8000000812022202 | |
| 61000008123202 | |
| 60010008125200002 | |
| 600001081212022202 | |
| 6000000912123202 | |
| 6000002802125200002 | |
| 60002008120212022202 | |
| 602000081212023202 | |
| 800000081212124200002 | |
| 6100000812121210002 | |
| 60010008121210103 | |
| 60000108121010105000002 | |
| 600000091010101012022202 | |
| 6000002600101012123202 | |
| 6000200600001212125200002 | |
| 60200006000202121212022202 | |
| 800000060202020212123202 | |
| 610000080202020202125200002 | |
| 6001000812020202020212022202 | |
| 60000108121202020202023202 | |
| 60000009121212020202024200002 | |
| 600000280212121202020200002 | |
| 6000200812021212120200002 | |
| 60200008121202121210002 | |
| 800000081212120210103 | |
| 610000081212121000105000002 | |
| 6001000812121010100012022202 | |
| 60000108121010101012023202 | |
| 60000009101010101212124200002 | |
| 600000260010101212121210002 | |
| 6000200600001212121210103 | |
| 6020000600020212121010105000002 | |
| 80000006020202021010101012022202 | |
| 610000080202020000101012123202 | |
| 600100081202000000001212125200002 | |
| 6000010812100000000202121212022202 | |
| 60000009101010000202020212123202 | |
| 60000026001010120202020202125200002 | |
| 600020060000121212020202020212022202 | |
| 6020000600020212121202020202023202 | |
| 8000000602020202121212020202024200002 | |
| 61000008020202020212121202020200002 | |
| 600100081202020202021212120200002 | |
| 6000010812120202020202121210002 | |
| 60000009121212020202020210103 | |
| 60000028021212120202020000105000002 | |
| 600020081202121212020000000012022202 | |
| 6020000812120212121000000002023202 | |
| 8000000812121202101010000202024200002 | |
| 61000008121212100010101202020200002 | |
| 600100081212101010001212120200002 | |
| 6000010812101010101202121210002 | |
| 60000009101010101212120210103 | |
| 60000026001010121212121000105000002 | |
| 600020060000121212121010100012022202 | |
| 6020000600020212121010101012023202 | |
| 8000000602020202101010101212124200002 | |
| etc. (this program does not halt) | |
| </pre> | |
| <p>The easiest way to spot the correspondence is to look for 4s and 5s: a 4 appears when the Echo Tag program pushes a block of 0s onto the end of the data queue, and a 5 when it pushes a block of 1s. | |
| </p> | |
| <h2><span class="mw-headline" id="External_resources">External resources</span></h2> | |
| <ul><li><a class="external text" href="https://tio.run/##XVA9T8MwEN37K24Eqa3SCFWssCF1hAkxXGI3GLl2FF/Ex1QQCAkWRiRgAjbEAkWt2FIJ8TeSPxLORHzGin13fvfe8@1IrffruhpfrwihSFkDKznZERJHypDM0kzy3oW1UarlSBpyoHEPtLUpCL6KfVMb0AgQyqUa9xmgiLTsSCMUGkZFeQI2pzQn5oQInYSoW41vWqy7vi1hqDJHgFmSewFYKJ4WQTkgvlKGXaEGgYTgKFMmYTEHCCYfRWzsF42TsWUbPzzV4fM3EWVoXPNCwkjLLny2qAMJdsgID/N1j8@dFEAWYtRxrpH@2WVw9ldm8i3TuPKUWqKjjlOJUUMVIwOFShSPj4ndtt31o/Adv8fzqdLaKKe3zFmNL8vX8/nl6vvj21l19FDOrqrDl3J2zEGrmET8ukFxR8H8lGGclNOTplTcF5P5xcDjx9d1XYdBGIbBchj4r19v9vzZDttNYYljzoJmcdL3fxi0e19BsFX3loMP" rel="nofollow">Implementation in Jelly (with debug output and lax loop detection); runnable online at Try It Online!</a></li> | |
| <li>More context on what lead to the creation of Addition Automaton can be found in two Code Golf Stack Exchange posts, <a class="external text" href="https://codegolf.stackexchange.com/a/264429" rel="nofollow">here</a> and <a class="external text" href="https://codegolf.stackexchange.com/a/264393" rel="nofollow">here</a>.</li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20250724091411 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.015 seconds | |
| Real time usage: 0.017 seconds | |
| Preprocessor visited node count: 25/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:17600-0!canonical and timestamp 20250724091411 and revision id 140563. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b>Advance The Wheel!</b> is a <a href="/wiki/Turning_tarpit" title="Turning tarpit">turning tarpit</a> created by <a href="/wiki/User:Ais523" title="User:Ais523">User:ais523</a> in <a href="/wiki/Category:2022" title="Category:2022">2022</a>. Its primary purpose is to create a language in which a self-interpreter can be as small as possible. It also has an unusual form of control flow: when the program reads data from memory, this does not affect the position of the instruction pointer, but rather affects the position of the wheel (thus the two branches of the equivalent of an "if" statement will run the same program commands, but with different meanings because they will correspond to different wheel commands). | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Data_model"><span class="tocnumber">1</span> <span class="toctext">Data model</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Commands"><span class="tocnumber">2</span> <span class="toctext">Commands</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-3"><a href="#Program_commands"><span class="tocnumber">2.1</span> <span class="toctext">Program commands</span></a></li> | |
| <li class="toclevel-2 tocsection-4"><a href="#Wheel_commands"><span class="tocnumber">2.2</span> <span class="toctext">Wheel commands</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-5"><a href="#Computational_class"><span class="tocnumber">3</span> <span class="toctext">Computational class</span></a></li> | |
| <li class="toclevel-1 tocsection-6"><a href="#Programs"><span class="tocnumber">4</span> <span class="toctext">Programs</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-7"><a href="#Self-interpreter"><span class="tocnumber">4.1</span> <span class="toctext">Self-interpreter</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-8"><a href="#External_resources"><span class="tocnumber">5</span> <span class="toctext">External resources</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Data_model">Data model</span></h2> | |
| <p>A program in Advance The Wheel! stores data in queues of bits – there are an unbounded number of such queues available, and each can hold an unbounded number of bits. In order to determine which queue memory operations operate on, there is an unbounded integer (which can be positive, negative or zero) that is known as the <i>queue pointer</i>; at the start of the program, this is initially 1. It refers to a queue in the following fashion: | |
| </p> | |
| <ul><li>When the queue pointer is odd (i.e. congruent to 1 mod 2), it refers to queue 1;</li> | |
| <li>when the queue pointer is congruent to 2 mod 4, it refers to queue 2;</li> | |
| <li>when the queue pointer is congruent to 4 mod 8, it refers to queue 3;</li> | |
| <li>when the queue pointer is congruent to 8 mod 16, it refers to queue 4, etc..</li> | |
| <li>As a special case, when the queue pointer is 0, it refers to queue 0.</li></ul> | |
| <p>Queue 0 is special: enqueuing bits onto it writes to standard output, and dequeuing bits from it reads from standard input (rather than returning bits enqueued earlier). The exact encoding of I/O has not been specified yet, nor has EOF behaviour – this may change in the future. | |
| </p><p>Attempting to dequeue a bit from an empty queue halts the program. | |
| </p><p>An Advance The Wheel! interpreter initializes queues 1, 2, 3, etc. in sequence from its command-line arguments; each command-line argument names a file, and the contents of that file provide the initial contents of the queue. Apart from queue 0 (whose contents are inaccessible and thus irrelevant), queues for which no corresponding command-line argument is present start out empty. | |
| </p><p>In addition to the queues and queue pointer, there is also The Wheel. This is, in effect, a list of nine "wheel commands" plus a pointer that can point to one command (the "current command") on The Wheel; "advancing" The Wheel increments the pointer, causing it to point at the command immediately after the command it was previously pointing to (and it wraps back to the start upon reaching the end). | |
| </p> | |
| <h2><span class="mw-headline" id="Commands">Commands</span></h2> | |
| <h3><span class="mw-headline" id="Program_commands">Program commands</span></h3> | |
| <p>Advance The Wheel! programs are a sequence of bits, with each bit corresponding to one of two commands, based on its value: | |
| </p> | |
| <ul><li>A 0 bit advances The Wheel.</li> | |
| <li>A 1 bit runs The Wheel's current command, and then advances The Wheel. (Even if the wheel command advances The Wheel, the program command advances it anyway after running the command, so, e.g. if the current command is "advance The Wheel", running the "1" program command will cause The Wheel to advance twice; once from the wheel command, and once from the program command.)</li></ul> | |
| <p>The program commands that make up the program always run in sequence from start to end; there is no control flow. When the end of the program is reached, the instruction pointer loops back to the start of the program, effectively making the program into the body of a giant infinite loop (with the only way to break out of the loop being to halt the program by trying to dequeue from an empty queue). | |
| </p><p>A program is not allowed to be entirely empty (the empty program has <a class="mw-redirect" href="/wiki/Undefined_behaviour" title="Undefined behaviour">undefined behaviour</a>). | |
| </p> | |
| <h3><span class="mw-headline" id="Wheel_commands">Wheel commands</span></h3> | |
| <p>The Wheel contains nine commands. (This description of the language names them with letters, "A" to "I" inclusive, in order to make it easier to explain which command is being referred to; they cannot be named directly in a program, so the names are irrelevant from the point of view of implementing or programming in the language.) Here they are, in the order they appear on The Wheel: | |
| </p> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <th>A | |
| </th> | |
| <td>Dequeue a bit from the queue that the queue pointer refers to. If the dequeued bit was a 1 bit, advance The Wheel! | |
| </td></tr> | |
| <tr> | |
| <th>B | |
| </th> | |
| <td>Do nothing. | |
| </td></tr> | |
| <tr> | |
| <th>C | |
| </th> | |
| <td>Decrement the queue pointer. | |
| </td></tr> | |
| <tr> | |
| <th>D | |
| </th> | |
| <td>Enqueue a 0 bit onto the queue that the queue pointer refers to. | |
| </td></tr> | |
| <tr> | |
| <th>E | |
| </th> | |
| <td>Enqueue a 1 bit onto the queue that the queue pointer refers to. | |
| </td></tr> | |
| <tr> | |
| <th>F | |
| </th> | |
| <td>Do nothing. | |
| </td></tr> | |
| <tr> | |
| <th>G | |
| </th> | |
| <td>Advance The Wheel! | |
| </td></tr> | |
| <tr> | |
| <th>H | |
| </th> | |
| <td>Do nothing. | |
| </td></tr> | |
| <tr> | |
| <th>I | |
| </th> | |
| <td>Increment the queue pointer. | |
| </td></tr></tbody></table> | |
| <p>Advancing The Wheel therefore changes the current command from A to B, from B to C, … from H to I, or from I to A. At the start of program execution, the current command is command A. | |
| </p> | |
| <h2><span class="mw-headline" id="Computational_class">Computational class</span></h2> | |
| <p>Every <a href="/wiki/Cyclic_tag_system" title="Cyclic tag system">cyclic tag system</a> can be compiled into Advance The Wheel! fairly directly – it's possible to use queue 1 to contain the data string, and to hard-code the production rules into the program. Between two production rules, The Wheel's current command is command A. The Advance The Wheel! code for that implements the start of a production rule is <code>100001000</code>; this runs command A to dequeue a bit from queue 1, then runs command F if a 0 was dequeued, or G if a 1 was dequeued, with three more 0 commands leaving the current command as A or C based on whether a 0 was dequeued (i.e. skip the production) or a 1 was dequeued (i.e. append the production to the queue). A 0 within the production can then be implemented as <code>010000000</code> (which runs command B if the production should be skipped, or D if it should be appended), and a 1 as <code>001000001</code> (which runs commands C and I (which cancel each other out) if the production should be skipped, or E and B if it should be appended). At the end of the production, <code>0000001001000010</code> will deterministically get the current command back to command A (via running GBG if the current command was A, or ICH if the current command was C – the former has two advancements and a no-op, the latter has two queue pointer adjustments that cancel each other out and a no-op, so The Wheel is advanced 18 or 16 times depending on whether the current command was initially A or C, and thus ends up at A in either case). | |
| </p><p>The initial state of the data string can be initialized from a file specified via a command-line argument, but if you consider that cheating, it's also possible to initialize it within the program itself, via starting with <code>00</code> followed by a "production body" that initializes the data queue (and the <code>0000001001000010</code> after it that normalizes The Wheel's current command) – the production body will then run with The Wheel with C as its current command on the first pass through the program (which is where The Wheel starts), and thus initialize the data queue appropriately. Ending the program with <code>0000000</code> will cancel out the leading <code>00</code> (as nine <code>0</code>s are a no-op), meaning that on subsequent executions, the initializer's "production body" starts out with A as the current command and thus does nothing. | |
| </p> | |
| <h2><span class="mw-headline" id="Programs">Programs</span></h2> | |
| <h3><span class="mw-headline" id="Self-interpreter">Self-interpreter</span></h3> | |
| <pre class="rectwrap">10010111000000100000010011001001000000010110000000 | |
| 01010010100100000011000111001000000100010000010001 | |
| 00100001000100010100100101001010001001001000000010 | |
| 100001100000011000010010 | |
| </pre> | |
| <p>This self-interpreter is only 174 bits long. It works via using its queue <i>n</i>+1 to model queue <i>n</i> of the interpreted program; queue 1 holds the program being interpreted. The queue pointer is twice the queue pointer of the interpreted program plus a constant (the constant depends on the position within the program and The Wheel's current command, but is normally either -1 or 1). The position of the instruction pointer within the self-interpreter encodes the position of The Wheel within the interpreted program (and the position of the instruction pointer within the interpreted program is always at the head of queue 1 – whenever a command is executed, it is dequeued, then re-enqueued). This way of doing things means that the language is metacircular in terms of I/O and in terms of the queue pointer decoding, but the wheel commands are all implemented explicitly using actual code (thus, it would be easy to alter this program so that it implements a language that was the same in most respects, but used a different Wheel). | |
| </p><p>Here's a computer-generated explanation of how the program works (each section of code implements either one wheel command or two consecutive wheel commands); each line specifies a possible interpretation of the program commands as wheel commands, together with the queue operations that occur during / produce that interpretation: | |
| </p> | |
| <pre>Behaviour for AB_dequeue_nop (10010111000000100000010011001001000000010): | |
| ADFGIGFIADGG [qptr: 1 -> 3] shift 0 from 1; push 0 to 1; shift 0 from 1; push 0 to 1 | |
| ADFGIGFIAEHG [qptr: 1 -> 3] shift 0 from 1; push 0 to 1; shift 1 from 1; push 1 to 1 | |
| AEGIAHFIADGG [qptr: 1 -> 3] shift 1 from 1; push 1 to 1; shift 0 from 2; shift 0 from 1; push 0 to 1 | |
| AEGIAHFIAEHG [qptr: 1 -> 3] shift 1 from 1; push 1 to 1; shift 0 from 2; shift 1 from 1; push 1 to 1 | |
| AEGIAIGBCFIH [qptr: 1 -> 3] shift 1 from 1; push 1 to 1; shift 1 from 2 | |
| Behaviour for C_decrement (11000000001010010): | |
| ABBDG [qptr: 3 -> 3] shift 0 from 1; push 0 to 1 | |
| ACCEH [qptr: 3 -> 1] shift 1 from 1; push 1 to 1 | |
| Behaviour for D_enqueue_0 (10010000001100011): | |
| ADBCGI [qptr: 3 -> 3] shift 0 from 1; push 0 to 1 | |
| AECDHI [qptr: 3 -> 3] shift 1 from 1; push 1 to 1; push 0 to 2 | |
| Behaviour for E_enqueue_1 (100100000010001000001000100100001000100010): | |
| ADBFCGBGCG [qptr: 3 -> 1] shift 0 from 1; push 0 to 1 | |
| AECGEICHCG [qptr: 3 -> 1] shift 1 from 1; push 1 to 1; push 1 to 2 | |
| Behaviour for F_no_operation (10010010): | |
| ADG [qptr: 1 -> 1] shift 0 from 1; push 0 to 1 | |
| AEH [qptr: 1 -> 1] shift 1 from 1; push 1 to 1 | |
| Behaviour for GH_advance_nop (1001010001001001000000010): | |
| ADFADGG [qptr: 1 -> 1] shift 0 from 1; push 0 to 1; shift 0 from 1; push 0 to 1 | |
| ADFAEHG [qptr: 1 -> 1] shift 0 from 1; push 0 to 1; shift 1 from 1; push 1 to 1 | |
| AEGCFIH [qptr: 1 -> 1] shift 1 from 1; push 1 to 1 | |
| Behaviour for I_increment (100001100000011000010010): | |
| AFGFGDG [qptr: 1 -> 1] shift 0 from 1; push 0 to 1 | |
| AGIGIEH [qptr: 1 -> 3] shift 1 from 1; push 1 to 1 | |
| </pre> | |
| <h2><span class="mw-headline" id="External_resources">External resources</span></h2> | |
| <ul><li><a class="external text" href="https://gitlab.com/Hakerh400/haskell-projects/-/tree/master/advance-the-wheel" rel="nofollow">Interpreter</a></li> | |
| <li><a class="external text" href="http://nethack4.org/esolangs/atw-analyzer.pl" rel="nofollow">Some Perl subroutines</a> that ais523 uses to help generate fragments of Advance The Wheel! code</li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20250724010919 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.012 seconds | |
| Real time usage: 0.017 seconds | |
| Preprocessor visited node count: 34/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 207/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:15323-0!canonical and timestamp 20250724010919 and revision id 147712. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><dl><dd><i>Note: This article contains <a href="#Special_characters">special characters</a>.</i></dd></dl> | |
| <p><b>Aheui</b> (아희 in Korean language) is the first <a href="/wiki/Esoteric_programming_language" title="Esoteric programming language">esoteric programming language</a> ever to be designed for Hangul, the Korean alphabet, designed by <a href="/wiki/User:Puzzlet_Chung" title="User:Puzzlet Chung">User:Puzzlet Chung</a>. | |
| </p><p>Many of the Aheui's concept is derived from <a href="/wiki/Befunge" title="Befunge">Befunge</a>-93, except the fact that it has no instruction for self-modifying, and that it has 26 stacks and one queue. | |
| </p><p><br/> | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Execution"><span class="tocnumber">1</span> <span class="toctext">Execution</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-2"><a href="#Instructions"><span class="tocnumber">1.1</span> <span class="toctext">Instructions</span></a> | |
| <ul> | |
| <li class="toclevel-3 tocsection-3"><a href="#Vowels"><span class="tocnumber">1.1.1</span> <span class="toctext">Vowels</span></a></li> | |
| <li class="toclevel-3 tocsection-4"><a href="#Consonants"><span class="tocnumber">1.1.2</span> <span class="toctext">Consonants</span></a> | |
| <ul> | |
| <li class="toclevel-4 tocsection-5"><a href='#The_"ㅇ"_group:'><span class="tocnumber">1.1.2.1</span> <span class="toctext">The "ㅇ" group:</span></a></li> | |
| <li class="toclevel-4 tocsection-6"><a href='#The_"ㄷ"_group_(arithmetic_operations):'><span class="tocnumber">1.1.2.2</span> <span class="toctext">The "ㄷ" group (arithmetic operations):</span></a></li> | |
| <li class="toclevel-4 tocsection-7"><a href='#The_"ㅁ"_group(storage_manipulation):'><span class="tocnumber">1.1.2.3</span> <span class="toctext">The "ㅁ" group(storage manipulation):</span></a></li> | |
| <li class="toclevel-4 tocsection-8"><a href='#The_"ㅅ"_group:'><span class="tocnumber">1.1.2.4</span> <span class="toctext">The "ㅅ" group:</span></a></li> | |
| </ul> | |
| </li> | |
| </ul> | |
| </li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-9"><a href="#Computational_class"><span class="tocnumber">2</span> <span class="toctext">Computational class</span></a></li> | |
| <li class="toclevel-1 tocsection-10"><a href="#Examples"><span class="tocnumber">3</span> <span class="toctext">Examples</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-11"><a href="#Hello_world"><span class="tocnumber">3.1</span> <span class="toctext">Hello world</span></a></li> | |
| <li class="toclevel-2 tocsection-12"><a href="#Truth-machine"><span class="tocnumber">3.2</span> <span class="toctext">Truth-machine</span></a></li> | |
| <li class="toclevel-2 tocsection-13"><a href="#A+B_Problem"><span class="tocnumber">3.3</span> <span class="toctext">A+B Problem</span></a></li> | |
| <li class="toclevel-2 tocsection-14"><a href="#Times_table_generator"><span class="tocnumber">3.4</span> <span class="toctext">Times table generator</span></a></li> | |
| <li class="toclevel-2 tocsection-15"><a href="#Project_Euler"><span class="tocnumber">3.5</span> <span class="toctext">Project Euler</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-16"><a href="#Special_characters"><span class="tocnumber">4</span> <span class="toctext">Special characters</span></a></li> | |
| <li class="toclevel-1 tocsection-17"><a href="#External_resources"><span class="tocnumber">5</span> <span class="toctext">External resources</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Execution">Execution</span></h2> | |
| <p>A program is a grid of characters(it doesn't need to be a rectangle). | |
| If the cursor arrives at a boundary of the grid, it wraps around to the other side of the grid but maintains the same momentum. | |
| Complete Hangul characters(they are commands) are made of three parts: | |
| </p> | |
| <ol><li>initial consonant</li> | |
| <li>vowel</li> | |
| <li>final consonant</li></ol> | |
| <p>The initial consonants are: | |
| </p> | |
| <pre>ㄱ,ㄲ,ㄴ,ㄷ,ㄸ,ㄹ,ㅁ,ㅂ,ㅃ,ㅅ,ㅆ,ㅇ,ㅈ,ㅉ,ㅊ,ㅋ,ㅌ,ㅍ,ㅎ | |
| </pre> | |
| <p>The vowels are: | |
| </p> | |
| <pre>ㅏ,ㅐ,ㅑ,ㅒ,ㅓ,ㅔ,ㅕ,ㅖ,ㅗ,ㅘ,ㅙ,ㅚ,ㅛ,ㅜ,ㅝ,ㅞ,ㅟ,ㅠ,ㅡ,ㅢ,ㅣ | |
| </pre> | |
| <p>And the final consonants are: | |
| </p> | |
| <pre>(no consonant),ㄱ,ㄲ,ㄳ,ㄴ,ㄵ,ㄶ,ㄷ,ㄹ,ㄺ,ㄻ,ㄼ,ㄽ,ㄾ, | |
| ㄿ,ㅀ,ㅁ,ㅂ,ㅄ,ㅅ,ㅆ,ㅇ,ㅈ,ㅊ,ㅋ,ㅌ,ㅍ,ㅎ | |
| </pre> | |
| <p>The examples of complete Hangul characters: 한, 가, 응. | |
| Incomplete Hangul(ㄱ, ㅇ, ㅑ, ㅟ) and non-Hangul characters are treated as comments. | |
| The commands are executed as follows: | |
| </p> | |
| <ol><li>Process the consonants(they specify the actual instruction). Update the momentum if required by the consonants.</li> | |
| <li>Set the momentum of the cursor based on the current momentum and the vowel(it changes the momentum).</li> | |
| <li>Move the cursor based on the current momentum.</li></ol> | |
| <p>Instruction pointer starts at the top left corner([0;0]) and is moving down(it has a [1;0] momentum). | |
| </p> | |
| <h3><span class="mw-headline" id="Instructions">Instructions</span></h3> | |
| <h4><span class="mw-headline" id="Vowels">Vowels</span></h4> | |
| <p>In Aheui, the following vowels have no use (although they can still be included in valid programs): | |
| </p> | |
| <pre>ㅐ,ㅒ,ㅖ,ㅘ,ㅙ,ㅚ,ㅝ,ㅞ,ㅟ | |
| </pre> | |
| <p>Other vowels change momentum as follows: | |
| </p> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <th>Vowel | |
| </th> | |
| <th>Momentum | |
| </th></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㅏ</code>(A) | |
| </td> | |
| <td>[0;1](right) | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㅓ</code>(Ö) | |
| </td> | |
| <td>[0;-1](left) | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㅗ</code>(O) | |
| </td> | |
| <td>[-1;0](up) | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㅜ</code>(U) | |
| </td> | |
| <td>[1;0](down) | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㅑ</code>(ʲA) | |
| </td> | |
| <td>[0;2] | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㅕ</code>(ʲÖ) | |
| </td> | |
| <td>[0;-2] | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㅛ</code>(ʲO) | |
| </td> | |
| <td>[-2;0] | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㅠ</code>(ʲU) | |
| </td> | |
| <td>[2;0] | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㅡ</code>(Ǝ) | |
| </td> | |
| <td>current momentum reflected vertically. | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㅣ</code>(I) | |
| </td> | |
| <td>current momentum reflected horizontally. | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㅢ</code>(ʲI) | |
| </td> | |
| <td>current momentum reflected both vertically and horizontally. | |
| </td></tr> | |
| </tbody></table> | |
| <h4><span class="mw-headline" id="Consonants">Consonants</span></h4> | |
| <p>When reading a character, the initial consonant specifies the action to be performed. If the action takes in some parameter, the final consonant (or lack thereof) is used as the value for the parameter. | |
| If there is less values than needed in the current storage, | |
| instructions only reverse the momentum. The functionality of the consonants can be broken down into the following groups: | |
| </p> | |
| <h5><span id="The_.22.E3.85.87.22_group:"></span><span class="mw-headline" id='The_"ㅇ"_group:'>The "ㅇ" group:</span></h5> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <th>Consonant | |
| </th> | |
| <th>Description | |
| </th></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㅇ</code>(ʔ-ŋ) | |
| </td> | |
| <td><a href="/wiki/Nop" title="Nop">Nop</a> | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㅎ</code>(h-h) | |
| </td> | |
| <td>Terminate the program. | |
| <p>(If the current storage is non-empty, the program pops from the storage and returns the result. If the current storage is empty, the program returns 0.) | |
| </p> | |
| </td></tr> | |
| </tbody></table> | |
| <p>The final consonant is not used. | |
| </p> | |
| <h5><span id="The_.22.E3.84.B7.22_group_.28arithmetic_operations.29:"></span><span class="mw-headline" id='The_"ㄷ"_group_(arithmetic_operations):'>The "ㄷ" group (arithmetic operations):</span></h5> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <th>Consonant | |
| </th> | |
| <th>Description | |
| </th></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㄷ</code>(d-d) | |
| </td> | |
| <td>Pops two values from the current storage and pushes their sum. | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㄸ</code>(d²-d²) | |
| </td> | |
| <td>Pops two values from the current storage and pushes their product | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㄴ</code>(n-n) | |
| </td> | |
| <td>Pops two values from the current storage, | |
| <p>performs integer division and pushes the result. | |
| </p> | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㅌ</code>(t-t) | |
| </td> | |
| <td>Pops two values from the current storage, | |
| <p>subtracts the 1st value from the 2nd and pushes the result. | |
| </p> | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㄹ</code>(r-l) | |
| </td> | |
| <td>Pops two values from the current storage, | |
| <p>performs modulo(second%first) and pushes the result. | |
| </p> | |
| </td></tr></tbody></table> | |
| <p>All of the "ㄷ" group ingnores the final consonant. | |
| </p> | |
| <h5><span id="The_.22.E3.85.81.22_group.28storage_manipulation.29:"></span><span class="mw-headline" id='The_"ㅁ"_group(storage_manipulation):'>The "ㅁ" group(storage manipulation):</span></h5> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <th>Consonant | |
| </th> | |
| <th>Description | |
| </th></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㅁ</code>(m-m) | |
| </td> | |
| <td>Pops the value from the current storage. | |
| <p>If the final consonant is "ㅇ": Print it as an integer. | |
| If it is "ㅎ": Print as the unicode(UTF-8) character. | |
| Otherwise do nothing with the value. | |
| </p> | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㅂ</code>(b-b) | |
| </td> | |
| <td>If the final consonant is "ㅇ": | |
| <pre> Pushes an integer from the input to the current storage. | |
| </pre> | |
| <p>If it is "ㅎ": Pushes the value of the unicode(UTF-8) character from the input | |
| to the current storage. | |
| Otherwise, pushes the number of strokes required to draw the consonant | |
| to the current storage: | |
| </p><p>ㄱ:2 ㄴ:2 ㄷ:3 ㄹ:5 ㅁ:4 ㅂ:4 | |
| ㅅ:2 ㅈ:3 ㅊ:4 ㅋ:3 ㅌ:4 ㅍ:4 | |
| ㄲ:4 ㄳ:4 ㄵ:5 ㄶ:5 ㄺ:7 ㄻ:9 | |
| ㄼ:9 ㄽ:7 ㄾ:9 ㄿ:9 ㅀ:8 ㅄ:6 ㅆ:4 | |
| (no consonant):0 | |
| </p> | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㅃ</code>(b²-b²) | |
| </td> | |
| <td>DUP | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㅍ</code>(p-p) | |
| </td> | |
| <td>SWAP | |
| </td></tr> | |
| </tbody></table> | |
| <h5><span id="The_.22.E3.85.85.22_group:"></span><span class="mw-headline" id='The_"ㅅ"_group:'>The "ㅅ" group:</span></h5> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <th>Consonant | |
| </th> | |
| <th>Description | |
| </th></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㅅ</code>(s-s) | |
| </td> | |
| <td>Current storage is changed by the final consonants. | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㅆ</code>(s²-s²) | |
| </td> | |
| <td>The current storage is popped and the returned value is pushed into the storage mapped to by the final consonant. | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㅈ</code>(ĵ-ĵ) | |
| </td> | |
| <td>Pops 2 values from the current storage. If the latter value is greater than or equal to the former value(first≥second), pushes 1 to the current storage, pushes 0 otherwise. | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center;"><code>ㅊ</code>(ĉ-ĉ) | |
| </td> | |
| <td>Pops a value from current storage. If the value is zero, reverses the current momentum. Else, do nothing. | |
| </td></tr> | |
| </tbody></table> | |
| <p>The final consonants are mapped to the storages as follows: | |
| </p> | |
| <pre>The stacks: none, ㄱ, ㄴ, ㄷ, ㄹ, ㅁ, ㅂ, ㅇ, ㅅ, ㅈ, ㅊ, ㅋ, ㅌ, ㅍ, ㅎ, ㄲ, ㄳ, ㄵ, ㄶ, | |
| ㄺ, ㄻ, ㄼ, ㄽ, ㄾ, ㄿ, ㅀ, ㅄ, or ㅆ. | |
| The queue: ㅇ. | |
| The extension protocol: ㅎ. | |
| </pre> | |
| <h2><span class="mw-headline" id="Computational_class">Computational class</span></h2> | |
| <p>Unlike <a href="/wiki/Befunge" title="Befunge">Befunge</a>-93, Aheui does not specify limit of codespace; however, Aheui does not use codespace as a storage. Aheui has additional stacks instead. Since a pair of unbounded stacks can be used to simulate the unbounded tape of a <a href="/wiki/Turing_machine" title="Turing machine">Turing machine</a>, it is likely that Aheui is <a href="/wiki/Turing-complete" title="Turing-complete">Turing-complete</a>. <a href="/wiki/Aheui_Turing-completeness_proof" title="Aheui Turing-completeness proof">Partial proof</a>. | |
| </p> | |
| <h2><span class="mw-headline" id="Examples">Examples</span></h2> | |
| <h3><span class="mw-headline" id="Hello_world"><a class="mw-redirect" href="/wiki/Hello_world" title="Hello world">Hello world</a></span></h3> | |
| <p>This code prints "<a href="/wiki/Hello,_world!" title="Hello, world!">Hello, world!</a>": | |
| </p><p><font style="font-family:UnDotum, Dotum, monospace;"> | |
| </font></p><font style="font-family:UnDotum, Dotum, monospace;"><pre>밤밣따빠밣밟따뿌 | |
| 빠맣파빨받밤뚜뭏 | |
| 돋밬탕빠맣붏두붇 | |
| 볻뫃박발뚷투뭏붖 | |
| 뫃도뫃희멓뭏뭏붘 | |
| 뫃봌토범더벌뿌뚜 | |
| 뽑뽀멓멓더벓뻐뚠 | |
| 뽀덩벐멓뻐덕더벅 | |
| </pre></font><font style="font-family:UnDotum, Dotum, monospace;"></font><p><font style="font-family:UnDotum, Dotum, monospace;"></font> | |
| </p> | |
| <h3><span class="mw-headline" id="Truth-machine"><a href="/wiki/Truth-machine" title="Truth-machine">Truth-machine</a></span></h3> | |
| <pre>뱡먕뺘뼈처망희</pre> | |
| <h3><span id="A.2BB_Problem"></span><span class="mw-headline" id="A+B_Problem"><a href="/wiki/A%2BB_Problem" title="A+B Problem">A+B Problem</a></span></h3> | |
| <pre>방방다망희</pre> | |
| <p><br/> | |
| </p> | |
| <h3><span class="mw-headline" id="Times_table_generator">Times table generator</span></h3> | |
| <p>Not available | |
| </p> | |
| <h3><span class="mw-headline" id="Project_Euler"><a href="/wiki/User:ProjectEuler" title="User:ProjectEuler">Project Euler</a></span></h3> | |
| <p><b>Problem 1</b> | |
| </p><p>This code is for Project Euler's Problem 1. It may still need reduction. | |
| </p> | |
| <pre>바싹밣발발발따따뚜 | |
| 루벌루벋뻐터너벌벌 | |
| 우뽀처빠쑥사빠아초희멍 | |
| 처아아오삭도오어샥여오여</pre> | |
| <p><b>Problem 2</b> | |
| </p><p>This program may need reduction. | |
| </p> | |
| <pre>바싹바발발나빠뱐주뱔뗘땨뼈뺘뗘뺘변따뗘 | |
| 삭망희ㅇ루벅포뼈차 | |
| 싹샥뼈댜챠사빠쑥 | |
| ㅇㅇㅇㅇ쌰석쇼뎌</pre> | |
| <p><b>Problem 5</b> | |
| </p> | |
| <pre>발발나싹발밤따뿌망희 | |
| 뿌석뻐서썬뻐석처속 | |
| 사싹샥도루발나툐 | |
| 빠쌱션속쳐볼서</pre> | |
| <p><b>Problem 6</b> | |
| </p> | |
| <pre>바싹밤발발따뚜 | |
| 투너벌벌뻐뻐뻐 | |
| 따따싹삭두빠초 | |
| 뭉뱔벌냐셔토삭 | |
| 희</pre> | |
| <h2><span class="mw-headline" id="Special_characters">Special characters</span></h2> | |
| <p><i>This article contains special characters that fall in the Hangul Syllable area of the Unicode charset. You need an appropriate font for the browser to display it correctly. Because Aheui is a two-dimensional language, using a monospacial Hangul font is highly recommended. (e.g. <a class="external text" href="http://kldp.net/frs/?group_id=300" rel="nofollow">UnDotum</a>)</i> | |
| </p> | |
| <h2><span class="mw-headline" id="External_resources">External resources</span></h2> | |
| <ul><li><a class="external text" href="https://aheui.readthedocs.io/en/latest/specs.en.html" rel="nofollow">Specification of Aheui</a></li> | |
| <li><a class="external text" href="http://aheui.github.io/jsaheui/jsaheui_en.html" rel="nofollow">Interpreter in JavaScript</a></li> | |
| <li><a class="external text" href="https://github.com/aheui" rel="nofollow">Implementations in various languages</a></li> | |
| <li><a class="external text" href="https://github.com/aheui/aheui.aheui" rel="nofollow">AheuiAheui, Implementation in Aheui</a></li> | |
| <li><a class="external text" href="https://aheui.github.io/avis/" rel="nofollow">AVIS</a>, Visual Aheui editor & interpreter</li> | |
| <li><a class="external text" href="http://yoo2001818.github.io/AheuiChem/" rel="nofollow">AheuiChem</a> Visual Aheui editor</li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20250724011238 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.026 seconds | |
| Real time usage: 0.027 seconds | |
| Preprocessor visited node count: 92/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 559/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:1062-0!canonical and timestamp 20250724011238 and revision id 138984. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b>ALPACA</b> is a meta-language designed by <a href="/wiki/Chris_Pressey" title="Chris Pressey">Chris Pressey</a> sometime around 1997-1999. The name stands for <i>A Language for Programming Arbitrary Cellular Automata</i>. | |
| </p><p>The primary motivation for ALPACA was to have a clean and concise notation in which to describe a successor to <a href="/wiki/RUBE" title="RUBE">RUBE</a>, namely <a href="/wiki/REDGREEN" title="REDGREEN">REDGREEN</a>. However, ALPACA is capable of describing many common <a href="/wiki/Cellular_automaton" title="Cellular automaton">cellular automata</a>. The rules for <a class="mw-redirect" href="/wiki/John_Conway" title="John Conway">John Conway</a>'s <a href="/wiki/Game_of_Life" title="Game of Life">Game of Life</a>, for instance, can be expressed as follows: | |
| </p> | |
| <pre>state Dead " " | |
| to Alive when 3 Alive and 5 Dead; | |
| state Alive "*" | |
| to Dead when 4 Alive or 7 Dead. | |
| </pre> | |
| <p>ALPACA is not, as its name implies, capable of describing truly arbitrary cellular automata; they must be at most 2-dimensional, and exist in a Cartesian geometry. It is, however, capable of describing 2-dimensional cellular automata with a Moore neighbourhood, or any neighbourhood which is a subset of the Moore neighbourhood. | |
| </p> | |
| <h2><span class="mw-headline" id="Computational_class">Computational class</span></h2> | |
| <p>ALPACA is a meta-language, and thus a direct classification of its computational power is impossible. It can, however, describe John Conway's Game of Life, which is known to be <a href="/wiki/Turing-complete" title="Turing-complete">Turing-complete</a>. It might be argued, therefore, that ALPACA is "<a href="/wiki/Meta_Turing-complete" title="Meta Turing-complete">meta Turing-complete</a>" (that is, able to describe Turing-complete systems.) | |
| </p><p>Also, any meta-language-plus-input is equivalent to a programming language. So a trivial extension to ALPACA which turns it into a <a href="/wiki/Matrioshka_language" title="Matrioshka language">Matrioshka language</a> (like <a href="/wiki/Thue" title="Thue">Thue</a> or <a href="/wiki/ODDBALL" title="ODDBALL">ODDBALL</a>) would be Turing-complete. | |
| </p> | |
| <h2><span class="mw-headline" id="See_also">See also</span></h2> | |
| <ul><li><a href="/wiki/RuleLoader" title="RuleLoader">Rule table</a></li></ul> | |
| <p><br/> | |
| </p> | |
| <h2><span class="mw-headline" id="External_resources">External resources</span></h2> | |
| <ul><li><a class="external text" href="https://catseye.tc/node/ALPACA" rel="nofollow">The ALPACA Meta-Language</a></li> | |
| <li><a class="external text" href="http://scienceblogs.com/goodmath/2006/10/20/a-metalanguage-for-pathologica-1" rel="nofollow">A Metalanguage for Pathological Programming: Cellular Automata in Alpaca</a></li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20250724000227 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [] | |
| CPU time usage: 0.010 seconds | |
| Real time usage: 0.011 seconds | |
| Preprocessor visited node count: 27/1000000 | |
| Post‐expand include size: 57/2097152 bytes | |
| Template argument size: 35/2097152 bytes | |
| Highest expansion depth: 3/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 1.135 1 Template:Catseye | |
| 100.00% 1.135 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:995-0!canonical and timestamp 20250724000227 and revision id 145806. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b>The Amnesiac From Minsk</b> is a series of <a href="/wiki/Esoteric_programming_language" title="Esoteric programming language">esoteric programming languages</a> designed by <a href="/wiki/User:Ais523" title="User:Ais523">User:ais523</a> towards the end of <a href="/wiki/Category:2015" title="Category:2015">2015</a>. They are arranged as a sequence of "difficulty levels"; higher-level languages are intended to be harder to program in (and lower-level languages can be seen as <a href="/wiki/Wimpmode" title="Wimpmode">wimpmodes</a> for the higher-level languages). <a href="/wiki/Minsky_machine" title="Minsky machine">Minsky machines</a> can be seen as a "level 0", or a wimpmode for the language as a whole, as they have a strict superset of its functionality. | |
| </p><p>In addition to the obvious <a href="/wiki/Minsky_machine" title="Minsky machine">Minsky machines</a>, inspirations for the language include <a href="/wiki/StackFlow" title="StackFlow">StackFlow</a> and <a href="/wiki/Unassignable" title="Unassignable">:≠</a>. It's also less directly inspired by <a href="/wiki/Three_Star_Programmer" title="Three Star Programmer">Three Star Programmer</a> and <a href="/wiki/MiniMAX" title="MiniMAX">MiniMAX</a>, via <a href="/wiki/Last_ReSort" title="Last ReSort">Last ReSort</a>. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#The_Amnesiac_From_Minsk,_level_1"><span class="tocnumber">1</span> <span class="toctext">The Amnesiac From Minsk, level 1</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-2"><a href="#Semantics"><span class="tocnumber">1.1</span> <span class="toctext">Semantics</span></a></li> | |
| <li class="toclevel-2 tocsection-3"><a href="#Syntax"><span class="tocnumber">1.2</span> <span class="toctext">Syntax</span></a></li> | |
| <li class="toclevel-2 tocsection-4"><a href="#Implementation_in_and_of_other_languages"><span class="tocnumber">1.3</span> <span class="toctext">Implementation in and of other languages</span></a></li> | |
| <li class="toclevel-2 tocsection-5"><a href="#Example_programs"><span class="tocnumber">1.4</span> <span class="toctext">Example programs</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-6"><a href="#The_Amnesiac_From_Minsk,_level_2"><span class="tocnumber">2</span> <span class="toctext">The Amnesiac From Minsk, level 2</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-7"><a href="#Semantics_2"><span class="tocnumber">2.1</span> <span class="toctext">Semantics</span></a></li> | |
| <li class="toclevel-2 tocsection-8"><a href="#Syntax_2"><span class="tocnumber">2.2</span> <span class="toctext">Syntax</span></a></li> | |
| <li class="toclevel-2 tocsection-9"><a href="#Implementing_level_1_in_level_2"><span class="tocnumber">2.3</span> <span class="toctext">Implementing level 1 in level 2</span></a></li> | |
| <li class="toclevel-2 tocsection-10"><a href="#Implementing_level_2_in_level_1"><span class="tocnumber">2.4</span> <span class="toctext">Implementing level 2 in level 1</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-11"><a href="#The_Amnesiac_From_Minsk,_level_3"><span class="tocnumber">3</span> <span class="toctext">The Amnesiac From Minsk, level 3</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-12"><a href="#Semantics_3"><span class="tocnumber">3.1</span> <span class="toctext">Semantics</span></a></li> | |
| <li class="toclevel-2 tocsection-13"><a href="#Syntax_3"><span class="tocnumber">3.2</span> <span class="toctext">Syntax</span></a></li> | |
| <li class="toclevel-2 tocsection-14"><a href="#Implementing_level_3_in_level_2"><span class="tocnumber">3.3</span> <span class="toctext">Implementing level 3 in level 2</span></a></li> | |
| <li class="toclevel-2 tocsection-15"><a href="#Turing-completeness_proof_for_level_3"><span class="tocnumber">3.4</span> <span class="toctext">Turing-completeness proof for level 3</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-16"><a href="#The_Amnesiac_From_Minsk,_level_4"><span class="tocnumber">4</span> <span class="toctext">The Amnesiac From Minsk, level 4</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-17"><a href="#Semantics_4"><span class="tocnumber">4.1</span> <span class="toctext">Semantics</span></a></li> | |
| <li class="toclevel-2 tocsection-18"><a href="#Syntax_4"><span class="tocnumber">4.2</span> <span class="toctext">Syntax</span></a></li> | |
| <li class="toclevel-2 tocsection-19"><a href="#Implementing_level_4_in_level_3"><span class="tocnumber">4.3</span> <span class="toctext">Implementing level 4 in level 3</span></a></li> | |
| <li class="toclevel-2 tocsection-20"><a href="#Implementation_in_Last_ReSort"><span class="tocnumber">4.4</span> <span class="toctext">Implementation in Last ReSort</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-21"><a href="#External_resources"><span class="tocnumber">5</span> <span class="toctext">External resources</span></a></li> | |
| <li class="toclevel-1 tocsection-22"><a href="#See_also"><span class="tocnumber">6</span> <span class="toctext">See also</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span id="The_Amnesiac_From_Minsk.2C_level_1"></span><span class="mw-headline" id="The_Amnesiac_From_Minsk,_level_1">The Amnesiac From Minsk, level 1</span></h2> | |
| <h3><span class="mw-headline" id="Semantics">Semantics</span></h3> | |
| <p>At level 1, a The Amnesiac From Minsk program consists of a set of counters, each of which is initialized to a value specified in the program. Each counter can hold an unbounded positive integer (i.e. 0 is not a valid value, so a counter will fail to decrement from 1). The other thing that the program specifies is a list of triggers for each counter: one that runs when the counter is incremented, one which runs when the counter is decremented successfully, and one which runs when a failing attempt is made to decrement the counter when it has a value of 1. | |
| </p><p>The triggers work in a very similar way to in :≠; when the counter is changed, the corresponding trigger will run immediately afterwards. Unlike in :≠, recursion is allowed, i.e. it's legal for a trigger on a counter to start a cascading chain of triggers that results in another change to that same counter. However, again unlike in :≠, the triggers are tail calls (and thus none of the usual state for tracking recursion is required to implement The Amnesiac From Minsk); the trigger does not return after it runs (or at any other time). Given that every possible change to a counter (and thus everything that you can do in the language) will trigger some trigger or other, this means that there's no point in the code for a trigger containing more than one command, as the first command will never return. (These rules are the same as those used for <code>pop</code> commands in StackFlow.) | |
| </p><p>The program halts if a counter is incremented, and the trigger for that increment causes the same counter to be incremented again. (At this point, it is clear that the program is incapable of making further progress.) Likewise, it halts if a counter fails to decrement from 1, and the trigger for that decrement causes an attempt to be made to decrement that same counter again. The implementation starts by incrementing the first counter, and allowing the program to run its course via triggers from there. | |
| </p><p>As an extension, if a program contains precisely two counters that are not decremented by any trigger, incrementing the one that appears earlier in the program will write a 0 bit to standard output, and incrementing the one that appears later in the program will write a 1 bit to standard output. In the common case where implementations write bits an octet at a time, they should write bits that appear earlier at the more significant end of the byte. | |
| </p> | |
| <h3><span class="mw-headline" id="Syntax">Syntax</span></h3> | |
| <p>Syntactically, the language looks like this: | |
| </p> | |
| <pre>L1 + = - | |
| 0: +1; +2; -1; @5 | |
| 1: -0; -2; -1; @9 This is a comment. | |
| 2: +0; +1; -0; @12 | |
| </pre> | |
| <p>Horizontal whitespace is insignificant anywhere, except that it's disallowed in the middle of a literal integer (although programmers are encouraged to make the columns line up); vertical whitespace is significant. The first line must consist of <code>L1+=-</code>, typically with whitespace added. Each subsequent line starts with a nonnegative integer (the counter number), in sequence starting at 0 and ascending from there. This is followed by the triggers for increment, failed decrement, successful decrement, separated by semicolons; then a semicolon, <code>@</code>, and the initial value for the counter. Anything beyond that is a comment, and should be ignored by implementations. The triggers themselves are expressed as <code>+</code> or <code>-</code> (for increment and for decrement attempt, respectively), followed by the number of the counter to affect. | |
| </p> | |
| <h3><span class="mw-headline" id="Implementation_in_and_of_other_languages">Implementation in and of other languages</span></h3> | |
| <p>A level 1 The Amnesiac From Minsk program is clearly a special case of a Minsky machine (specifically, one in which the program does not have to remember why it tried to increment or decrement a given counter, because all the information is provided with knowledge of what it's currently doing, thus "amnesiac"). | |
| </p><p>Slightly less obviously, but nonetheless with a pretty direct construction, you can compile any level 1 The Amnesiac From Minsk program into StackFlow via representing a counter as a stack with one distinguished symbol at the bottom (that re-pushes itself upon an attempt to pop it) and a different symbol for the other elements of the stack. The "successful decrement" and "failed decrement" triggers have exact analogues in StackFlow (the rules for the "not bottom of stack" and "bottom of stack" symbols for the stack that corresponds to the counter). The "increment" trigger does not directly have an analogue, but because a StackFlow rule can contain multiple <code>push</code> commands, it is possible to simply inline the trigger into every rule that increments the counter corresponding to the stack. | |
| </p><p>Going the other way, The Amnesiac From Minsk can be proved <a class="mw-redirect" href="/wiki/Turing_complete" title="Turing complete">Turing complete</a> at level 1 via implementing Minsky machines in it. The construction works like this: we treat the Minsky machine as a set of counters, plus a state machine that remembers what the system is currently doing. For each state of the state machine, we have a counter that is normally 1, but is 2 while that state is executing. These are connected in chains via failed-decrement triggers; thus attempting to decrement the first counter in a chain will set every counter in the chain to 1 and run the successful-decrement trigger for the current state (if that state is in the chain). | |
| </p><p>This gives a way to increment counters without losing state, using an "increment chain" for all states that do an increment: you increment the counter for the state, have its increment trigger increment the data counter you wanted to increment, have its increment trigger attempt to decrement the first counter in the increment chain, and have the successful-decrement trigger increment the counter for the next state, and so on. It can be seen by inspection that each trigger in the chain is only used for one purpose, meaning that we have no clashes and thus arbitrary increment behaviour will work. | |
| </p><p>For decrements, things are rather more complex; we can't use the same construction directly because a decrement has two possible results. Instead, we have two chains: "successful decrement" (which contains one element per decrementing state), and "failed decrement" (which also contains one element per decrementing state). Additionally, we have two separate counters, "success control" and "failure control", for each decrementing state. As with the implementation of increments, these are all 1 except when a decrement is in progress. You start a decrement via incrementing the "succesful decrement" element for the current state, which (via its increment trigger) increments the "failed decrement" element for the current state, which decrements the data counter in question. Its triggers then attempt to decrement the first element of either the "successful decrement" or "failed decrement" chain, depending on the success or failure of the decrement. | |
| </p><p>The failed-decrement triggers for these two chains are used to maintain the chain behaviour. The successful-decrement triggers for the "successful decrement" and "failed decrement" chains attempt to decrement the "failure control" or "success control" counter respectively for the state in question. Each of these counters will increment the other on a failed decrement, attempt to decrement the first element of the "succesful decrement" or "failed decrement" chain respectively on an increment, and move onto the next state (via incrementing an appropriate chain element to start its increment or decrement) on successful decrement. | |
| </p><p>Here's an example to show how this works, using a successful decrement in the third state in the chain: | |
| </p> | |
| <pre>s.dec chain f.dec chain s.control f.control | |
| 11111...111 11111...111 1 1 Before starting the decrement | |
| 11211...111 11111...111 1 1 Decrement starts from outside | |
| 11211...111 11211...111 1 1 After the first trigger | |
| --- Data counter decremented here, and decrements the s.dec chain --- | |
| 11111...111 11211...111 1 1 f.control fails to decrement | |
| 11111...111 11211...111 2 1 so it increments s.control | |
| 11111...111 11111...111 2 1 which decrements f.dec chain | |
| 11111...111 11111...111 1 1 s.control decrement succeeds | |
| </pre> | |
| <p>and now we're back where we started, but the "success control" decrement trigger runs and moves onto the next part of the program. Everything is symmetrical between success and failure, so if the decrement had failed instead, the example would be the same but with success and failure state swapped. | |
| </p> | |
| <h3><span class="mw-headline" id="Example_programs">Example programs</span></h3> | |
| <p>A <a class="mw-redirect" href="/wiki/Hello_world" title="Hello world">Hello world</a> program is available at <a href="/wiki/Hello_world_program_in_esoteric_languages_(T-Z)#The_Amnesiac_From_Minsk" title="Hello world program in esoteric languages (T-Z)">Hello world program in esoteric languages (T-Z)#The Amnesiac From Minsk</a>. | |
| </p> | |
| <h2><span id="The_Amnesiac_From_Minsk.2C_level_2"></span><span class="mw-headline" id="The_Amnesiac_From_Minsk,_level_2">The Amnesiac From Minsk, level 2</span></h2> | |
| <h3><span class="mw-headline" id="Semantics_2">Semantics</span></h3> | |
| <p>Level 2 works pretty similarly to level 1, with one big difference: instead of a decrement from 1 failing, it succeeds, decrementing the counter to 0. This is known as a "critical state" for the counter (in the sense that bad things can potentially happen very soon); if a counter that's currently at 0 is decremented again, you get <a class="mw-redirect" href="/wiki/Undefined_behaviour" title="Undefined behaviour">undefined behaviour</a>, a state which must be avoided in any valid program. The trigger in the <code>=</code> column has similar semantics as in level 1 – it runs on an attempt to decrement a counter at 1 – but is now called the "critical decrement" rather than "failed decrement" trigger (as the decrement didn't actually fail). (Fans of :≠ will be reminded of the way that that language works, in which you mustn't, say, attempt to disable a function that's already disabled. This language has quite a similar style.) | |
| </p> | |
| <h3><span class="mw-headline" id="Syntax_2">Syntax</span></h3> | |
| <p>The syntax for level 2 is entirely analogous for that at level 1; the semantic changes do not require any syntactic changes. The only difference is that the first line is | |
| <code>L2+=-</code> rather than <code>L1+=-</code>. | |
| </p> | |
| <h3><span class="mw-headline" id="Implementing_level_1_in_level_2">Implementing level 1 in level 2</span></h3> | |
| <p>Making a similar change to a Minsky machine would be trivial; after a critical decrement, you could just increment the counter again then continue what you were doing. It turns out that it's possible to do something similar in The Amnesiac From Minsk (although the construction is a bit more complex due to the absence of an instruction pointer). | |
| </p><p>The idea is to emulate each level 1 counter with a triple of level 2 counters, called "value", "restore", and "increment". While the counter is not being accessed, "value" holds the same value as the level 1 counter being emulated would, and the other two hold 1. The triggers are connected as follows: | |
| </p> | |
| <ul><li>"value" successful-decrement is the same as the emulated counter's successful-decrement trigger</li> | |
| <li>"value" critical-decrement increments "restore"</li> | |
| <li>"value" increment decrements "restore"</li> | |
| <li>"restore" successful-decrement is the same as the emulated counter's failed-decrement trigger</li> | |
| <li>"restore" critical-decrement increments "restore"</li> | |
| <li>"restore" increment decrements "increment"</li> | |
| <li>"increment" successful-decrement is the same as the emulated counter's increment trigger</li> | |
| <li>"increment" critical-decrement increments "increment"</li> | |
| <li>"increment" increment increments "value"</li></ul> | |
| <p>In order to emulate incrementing the counter, we increment "increment": | |
| </p> | |
| <pre>value restore increment | |
| x 1 1 Before starting the increment | |
| x 1 2 Increment starts from outside | |
| x+1 1 2 "value" incremented | |
| x+1 0 2 so it decrements "restore" | |
| x+1 1 2 which increments itself | |
| x+1 1 1 which decrements "increment" | |
| </pre> | |
| <p>and as that was a successful-decrement, we run the increment trigger, as desired. | |
| </p><p>To emulate decrementing the counter, we decrement "value". For a successful-decrement, this is trivial: it decrements successfully and the successful-decrement trigger runs. An emulated failed-decrement is more interesting: | |
| </p> | |
| <pre>value restore increment | |
| 1 1 1 Before starting the decrement | |
| 0 1 1 Decrement starts from outside | |
| 0 2 1 "restore" incremented | |
| 0 2 0 so it decrements "increment" | |
| 0 2 1 which increments itself | |
| 1 2 1 which increments "value" | |
| 1 1 1 which decrements "restore" | |
| </pre> | |
| <p>and now we're back where we started, continuing with the emulated failed-decrement trigger. Which is as we wanted. | |
| </p><p>Because The Amnesiac From Minsk is Turing complete at level 1, and we can compile level 1 into level 2, it's Turing complete at level 2 too. | |
| </p> | |
| <h3><span class="mw-headline" id="Implementing_level_2_in_level_1">Implementing level 2 in level 1</span></h3> | |
| <p>Going the other way is simpler, but not entirely trivial; incrementing a counter after a failed decrement leaves it in a different state from incrementing a counter after a critical decrement. The method we use is to construct signed counters out of pairs of unsigned counters; we have a "positive" and a "negative" counter, with triggers as follows: | |
| </p> | |
| <ul><li>"positive" failed-decrement increments "negative"</li> | |
| <li>"negative" failed-decrement increments "positive"</li> | |
| <li>"positive" successful-decrement is the same as the emulated counter's successful-decrement trigger (because it runs on decrements from 2 or more to 1 or more)</li> | |
| <li>"negative" increment is the same as the emulated counter's critical-decrement trigger (because it runs on decrements from 1 or less to 0 or less)</li> | |
| <li>"positive" increment is the same as the emulated counter's increment trigger (and runs on increments from 1 or more to 2 or more)</li> | |
| <li>"negative" successful-decrement is the same as the emulated counter's increment trigger (and runs on increments from 0 or less to 1 or less)</li></ul> | |
| <p>The two counters effectively encode a single integer, whose value is (positive - negative) + 1, which gives all the behaviour that level 2 needs (while potentially useful for other purposes, too, as the "undefined" behaviour of decrementing a critical trigger is both well-defined and useful in this construction). | |
| </p> | |
| <h2><span id="The_Amnesiac_From_Minsk.2C_level_3"></span><span class="mw-headline" id="The_Amnesiac_From_Minsk,_level_3">The Amnesiac From Minsk, level 3</span></h2> | |
| <h3><span class="mw-headline" id="Semantics_3">Semantics</span></h3> | |
| <p>Unlike levels 1 and 2, in which only one counter is incremented or decremented at a time, a counter adjustment in the level 3 language affects two counters at once. Specifically, incrementing counter <i>x</i> decrements counter <i>x</i>+1, and a decrement cannot be made except via incrementing the previous counter. (The exception is incrementing the last counter; this doesn't cause a counter to be decremented.) The implementation starts running the program via incrementing the first counter, as before, but it now also has the side effect of decrementing the second counter. The first counter starts at 1, and can only go up from there (because there is no way to decrement it). | |
| </p><p>The language otherwise works like the level 2 language; decrementing a counter at 1 is a critical decrement, and that counter thus must not be decremented (and thus the previous counter must not be incremented) until the counter has been restored to a positive value. With the previous-level languages, this would cause problems, as two triggers would run as a result of the two changes. Level 3 does not use increment triggers, just decrement triggers; as a result, you get a successful-decrement or critical-decrement trigger running for the counter that was decremented. Again, the last counter is an exception, and does have an increment trigger, which runs when the last counter is incremented (as no counter is decremented in this case). | |
| </p><p>The I/O (well, output) extension explained above doesn't really work at this level. At present, there's no defined replacement for it, although perhaps one will be added at some point. | |
| </p> | |
| <h3><span class="mw-headline" id="Syntax_3">Syntax</span></h3> | |
| <p>Syntax is basically the same as with levels 1 and 2, but with the increment triggers removed, and with only the increment half of an adjustment shown (and the first line changed to <code>L3=-</code>): | |
| </p> | |
| <pre>L3 = - | |
| 1: +2; +1; @5 | |
| 2: +0; +3; @9 This is a comment. | |
| 3: +1; +0; @12 | |
| +: +1 | |
| </pre> | |
| <p>As can be seen, the last line starts with <code>+:</code> and has a single trigger specified, which is the increment trigger for the last counter. Note also that the first row is labeled <code>1:</code>; the counter numbers still start at 0, but as counter 0 cannot be decremented, there's correspondingly no point in specifying decrement triggers for it. | |
| </p> | |
| <h3><span class="mw-headline" id="Implementing_level_3_in_level_2">Implementing level 3 in level 2</span></h3> | |
| <p>This is pretty trivial; you can use the same counters in level 2 as in level 3, and just have the increment trigger of each counter (but the last) decrement the following counter. As such, level 3 can be seen as a strict subset of level 2; it's level 2 with the additional constraint that all but the last increment trigger has to have a specified value. | |
| </p> | |
| <h3><span class="mw-headline" id="Turing-completeness_proof_for_level_3">Turing-completeness proof for level 3</span></h3> | |
| <p>The Amnesiac From Minsk level 3 is <a class="mw-redirect" href="/wiki/Turing_complete" title="Turing complete">Turing complete</a>. This proof proves this not via use of level 2, but rather by compiling programs from <a href="/wiki/The_Waterfall_Model" title="The Waterfall Model">The Waterfall Model</a> into it. | |
| </p><p>Each waterclock from The Waterfall Model is represented using the following, consecutively numbered, TAFM counters: | |
| </p> | |
| <ul><li>a "padding counter" – this has an arbitrary value which is maintained to always be sufficiently large (i.e. it is not allowed to go near 0)</li> | |
| <li>some number of "decrement control counters", which normally have the value 1</li> | |
| <li>a "value counter", which holds the value of the waterclock</li> | |
| <li>some number of "increment control counters", which normally have the value 1</li></ul> | |
| <p>These are then concatenated to form the set of all counters (i.e. the last increment control counter of one waterclock is followed by the padding counter of the next waterclock). Counter 0 is the first padding counter, and its automatic starting value of 1 is sufficiently large (because it can never be decremented). | |
| </p><p>Control counters are chained together as follows: a critical decrement of a control counter causes that counter to immediately be incremented again (thus decrementing the next counter). On a successful decrement of a value counter, the corresponding padding counter is incremented (thus decrementing the first decrement control counter). On a successful decrement of a padding counter (which can't happen to the first waterclock's padding counter, only with subsequent waterclocks), the preceding waterclock's value counter is incremented; likewise, if the last counter is incremented, the last waterclock's value counter is incremented. This mechanism means that incrementing any of a waterclock's control counters will cause that waterclock to be incremented or decremented (depending on what sort of control counter it is), and in most cases restore the value of all the control counters to 1. Incrementing a waterclock will decrement the next waterclock's padding counter, and decrementing a waterclock will increase that waterclock's padding counter. | |
| </p><p>A successful (rather than critical) decrement of a control counter indicates that this is the counter that was incremented (in order to cause the increment or decrement of the waterclock). This effectively allows for sequencing of commands in a way similar to regular Minsky machines: to create a sequence of, e.g., "increment waterclock 2 twice then waterclock 3", you can choose a sequence of two increment control counters from waterclock 2 and one from waterclock 3, then cause the successful-decrement trigger of each counter in the sequence to increment the next counter in the sequence. | |
| </p><p>It then becomes easy to implement one instance of the steady decrement from The Waterfall Model: You just create a linked sequence of commands that decrements each waterclock in turn (the program starts here, as the first decrement is made to the second counter, which is a decrement control counter for the first waterclock). After this steady decrement comes a padding routine, which for each waterclock <i>n</i> in reverse order (i.e. starting with the highest-numbered), increments and decrements that waterclock <i>kn</i> times for some sufficiently large constant <i>k</i>. This has no net effect on the waterclock's value, but will increase the value of all the padding counters by <i>k</i> (because they're incremented <i>kn</i> times and then decremented <i>k</i>(<i>n</i>-1) times). Once the padding routine finishes, it returns to the start of the steady decrement routine, thus causing the decrement to be repeated forever for the lifetime of the program. | |
| </p><p>The one remaining case is implementing the zeroing triggers. This is done using the critical-decrement triggers of the value counters; these start a separate sequence of commands that increment waterclocks (i.e. the value counter's critical-decrement trigger is linked to an increment control counter, its successful-decrement trigger is linked to another increment control counter, and so on, until all the waterclocks have been increased by the appropriate amounts). The end of this chain increments the corresponding padding counter (just as the successful-decrement trigger of a value counter does), thus restoring things to the same state they would have been on a successful decrement (except for all the incrementation of the waterclocks' values in the meantime). Although a control counter will have the "wrong" value during this sequence (i.e. we aren't obeying the normal rule that control counters usually have the value 1), that control counter will necessarily be a <i>decrement</i> control counter, whereas only <i>increment</i> control counters are adjusted by this sequence, so the chain of increments will still work normally. | |
| </p><p>It is clear that there's a limit to how much the padding counters can shrink in each steady-decrement cycle (because each zeroing trigger will shrink each of them by at most some fixed finite amount), which means that it's always possible to choose <i>k</i> such that the padding counters will always have a net increase every cycle. Starting each padding counter at <i>k</i> will then ensure that the padding counters never zero. (As such, the critical-decrement triggers for padding counters are arbitrary and do not matter.) | |
| </p> | |
| <h2><span id="The_Amnesiac_From_Minsk.2C_level_4"></span><span class="mw-headline" id="The_Amnesiac_From_Minsk,_level_4">The Amnesiac From Minsk, level 4</span></h2> | |
| <h3><span class="mw-headline" id="Semantics_4">Semantics</span></h3> | |
| <p>Level 4 of The Amnesiac From Minsk is similar to level 3, but with different behaviour for the triggers, and a restriction on the counters as well. The restriction on the counters is that you may never have two critical counters in a row (attempting to create such a situation is undefined behaviour); as with level 3, the first counter always starts at 1 and can only go up from there (although the last counter can go down to 0). As for the triggers, each counter has but a single trigger; the result of the decrement determines which counter's trigger runs: | |
| </p> | |
| <ul><li>If, in an increment/decrement pair, the decrement is critical, then the trigger for the decremented counter runs.</li> | |
| <li>Otherwise, the trigger for the incremented counter runs.</li></ul> | |
| <p>As an extra rule (that's part of the language definition, in order to make the language easier to implement, but which would nonetheless be obeyed by any useful program even if it didn't exist because otherwise some counters couldn't change both up and down), all the triggers that exist must be distinct (i.e. increment different counters). | |
| </p> | |
| <h3><span class="mw-headline" id="Syntax_4">Syntax</span></h3> | |
| <p>Syntax works as in previous levels, with the same sorts of changes; the first line is now <code>L4?</code>, and each line only lists one trigger. There are no longer special cases for the first and last lines. Thus, the language looks like this: | |
| </p> | |
| <pre>L4 ? | |
| 0: +2; @1 | |
| 1: +0; @9 This is a comment. | |
| 2: +1; @12 | |
| 3: +3; @5 | |
| </pre> | |
| <h3><span class="mw-headline" id="Implementing_level_4_in_level_3">Implementing level 4 in level 3</span></h3> | |
| <p>Just like implementing level 3 in level 2, this is trivial; you simply copy each of the triggers from the level 4 program into the two corresponding triggers in the level 3 program (apart from the first trigger, which has only one corresponding trigger (the successful-decrement trigger for the second counter) and thus only gets copied to one place). | |
| </p><p>It's currently unknown whether it's possible to go the other way, and implement level 3 in level 4. | |
| </p> | |
| <h3><span class="mw-headline" id="Implementation_in_Last_ReSort">Implementation in Last ReSort</span></h3> | |
| <p>To implement The Amnesiac From Minsk level 4 in <a href="/wiki/Last_ReSort" title="Last ReSort">Last ReSort</a>, we first construct a list of integers from the list of counters by taking a cumulative sum of the initial values of the counters. So for example, if the initial values were (in order) 1, 7, 0, 4, 2, our cumulative sum would be 1, 8, 8, 12, 14. Then we permute the list according to the list of triggers; the element corresponding to the target of the trigger of the last counter comes first, the element corresponding to the target of the trigger of the penultimate counter counter comes second, and so on. The initial pointer points to the element that was permuted from the element corresponding to the first counter (which will always have the value 1). | |
| </p><p>Taking our example from above: | |
| </p> | |
| <pre>L4 ? | |
| 0: +2; @1 | |
| 1: +0; @9 This is a comment. | |
| 2: +1; @12 | |
| 3: +3; @5 | |
| </pre> | |
| <p>we get a list [1, 10, 22, 27], which would then be reordered as [27, 10, 1, 22] to provide the Last ReSort program, with the initial pointer pointing to the third element. | |
| </p><p>In order to see how this construction works, consider what one Last ReSort step is doing, when interpreted through the lens of this construction: | |
| </p> | |
| <ul><li>The increment is adding 1 to a single cumulative sum element. This corresponds to incrementing the accumulated element that was added at that point and decrementing the next element (which is exactly how memory changes in The Amnesiac From Minsk level 4).</li> | |
| <li>The retargeting is selecting an element. If the list of cumulative sums were strictly in order (i.e. we accumulated only positive values), then the element that would be selected is the nth from the end, if we incremented counter n (which is exactly the element that's the target of the decremented counter). The only way in which it can fail to be in strict order is if we decremented a counter down to 0, causing its cumulative sum to equal that of the counter afterwards and thus cause the pointer to point at the element before as a consequence of Last Resort's tiebreak rules (corresponding to using the target from the counter afterwards). Note that a three-way tie, which would cause problems, cannot happen because we disallow having two critical counters in a row.</li></ul> | |
| <p>In other words, the two languages are doing the same thing. | |
| </p> | |
| <h2><span class="mw-headline" id="External_resources">External resources</span></h2> | |
| <ul><li><a class="external text" href="https://github.com/pavelbraginskiy/TheAmnesiacFromMinsk" rel="nofollow">Interpreter for level 1 and level 2, including I/O</a></li></ul> | |
| <h2><span class="mw-headline" id="See_also">See also</span></h2> | |
| <ul><li><a href="/wiki/Minsky_machine" title="Minsky machine">Minsky machine</a></li> | |
| <li><a href="/wiki/StackFlow" title="StackFlow">StackFlow</a></li> | |
| <li><a href="/wiki/Unassignable" title="Unassignable">:≠</a></li> | |
| <li><a href="/wiki/Last_ReSort" title="Last ReSort">Last ReSort</a></li> | |
| <li><a href="/wiki/The_Waterfall_Model" title="The Waterfall Model">The Waterfall Model</a></li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20260116095055 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.020 seconds | |
| Real time usage: 0.030 seconds | |
| Preprocessor visited node count: 84/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:10083-0!canonical and timestamp 20260116095055 and revision id 173298. Rendering was triggered because: edit-page | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b>A Queue which can't grow</b> (<b>AQWCG</b>) is an esolang by <a href="/wiki/User:ChuckEsoteric08" title="User:ChuckEsoteric08">User:ChuckEsoteric08</a>. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Specification"><span class="tocnumber">1</span> <span class="toctext">Specification</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Examples"><span class="tocnumber">2</span> <span class="toctext">Examples</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-3"><a href="#Counter"><span class="tocnumber">2.1</span> <span class="toctext">Counter</span></a></li> | |
| <li class="toclevel-2 tocsection-4"><a href="#Adder"><span class="tocnumber">2.2</span> <span class="toctext">Adder</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-5"><a href="#Computational_class"><span class="tocnumber">3</span> <span class="toctext">Computational class</span></a></li> | |
| <li class="toclevel-1 tocsection-6"><a href="#Interpreter"><span class="tocnumber">4</span> <span class="toctext">Interpreter</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Specification">Specification</span></h2> | |
| <p><b>A Queue which can't grow</b> uses a queue of integers to store data. Its initial state is set to user input with elements being seperated by ;<br/>There are only two (three counting \ which is a nop) commands: | |
| </p> | |
| <pre>| | |
| </pre> | |
| <p>Which dequeues element, increments it, and enqueues result | |
| </p> | |
| <pre>/ | |
| </pre> | |
| <p>Which dequeues element, If it's nonzero decrements it, and enqueues result. If it's zero it would enqueue zero and jump forward to matching <code>\</code><br/>Program never halts. | |
| </p><p>We could also define language so that it would use tape instead of queue: | |
| </p> | |
| <pre>| | |
| </pre> | |
| <p>Increments cell and moves right | |
| </p> | |
| <pre>/ | |
| </pre> | |
| <p>If current cell is nonzero decrement it, and moves right. If it's zero it would move right and jump forward to matching <code>\</code> | |
| </p> | |
| <h2><span class="mw-headline" id="Examples">Examples</span></h2> | |
| <h3><span class="mw-headline" id="Counter">Counter</span></h3> | |
| <p>This counter program simply increments all of the user inputs in a perpetual manner: | |
| </p> | |
| <pre>| | |
| </pre> | |
| <h3><span class="mw-headline" id="Adder">Adder</span></h3> | |
| <p>The following program expects two numbers, incrementing the second by the first one's value, and repeating the process by a reversal of the roles: | |
| </p> | |
| <pre>/|\ | |
| </pre> | |
| <h2><span class="mw-headline" id="Computational_class">Computational class</span></h2> | |
| <p><b>AQWCG</b> is <a href="/wiki/Turing-complete" title="Turing-complete">Turing-complete</a> because it's possible to translate Minsky machines to it. For simplicity we would use notation where x is length of a Queue and (commands:x) would execute commands x times.We could define command INC2 which would move left and increment cell: | |
| </p> | |
| <pre>INC2 = (|:x)(/\:x-1) | |
| </pre> | |
| <p>DEC2 would decrement instead: | |
| </p> | |
| <pre>DEC2 = (|:x-1)(/\:x) | |
| </pre> | |
| <p>SKIP code ENDSKIP would execute code if cell is nonzero. Note that code should end with pointer pointing to the same cell. | |
| </p> | |
| <pre>SKIP code = / INC2 code | | |
| ENDSKIP = \ DEC2 | |
| </pre> | |
| <p>It's enough commands to compile Minsky machine to it. Queue is initialised as 0 followed by initial values of Minsky machine registers. That 0 is used as Instruction pointer for Minsky machine program. | |
| </p> | |
| <h2><span class="mw-headline" id="Interpreter">Interpreter</span></h2> | |
| <ul><li><a class="external text" href="https://github.com/KavehYousefi/Esoteric-programming-languages/tree/main/A%20Queue%20which%20can't%20grow" rel="nofollow">Common Lisp</a> implementation of the A Queue which can't grow programming language.</li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20250724080757 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.007 seconds | |
| Real time usage: 0.007 seconds | |
| Preprocessor visited node count: 20/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:17050-0!canonical and timestamp 20250724080757 and revision id 120130. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p>By Aaron Janse | |
| </p><p><b>AsciiDots</b> is an esoteric programming language based on ascii art. In this language, <i>dots</i>, represented by periods (<code>.</code>), travel down ascii art paths and undergo operations. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Program_Syntax"><span class="tocnumber">1</span> <span class="toctext">Program Syntax</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-2"><a href="#Basics"><span class="tocnumber">1.1</span> <span class="toctext">Basics</span></a></li> | |
| <li class="toclevel-2 tocsection-3"><a href="#Starting_a_program"><span class="tocnumber">1.2</span> <span class="toctext">Starting a program</span></a></li> | |
| <li class="toclevel-2 tocsection-4"><a href="#Ending_a_program"><span class="tocnumber">1.3</span> <span class="toctext">Ending a program</span></a></li> | |
| <li class="toclevel-2 tocsection-5"><a href="#Comments"><span class="tocnumber">1.4</span> <span class="toctext">Comments</span></a></li> | |
| <li class="toclevel-2 tocsection-6"><a href="#Paths"><span class="tocnumber">1.5</span> <span class="toctext">Paths</span></a> | |
| <ul> | |
| <li class="toclevel-3 tocsection-7"><a href="#Special_Paths"><span class="tocnumber">1.5.1</span> <span class="toctext">Special Paths</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-2 tocsection-8"><a href="#Addresses_and_Values"><span class="tocnumber">1.6</span> <span class="toctext">Addresses and Values</span></a></li> | |
| <li class="toclevel-2 tocsection-9"><a href="#Interactive_Console"><span class="tocnumber">1.7</span> <span class="toctext">Interactive Console</span></a></li> | |
| <li class="toclevel-2 tocsection-10"><a href="#Control_Flow"><span class="tocnumber">1.8</span> <span class="toctext">Control Flow</span></a></li> | |
| <li class="toclevel-2 tocsection-11"><a href="#Operations"><span class="tocnumber">1.9</span> <span class="toctext">Operations</span></a></li> | |
| <li class="toclevel-2 tocsection-12"><a href="#Warps"><span class="tocnumber">1.10</span> <span class="toctext">Warps</span></a></li> | |
| <li class="toclevel-2 tocsection-13"><a href="#Libraries"><span class="tocnumber">1.11</span> <span class="toctext">Libraries</span></a> | |
| <ul> | |
| <li class="toclevel-3 tocsection-14"><a href="#Using_Libraries"><span class="tocnumber">1.11.1</span> <span class="toctext">Using Libraries</span></a></li> | |
| <li class="toclevel-3 tocsection-15"><a href="#Creating_Libraries"><span class="tocnumber">1.11.2</span> <span class="toctext">Creating Libraries</span></a></li> | |
| </ul> | |
| </li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-16"><a href="#Interpretation"><span class="tocnumber">2</span> <span class="toctext">Interpretation</span></a></li> | |
| <li class="toclevel-1 tocsection-17"><a href="#Examples"><span class="tocnumber">3</span> <span class="toctext">Examples</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-18"><a href="#Hello,_World!"><span class="tocnumber">3.1</span> <span class="toctext">Hello, World!</span></a></li> | |
| <li class="toclevel-2 tocsection-19"><a href="#Counter"><span class="tocnumber">3.2</span> <span class="toctext">Counter</span></a></li> | |
| <li class="toclevel-2 tocsection-20"><a href="#Find_prime_numbers"><span class="tocnumber">3.3</span> <span class="toctext">Find prime numbers</span></a></li> | |
| <li class="toclevel-2 tocsection-21"><a href="#Print_the_Fibonacci_Sequence"><span class="tocnumber">3.4</span> <span class="toctext">Print the Fibonacci Sequence</span></a></li> | |
| <li class="toclevel-2 tocsection-22"><a href="#Print_powers_of_2"><span class="tocnumber">3.5</span> <span class="toctext">Print powers of 2</span></a></li> | |
| <li class="toclevel-2 tocsection-23"><a href="#Game"><span class="tocnumber">3.6</span> <span class="toctext">Game</span></a></li> | |
| <li class="toclevel-2 tocsection-24"><a href="#Quine"><span class="tocnumber">3.7</span> <span class="toctext">Quine</span></a></li> | |
| <li class="toclevel-2 tocsection-25"><a href="#Semi-compact_factorial_calculator"><span class="tocnumber">3.8</span> <span class="toctext">Semi-compact factorial calculator</span></a></li> | |
| <li class="toclevel-2 tocsection-26"><a href="#Code-golfed_counter_(15_bytes)"><span class="tocnumber">3.9</span> <span class="toctext">Code-golfed counter (15 bytes)</span></a></li> | |
| <li class="toclevel-2 tocsection-27"><a href="#W110"><span class="tocnumber">3.10</span> <span class="toctext">W110</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-28"><a href="#Implementation"><span class="tocnumber">4</span> <span class="toctext">Implementation</span></a></li> | |
| <li class="toclevel-1 tocsection-29"><a href="#External_Resources"><span class="tocnumber">5</span> <span class="toctext">External Resources</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Program_Syntax">Program Syntax</span></h2> | |
| <h3><span class="mw-headline" id="Basics">Basics</span></h3> | |
| <h3><span class="mw-headline" id="Starting_a_program">Starting a program</span></h3> | |
| <p><code>.</code> (a period), or <code>•</code> (a bullet symbol), signifies the starting location of a <i>dot</i>, the name for this language's information-carrying unit. Each dot is initialized with both an <a href="#addresses-and-values">address and value</a> of <code>0</code>. | |
| </p> | |
| <h3><span class="mw-headline" id="Ending_a_program">Ending a program</span></h3> | |
| <p>Interpretation of a dots program ends when a dot passes over an <code>&</code>. It also ends when all dots die (i.e. they all pass over the end of a path into nothingness) | |
| </p> | |
| <h3><span class="mw-headline" id="Comments">Comments</span></h3> | |
| <p>Everything after <code>``</code> (two back ticks) is a comment and is ignored by the interpreter | |
| </p> | |
| <h3><span class="mw-headline" id="Paths">Paths</span></h3> | |
| <p><code>|</code> (vertical pipe symbol) is a vertical path that dots travel along<br/> <code>-</code> is a horizontal path that dots travel along | |
| </p><p><i>Note</i>: Only one path should be adjacent to a starting dot location, so that there is no question where it should go | |
| </p><p>Here's an example program that just starts then ends (note that programs aren't always written and run top-to-bottom): | |
| </p> | |
| <pre>. `` This is where the program starts | |
| | `` The dot travels downwards | |
| | `` Keep on going! | |
| & `` The program ends</pre> | |
| <p>Think as these two paths as mirrors:<br/> <code>/</code><br/> <code>\</code> | |
| </p><p>So... here's a more complex program demonstrating the use of paths (it still just starts then ends): | |
| </p> | |
| <pre> | |
| /-& `` This is where the program ends! | |
| | | |
| \-\ /-\ | |
| | | | | |
| /-/ | \-\ | |
| \---/ | | |
| | | |
| \-. `` Here's where the program starts</pre> | |
| <h4><span class="mw-headline" id="Special_Paths">Special Paths</span></h4> | |
| <p><code>+</code> is the crossing of paths (they do not interact) | |
| </p><p><code>></code> acts like a regular, 2-way, horizontal, path, except dots can be inserted into the path from the bottom or the top. Those dots will go to the right<br/> <code><</code> does likewise except new dots go to the left<br/> <code>^</code> (caret) does this but upwards<br/> <code>v</code> (the lowercase letter 'v') does likewise but downwards | |
| </p><p>Here's a way to bounce a dot backwards along its original path using these symbols: | |
| </p> | |
| <pre>/->-- `` Input/output comes through here | |
| | | | |
| \-/</pre> | |
| <p>But there is an easier way to do that: | |
| </p><p><code>(</code> reflects a dot backwards along its original path. It accepts dot coming from the left, and lets them pass through to the right<br/> <code>)</code> does likewise but for the opposite direction | |
| </p><p><code>*</code> duplicates a dot and distributes copies including the original dot to all attached paths except the origin of dot | |
| </p><p>Here's a fun example of using these special paths. Don't worry—we'll soon be able to do more than just start then end a program. | |
| </p> | |
| <pre> /-\ /-& `` End | |
| | | | | |
| \-+-v | |
| | | /-\ | |
| (-<-/ | | | | |
| | \-<-/ | |
| \-\ | |
| | | |
| . `` Start</pre> | |
| <h3><span class="mw-headline" id="Addresses_and_Values">Addresses and Values</span></h3> | |
| <p><code>@</code> sets the address to the value after it following the direction of the line<br/> <code>#</code> does the same except it sets the value | |
| </p> | |
| <h3><span class="mw-headline" id="Interactive_Console">Interactive Console</span></h3> | |
| <p><code>$</code> is the output console. If there are single/double quotation marks (<code>'</code> or <code>"</code>), it outputs the text after it until there are closing quotation marks. <code>#</code> and <code>@</code> are substituted with the dot's value and address, respectively<br/> When <code>_</code> follows a <code>$</code>, the program does not end printing with a <a class="external text" href="https://en.wikipedia.org/wiki/Newline" rel="nofollow">newline</a>.<br/> When not in quotes, if a <code>a</code> comes before a <code>#</code> or <code>@</code> symbol, the value is converted to ascii before it is printed | |
| </p><p>Here's how to set and then print a dot's value: | |
| </p> | |
| <pre> . `` This dot is the data carrier | |
| | `` Travel along these vertical paths | |
| # `` Set the value... | |
| 3 `` ... to 3 | |
| | `` Continue down the path | |
| $ `` Output to the console... | |
| # `` ... the dot's value</pre> | |
| <p>Here's our hello world again: | |
| </p> | |
| <pre>.-$"Hello, World!"</pre> | |
| <p>Here's how to print that character 'h' without a newline: | |
| </p> | |
| <pre>.-$_"h"</pre> | |
| <p>And this prints '%' using the ascii code 37: | |
| </p> | |
| <pre>.-#37-$a#</pre> | |
| <p><code>?</code> is input from the console. It prompts the user for a value, and pauses until a value is entered in. It only runs after a <code>#</code> or <code>@</code> symbol<br/> | |
| </p> | |
| <pre> . `` Start | |
| | | |
| # `` Get ready to set the value | |
| ? `` Prompt the user | |
| | | |
| $ | |
| # `` Print that value to the console | |
| `` Since the only dot goes off the end of the path, it dies. Since no dots are left, the program ends</pre> | |
| <h3><span class="mw-headline" id="Control_Flow">Control Flow</span></h3> | |
| <p><code>~</code> (tilde) redirects dots going through it horizontally to the upward path if a dot waiting at the bottom has a value <i>not</i> equal to than <code>0</code>. Otherwise, the dot continues horizontally. If an exclamation point (<code>!</code>) is under it, then it redirects the dot upwards only if the value of the dot waiting <i>is</i> equal to zero.<br/> <code>!</code> acts like a pipe. Special function described above | |
| </p><p>This example prompts for a value then prints to the console whether the user provided value is equal to zero: | |
| </p> | |
| <pre> /-$"The value is not equal to zero" | |
| | | |
| .-~-$"The value is equal to zero" | |
| | | |
| ? | |
| # | |
| | | |
| .</pre> | |
| <h3><span class="mw-headline" id="Operations">Operations</span></h3> | |
| <p><code>[*]</code> multiplies the value that passes through vertically by the value that runs into it horizontally. When a dot arrive here, it waits for another dot to arrive from a perpendicular direction. When that dot arrives, the dot that arrived from the top or bottom has its value updated and it continues through the opposite side. The dot that passed through horizontally is deleted.<br/> <code>{*}</code> does likewise except it multiplies the value that enters horizontally by the value that enters vertically. The resulting dot exits horizontally<br/> | |
| </p><p>Other operations work similarly but with a different symbol in the middle. This is the key to these symbols:<br/> <code>*</code>: multiplication<br/> <code>/</code>: division<br/> <code>÷</code>: also division<br/> <code>+</code>: addition<br/> <code>-</code>: subtraction<br/> <code>%</code>: modulus<br/> <code>^</code>: exponent<br/> <code>&</code>: boolean AND<br/> <code>!</code>: boolean NOT<br/> <code>o</code>: boolean OR<br/> <code>x</code>: boolean XOR<br/> <code>></code>: greater than<br/> <code>≥</code>: greater than or equal to<br/> <code><</code>: less than<br/> <code>≤</code>: less than or equal to<br/> <code>=</code>: equal to<br/> <code>≠</code>: not equal to<br/> | |
| </p><p>Boolean operations return a dot with a value of <code>1</code> if the expression evaluates to true and <code>0</code> if false. | |
| </p><p>These characters are only considered operators when located within brackets. When outside of brackets, symbols like <code>*</code> perform their regular functions as described earlier. | |
| </p><p>Example: | |
| </p> | |
| <pre>`` Simple subtraction: | |
| `` (3 - 2 = 1) | |
| # | |
| $ | |
| | | |
| [-]-2#-. | |
| | | |
| 3 | |
| # | |
| | | |
| .</pre> | |
| <p>Add two user inputted values together then output the sum: | |
| </p> | |
| <pre>.-#?-{+}-$# | |
| | | |
| .-#?--/</pre> | |
| <h3><span class="mw-headline" id="Warps">Warps</span></h3> | |
| <p>A warp is a character that teleports, or 'warps', a dot to the other occurrence of the same letter in the program. | |
| </p><p>Define warps at the beginning of the file by listing them after a <code>%$</code>. The <code>%$</code> must be at the beginning of the line. | |
| </p><p>Example: | |
| </p> | |
| <pre>%$A | |
| .-#9-A `` Create a dot, set its value to 9, then warp it | |
| A-$# `` Print the dot's value (9)</pre> | |
| <p>Here's a fun example of using warps (although it is not very useful in this case) | |
| </p> | |
| <pre>%$A | |
| # /-) | |
| $ | | |
| \>-A | |
| \-3#-. | |
| A-\ | |
| \-/ | |
| </pre> | |
| <h3><span class="mw-headline" id="Libraries">Libraries</span></h3> | |
| <p>Dots supports libraries! A library is a program that defines a character (usually a letter). | |
| </p> | |
| <h5><span class="mw-headline" id="Using_Libraries">Using Libraries</span></h5> | |
| <p>A library can be imported by starting a line with <code>%!</code>, followed with the file name, followed with a single space and then the character that the library defines. | |
| </p><p>By default, all copies of the character lead to the same (<a class="external text" href="https://en.wikipedia.org/wiki/Singleton_pattern" rel="nofollow">singleton</a>) library code. This can cause some unexpected behavior if the library returns an old dot, since that old dot will come out of the char that <i>it</i> came from. | |
| </p><p>Here's an example of importing the standard <code>for_in_range</code> library (located in the <code>libs</code> folder) as the character <code>f</code>: | |
| </p> | |
| <pre>%!for_in_range.dots f</pre> | |
| <p>The way to use a library varies. Inputs and outputs of the library are through the alias character. | |
| </p><p>For the <code>for_in_range</code> library, the inputs are defined as follows: The dot coming from the <b>left</b> side sets the starting value of the counter. The dot coming from the <b>right</b> side sets the end value of the counter. | |
| </p><p>And the outputs are as follows: A dot for each number within the range defined by the inputs is output from the <b>top</b>. When the loop is complete (the end value has been reached), a dot is output from the <b>bottom</b>. | |
| </p><p>Here is an example of outputting all the numbers between <code>1</code> and <code>100</code> to the console, then stopping the program: | |
| </p> | |
| <pre>%!for_in_range.dots f | |
| # | |
| $ | |
| | | |
| .-*-#1---f-\ | |
| \-#100-+-/ | |
| | | |
| &</pre> | |
| <h5><span class="mw-headline" id="Creating_Libraries">Creating Libraries</span></h5> | |
| <p>Each library defines a character that will act as a warp to & from the library. | |
| </p><p>That can be done like so: | |
| </p> | |
| <pre>%^X `` X could be replaced with a different character, if so desired</pre> | |
| <p>It is recommended that you create warps for different sides of the char. Just look at the example code for the <code>val_to_addr.dots</code> library: | |
| </p><p><br/> | |
| Here's the code for a library that accepts a dot coming from the left, sets its value to its address, and then outputs it to the right: | |
| </p> | |
| <pre>%^X | |
| %$AB | |
| B-X-A | |
| A-*----@{+}-#0-B | |
| | | | |
| \------/</pre> | |
| <h2><span class="mw-headline" id="Interpretation">Interpretation</span></h2> | |
| <p>Each tick, the dots will travel along the lines until they hit a character that acts as a function of multiple dots (i.e. an operation character or a <code>~</code> character). The dot will stop if it goes on a path that it has already traversed in the same tick | |
| </p><p>Due to the fact that dots may be moving backwards down a line, if a number or system value (e.g. <code>?</code>) is seen without a preceding <code>@</code> or <code>#</code>, it will be ignored, along with any <code>@</code> or <code>#</code> immediately thereafter | |
| </p> | |
| <h2><span class="mw-headline" id="Examples">Examples</span></h2> | |
| <h3><span id="Hello.2C_World.21"></span><span class="mw-headline" id="Hello,_World!">Hello, World!</span></h3> | |
| <pre>.-$"Hello, World!"</pre> | |
| <h3><span class="mw-headline" id="Counter">Counter</span></h3> | |
| <pre> /1#-. | |
| | | |
| /-+-$#\ | |
| | | | | |
| [+]<1#-* | |
| | | | |
| \--<--/ | |
| | | |
| 0 | |
| # | |
| | | |
| .</pre> | |
| <h3><span class="mw-headline" id="Find_prime_numbers">Find prime numbers</span></h3> | |
| <pre>%$T | |
| . | |
| | | |
| # | |
| 3 | |
| | | |
| @ | |
| 1 | |
| | | |
| /--*--*-<--\ | |
| | | | /+----\ | |
| | # | v+-0@-~-\ | |
| | 2 | /->~*{%}/ | | |
| | | | 1 |\-+---/ | |
| | | | @ ^\ | | |
| \-{+}-+-* 01 | | |
| | | ## | | |
| | v--*+-/ | |
| | | || | |
| /-* | *+--\ | |
| | T | || | | |
| # $ # /~/ | | |
| 0 # 1 */ | | |
| | | | | | | |
| \->-+-~----<-#$-2#-. | |
| \-/ | |
| /--------\ | |
| T | | |
| *--------~ | |
| | | | |
| \-*----@[=] | |
| | | | |
| \--#1--/</pre> | |
| <hr/> | |
| <h3><span class="mw-headline" id="Print_the_Fibonacci_Sequence">Print the Fibonacci Sequence</span></h3> | |
| <pre>.-#1\ | |
| . /->\ | |
| >[+] | | |
| \-*#$/</pre> | |
| <h3><span class="mw-headline" id="Print_powers_of_2">Print powers of 2</span></h3> | |
| <pre> .-#2\ | |
| /---v | |
| [*]2#* | |
| \-#$/</pre> | |
| <h3><span class="mw-headline" id="Game">Game</span></h3> | |
| <pre>/-""$-. | |
| | | |
| \--$"Pick a number between 1 and 255 (inclusive)"\ | |
| /------------------------------------------------/ | |
| \--$"I will correctly guess that number after no more than 8 tries"\ | |
| /---------------------------------------------------------------""$/ | |
| \--$"After each of my guesses, respond with: "\ | |
| /---------------------------------------------/ | |
| \--$" '2' if I guess too high,"\ | |
| /----------------------------------/ | |
| \--$" '1' if I guess too low,"\ | |
| /---------------------------------/ | |
| \--$" or '0' if I guess correctly"\ | |
| /----------------------------------/ | |
| | | |
| | /->-\ | |
| | /--------------\ /-[-]| | | |
| # | /#1\-~--+[+]| | |
| 6 | /*-{-}* | | | | |
| 4 /2#\ | /----~-----+--+-+-+-#7-$a_#-$"I won! Good game!"-& | |
| |/{÷}-*---* *----/ |/-~-/ | | |
| || |/--+-----+------\ \+-/ | | |
| \>----~# # \-?#-*-+----/ | | |
| |1 1 /$""-$#-/ | | | |
| \/ | ~---------*----------<-821#-. | |
| \--/</pre> | |
| <h3><span class="mw-headline" id="Quine">Quine</span></h3> | |
| <pre> ($'.-#40-$_a#-#36-$_a#-#39-$_a#)</pre> | |
| <h3><span class="mw-headline" id="Semi-compact_factorial_calculator">Semi-compact factorial calculator</span></h3> | |
| <pre> /---------*--~-$#-& | |
| | /--;---\| [!]-\ | |
| | *------++--*#1/ | |
| | | /1#\ || | |
| [*]*{-}-*~<+*?#-. | |
| *-------+-</ | |
| \-#0----/</pre> | |
| <h3><span id="Code-golfed_counter_.2815_bytes.29"></span><span class="mw-headline" id="Code-golfed_counter_(15_bytes)">Code-golfed counter (15 bytes)</span></h3> | |
| <pre>/.*$#-\ | |
| \{+}1#/</pre> | |
| <h3><span class="mw-headline" id="W110"><a href="/wiki/W110" title="W110">W110</a></span></h3> | |
| <p>For more iterations, repeat the iteration part. Thanks to <a class="external text" href="http://wiki.xdi8.top/wiki/user:colorfulGalaxy" rel="nofollow">this user</a> | |
| </p> | |
| <pre> . . . . . . . . . . . . . . . . . . | |
| | | | | | | | | | | | | | | | | | | | |
| # # # # # # # # # # # # # # # # # # | |
| 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 1 1 1 | |
| /-*-\/-*-\/-*-\/-*-\/-*-\/-*-\/-*-\/-*-\/-*-\/-*-\/-*-\/-*-\/-*-\/-*-\/-*-\/-*-\/-*-\/-*-\ | |
| -/[+]+/[+]+/[+]+/[+]+/[+]+/[+]+/[+]+/[+]+/[+]+/[+]+/[+]+/[+]+/[+]+/[+]+/[+]+/[+]+/[+]+/[+]+-------. | |
| /*\| /*\| /*\| /*\| /*\| /*\| /*\| /*\| /*\| /*\| /*\| /*\| /*\| /*\| /*\| /*\| /*\| /*\| | |
| # || # || # || # || # || # || # || # || # || # || # || # || # || # || # || # || # || # || | |
| 1 || 1 || 1 || 1 || 1 || 1 || 1 || 1 || 1 || 1 || 1 || 1 || 1 || 1 || 1 || 1 || 1 || 1 || | |
| /[+]|\[+]|\[+]|\[+]|\[+]|\[+]|\[+]|\[+]|\[+]|\[+]|\[+]|\[+]|\[+]|\[+]|\[+]|\[+]|\[+]|\[+]|\ | |
| . \[*] \[*] \[*] \[*] \[*] \[*] \[*] \[*] \[*] \[*] \[*] \[*] \[*] \[*] \[*] \[*] \[*] \[*] | |
| /-* /-* /-* /-* /-* /-* /-* /-* /-* /-* /-* /-* /-* /-* /-* /-* /-* /-* | |
| # | # | # | # | # | # | # | # | # | # | # | # | # | # | # | # | # | # | | |
| 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | | |
| \[%] \[%] \[%] \[%] \[%] \[%] \[%] \[%] \[%] \[%] \[%] \[%] \[%] \[%] \[%] \[%] \[%] \[%] | |
| /-* /-* /-* /-* /-* /-* /-* /-* /-* /-* /-* /-* /-* /-* /-* /-* /-* /-* | |
| | # | # | # | # | # | # | # | # | # | # | # | # | # | # | # | # | # | # | |
| | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
| \[<] \[<] \[<] \[<] \[<] \[<] \[<] \[<] \[<] \[<] \[<] \[<] \[<] \[<] \[<] \[<] \[<] \[<] | |
| // // // // // // // // // // // // // // // // // // | |
| $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ | | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ $ | |
| # # # # # # # # # # # # # # # # # #</pre> | |
| <h2><span class="mw-headline" id="Implementation">Implementation</span></h2> | |
| <p>The original implementation is written in Python and is <a class="external text" href="https://github.com/aaronduino/asciidots" rel="nofollow">on Github</a> | |
| It can be tried out online at <a class="external text" href="https://asciidots.herokuapp.com" rel="nofollow">asciidots.herokuapp.com</a> | |
| </p> | |
| <h2><span class="mw-headline" id="External_Resources">External Resources</span></h2> | |
| <ul><li><a class="external text" href="https://github.com/aaronduino/asciidots" rel="nofollow">Main Github repo</a></li> | |
| <li><a class="external text" href="https://ajanse.me/asciidots/" rel="nofollow">AsciiDots</a> Visual Editor and Interpreter</li> | |
| <li><a class="external text" href="http://ajanse.me/asciidots/language/" rel="nofollow">Documentation</a> and specification</li> | |
| <li>It got a writeup on Motherboard! <a class="external autonumber" href="https://motherboard.vice.com/en_us/article/a33dvb/asciidots-is-the-coolest-looking-programming-language" rel="nofollow">[1]</a></li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20250724004522 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.039 seconds | |
| Real time usage: 0.040 seconds | |
| Preprocessor visited node count: 228/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 5950/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:11368-0!canonical and timestamp 20250724004522 and revision id 150337. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b>Autopsy</b> is a minimal esolanguage designed in <a href="/wiki/Category:2018" title="Category:2018">2018</a> by <a href="/wiki/User:Keymaker" title="User:Keymaker">User:Keymaker</a>. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Program_and_execution"><span class="tocnumber">1</span> <span class="toctext">Program and execution</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Computational_class"><span class="tocnumber">2</span> <span class="toctext">Computational class</span></a></li> | |
| <li class="toclevel-1 tocsection-3"><a href="#Example_MM_translation"><span class="tocnumber">3</span> <span class="toctext">Example MM translation</span></a></li> | |
| <li class="toclevel-1 tocsection-4"><a href="#External_resources"><span class="tocnumber">4</span> <span class="toctext">External resources</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Program_and_execution">Program and execution</span></h2> | |
| <p>An Autopsy program consists of two kinds of instructions, <code>.</code> and <code>;</code>. When reading the program, all other characters are ignored. The program must be at least one instruction long. | |
| </p><p>There are four registers/counters (a, b, c, d) which are all initially 0, which is also their minimum value. They have no upper bound. Initially the first register (a) is chosen. | |
| </p><p>When the program begins the instruction pointer is pointing at the first instruction. After executing an instruction, the instruction pointer moves forward two or three times (see below). If stepping past the last instruction, the instruction pointer returns to the first instruction. | |
| </p><p>Executing an instruction: | |
| </p> | |
| <pre>if instruction is "." | |
| increase value of current register by one | |
| move forward two times | |
| else if instruction is ";" | |
| if value of current register is 0 | |
| move forward three times | |
| else if value of current register is larger than 0 | |
| decrease value of current register by one | |
| move forward two times | |
| whether decreasing happened or not, switch register focus to next register (if presently in last, switch to first) | |
| </pre> | |
| <p>The program never halts. | |
| </p> | |
| <h2><span class="mw-headline" id="Computational_class">Computational class</span></h2> | |
| <p>The language has been proven <a href="/wiki/Turing-complete" title="Turing-complete">Turing-complete</a> via Minsky Machine translation. Detailed explanation can be found on the language's page (see link below). | |
| </p> | |
| <h2><span class="mw-headline" id="Example_MM_translation">Example MM translation</span></h2> | |
| <p>Here is a simple 7-instruction test program in Minsky Machine. | |
| </p><p>The numbers on the left indicate the number of each instruction. The letters after "inc" or "dec" indicate the affected register. The numbers on the right correspond to the ones on the left and indicate the next instruction to go to. The "inc" commands only have one number to go to, and they increase the register value. The "dec" commands go to the second number if the register is zero. Otherwise, they decrement the register and go to the first number. | |
| </p><p>The test program is similar to the Minsky Machine test program provided on the language's page, but here, the registers are renamed to "B" and "C" because those are the Autopsy registers corresponding to the registers of the Minsky machine. When the A register (of Autopsy) hits zero, the next Minsky Machine command is initiated. | |
| </p><p>The test program sets B to 3, then decreases it until zero while simultaneously increasing C, then settles into an endless loop decreasing B (which is already 0 at that point). | |
| </p> | |
| <pre>1 inc B 4 | |
| 2 inc B 5 | |
| 3 inc C 3 | |
| 4 inc B 2 | |
| 5 dec B 6 7 | |
| 6 inc C 5 | |
| 7 dec B 7 7 | |
| </pre> | |
| <p>The resulting Autopsy program (1842 instructions): | |
| </p> | |
| <pre>;...;;..;;..;;..;...;;..;..;...;.;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;...;;..;;..;;.;;...;. | |
| ..;...;.;...;;..;;..;;.;;.;...;;..;;..;;..;...;;..;..;...;.;;...;...;...;.;...;;..;;..;;.;;...;...;. | |
| ..;.;...;;..;;..;;.;;...;...;...;.;...;;..;;..;;.;;.;...;;..;;..;;..;...;...;....;...;.....;.;;...;. | |
| ..;...;.;...;;..;;..;;.;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;. | |
| ..;;..;;..;;.;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;...;;..;;.. | |
| ;;.;;.;...;;..;;..;;..;...;...;;.....;...;.;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;...;;..;;.. | |
| ;;.;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;...;;..;;..;;.;;.;... | |
| ;;..;;...;;...;;.;;..;;..;...............;...;...;.;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;... | |
| ;;..;;..;;.;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;...;;..;;..;; | |
| .;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;...;;..;;..;;.;;...;... | |
| ;...;.;...;;..;;..;;.;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;... | |
| ;;..;;..;;.;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;...;;..;;..;;.;;.;...;;..;;..;;..;...;...;. | |
| .;...;.....;.;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;...;;..;;.. | |
| ;;.;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;...;;..;;..;;.;;.;... | |
| ;;..;;...;..........;...;;.;;..;;..;...;...;...;.;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;...;; | |
| ..;;..;;.;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;...;;..;;..;;.; | |
| ;...;...;...;.;...;;..;;..;;.;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;...;;..;;..;;.;;...;...;. | |
| ..;.;...;;..;;..;;.;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;...;;..;;..;;.;;...;...;...;.;...;; | |
| ..;;..;;.;;...;...;...;.;...;;..;;..;;.;;. | |
| </pre> | |
| <h2><span class="mw-headline" id="External_resources">External resources</span></h2> | |
| <ul><li><a class="external text" href="http://yiap.nfshost.com/esoteric/autopsy/autopsy.html" rel="nofollow">Autopsy page</a> (exhaustive explanation of the language and the MM translation, MM-to-Autopsy translator, Autopsy interpreter in Python)</li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20251213155417 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.010 seconds | |
| Real time usage: 0.011 seconds | |
| Preprocessor visited node count: 20/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 438/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:12041-0!canonical and timestamp 20251213155417 and revision id 170570. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><table style="float:right;border:1px solid silver;background-color:rgb(249, 249, 249);max-width:256px;padding:5px;"> | |
| <caption><b>Befunge</b></caption> | |
| <tbody><tr> | |
| <th style="text-align: left;vertical-align: top;"><a href="/wiki/Esolang:Categorization#Paradigm" title="Esolang:Categorization">Paradigm(s)</a></th> | |
| <td>imperative</td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;">Designed by</th> | |
| <td><a href="/wiki/Chris_Pressey" title="Chris Pressey">Chris Pressey</a></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;"><a href="/wiki/Category:Years" title="Category:Years">Appeared in</a></th> | |
| <td><a href="/wiki/Category:1993" title="Category:1993">1993</a></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;"><a href="/wiki/Esolang:Categorization#Memory" title="Esolang:Categorization">Memory system</a></th> | |
| <td>stack-based</td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;"><a href="/wiki/Esolang:Categorization#Dimensions" title="Esolang:Categorization">Dimensions</a></th> | |
| <td><a href="/wiki/Category:Two-dimensional_languages" title="Category:Two-dimensional languages">two-dimensional</a></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;"><a href="/wiki/Computational_class" title="Computational class">Computational class</a></th> | |
| <td><a href="/wiki/Category:Turing_complete" title="Category:Turing complete">Turing complete</a> (Befunge-98)</td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;">Reference implementation</th> | |
| <td><a class="external text" href="https://codeberg.org/catseye/Befunge-93" rel="nofollow">Befunge-93</a></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;">Dialects</th> | |
| <td>Befunge-93, <a href="/wiki/Funge-98" title="Funge-98">Funge-98</a></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;">File extension(s)</th> | |
| <td><code>.be</code>, <code>.bf</code>, <code>.b93</code>, <code>.b98</code>, <code>.befunge</code></td> | |
| </tr> | |
| </tbody></table><p><b>Befunge</b> is a two-dimensional <a href="/wiki/Esoteric_programming_language" title="Esoteric programming language">esoteric programming language</a> invented in 1993 by <a href="/wiki/Chris_Pressey" title="Chris Pressey">Chris Pressey</a> with the goal of being as difficult to compile as possible. Code is laid out on a two-dimensional grid of instructions, and execution can proceed in any direction of that grid. | |
| </p><div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Language_overview"><span class="tocnumber">1</span> <span class="toctext">Language overview</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#History"><span class="tocnumber">2</span> <span class="toctext">History</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-3"><a href="#Etymology"><span class="tocnumber">2.1</span> <span class="toctext">Etymology</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-4"><a href="#Instructions"><span class="tocnumber">3</span> <span class="toctext">Instructions</span></a></li> | |
| <li class="toclevel-1 tocsection-5"><a href="#Computational_class"><span class="tocnumber">4</span> <span class="toctext">Computational class</span></a></li> | |
| <li class="toclevel-1 tocsection-6"><a href="#Compilation"><span class="tocnumber">5</span> <span class="toctext">Compilation</span></a></li> | |
| <li class="toclevel-1 tocsection-7"><a href="#Examples"><span class="tocnumber">6</span> <span class="toctext">Examples</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-8"><a href="#Befunge-93_and_Befunge-98"><span class="tocnumber">6.1</span> <span class="toctext">Befunge-93 and Befunge-98</span></a> | |
| <ul> | |
| <li class="toclevel-3 tocsection-9"><a href="#Hello,_World!"><span class="tocnumber">6.1.1</span> <span class="toctext">Hello, World!</span></a></li> | |
| <li class="toclevel-3 tocsection-10"><a href="#Cat_program"><span class="tocnumber">6.1.2</span> <span class="toctext">Cat program</span></a></li> | |
| <li class="toclevel-3 tocsection-11"><a href="#Truth_Machine"><span class="tocnumber">6.1.3</span> <span class="toctext">Truth Machine</span></a></li> | |
| <li class="toclevel-3 tocsection-12"><a href="#Factorial"><span class="tocnumber">6.1.4</span> <span class="toctext">Factorial</span></a></li> | |
| <li class="toclevel-3 tocsection-13"><a href="#Fibonacci_sequence"><span class="tocnumber">6.1.5</span> <span class="toctext">Fibonacci sequence</span></a></li> | |
| <li class="toclevel-3 tocsection-14"><a href="#Fizz_Buzz"><span class="tocnumber">6.1.6</span> <span class="toctext">Fizz Buzz</span></a></li> | |
| <li class="toclevel-3 tocsection-15"><a href="#Number_Guessing_Game_(from_1_to_3)"><span class="tocnumber">6.1.7</span> <span class="toctext">Number Guessing Game (from 1 to 3)</span></a></li> | |
| <li class="toclevel-3 tocsection-16"><a href="#DNA-code"><span class="tocnumber">6.1.8</span> <span class="toctext">DNA-code</span></a></li> | |
| <li class="toclevel-3 tocsection-17"><a href="#Compact_DNA-code"><span class="tocnumber">6.1.9</span> <span class="toctext">Compact DNA-code</span></a></li> | |
| <li class="toclevel-3 tocsection-18"><a href="#Sieve_of_Eratosthenes"><span class="tocnumber">6.1.10</span> <span class="toctext">Sieve of Eratosthenes</span></a></li> | |
| <li class="toclevel-3 tocsection-19"><a href="#Quine"><span class="tocnumber">6.1.11</span> <span class="toctext">Quine</span></a></li> | |
| <li class="toclevel-3 tocsection-20"><a href='#Simple_game_("Less_or_More")'><span class="tocnumber">6.1.12</span> <span class="toctext">Simple game ("Less or More")</span></a></li> | |
| <li class="toclevel-3 tocsection-21"><a href="#Another_simple_game(Tic-Tac-Toe)"><span class="tocnumber">6.1.13</span> <span class="toctext">Another simple game(Tic-Tac-Toe)</span></a></li> | |
| <li class="toclevel-3 tocsection-22"><a href="#Calculator"><span class="tocnumber">6.1.14</span> <span class="toctext">Calculator</span></a></li> | |
| <li class="toclevel-3 tocsection-23"><a href="#99_Bottles_of_Beer"><span class="tocnumber">6.1.15</span> <span class="toctext">99 Bottles of Beer</span></a></li> | |
| <li class="toclevel-3 tocsection-24"><a href="#Random_Number_Generator"><span class="tocnumber">6.1.16</span> <span class="toctext">Random Number Generator</span></a></li> | |
| <li class="toclevel-3 tocsection-25"><a href="#A+B_Problem"><span class="tocnumber">6.1.17</span> <span class="toctext">A+B Problem</span></a></li> | |
| <li class="toclevel-3 tocsection-26"><a href="#Do_Nothing"><span class="tocnumber">6.1.18</span> <span class="toctext">Do Nothing</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-2 tocsection-27"><a href="#Befunge-98"><span class="tocnumber">6.2</span> <span class="toctext">Befunge-98</span></a> | |
| <ul> | |
| <li class="toclevel-3 tocsection-28"><a href="#Hello,_world!_(without_string_reversion)"><span class="tocnumber">6.2.1</span> <span class="toctext">Hello, world! (without string reversion)</span></a></li> | |
| <li class="toclevel-3 tocsection-29"><a href="#Shorter_version_of_the_previous_one"><span class="tocnumber">6.2.2</span> <span class="toctext">Shorter version of the previous one</span></a></li> | |
| <li class="toclevel-3 tocsection-30"><a href="#One_character_shorter"><span class="tocnumber">6.2.3</span> <span class="toctext">One character shorter</span></a></li> | |
| <li class="toclevel-3 tocsection-31"><a href="#Multi-line_Hello_World_without_string_reversion"><span class="tocnumber">6.2.4</span> <span class="toctext">Multi-line Hello World without string reversion</span></a></li> | |
| <li class="toclevel-3 tocsection-32"><a href='#Yet_another_"Hello,_world"'><span class="tocnumber">6.2.5</span> <span class="toctext">Yet another "Hello, world"</span></a></li> | |
| <li class="toclevel-3 tocsection-33"><a href="#1D_Factorial"><span class="tocnumber">6.2.6</span> <span class="toctext">1D Factorial</span></a></li> | |
| <li class="toclevel-3 tocsection-34"><a href="#Convert_binary_number_to_decimal"><span class="tocnumber">6.2.7</span> <span class="toctext">Convert binary number to decimal</span></a></li> | |
| <li class="toclevel-3 tocsection-35"><a href="#Looping_counter_(with_newlines)"><span class="tocnumber">6.2.8</span> <span class="toctext">Looping counter (with newlines)</span></a></li> | |
| <li class="toclevel-3 tocsection-36"><a href="#The_Twelve_Days_of_Befungemas"><span class="tocnumber">6.2.9</span> <span class="toctext">The Twelve Days of Befungemas</span></a></li> | |
| </ul> | |
| </li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-37"><a href="#Interpreters"><span class="tocnumber">7</span> <span class="toctext">Interpreters</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-38"><a href="#Befunge-93_Self-Interpreter"><span class="tocnumber">7.1</span> <span class="toctext">Befunge-93 Self-Interpreter</span></a></li> | |
| <li class="toclevel-2 tocsection-39"><a href="#befunge93.js"><span class="tocnumber">7.2</span> <span class="toctext">befunge93.js</span></a></li> | |
| <li class="toclevel-2 tocsection-40"><a href="#BefunExec"><span class="tocnumber">7.3</span> <span class="toctext">BefunExec</span></a></li> | |
| <li class="toclevel-2 tocsection-41"><a href="#jsFunge_IDE"><span class="tocnumber">7.4</span> <span class="toctext">jsFunge IDE</span></a></li> | |
| <li class="toclevel-2 tocsection-42"><a href="#Befunge_JavaScript_interpreter"><span class="tocnumber">7.5</span> <span class="toctext">Befunge JavaScript interpreter</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-43"><a href="#Related_languages"><span class="tocnumber">8</span> <span class="toctext">Related languages</span></a></li> | |
| <li class="toclevel-1 tocsection-44"><a href="#External_resources"><span class="tocnumber">9</span> <span class="toctext">External resources</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-45"><a href="#Befunge-93"><span class="tocnumber">9.1</span> <span class="toctext">Befunge-93</span></a></li> | |
| <li class="toclevel-2 tocsection-46"><a href="#Befunge-98_and_beyond"><span class="tocnumber">9.2</span> <span class="toctext">Befunge-98 and beyond</span></a></li> | |
| </ul> | |
| </li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Language_overview">Language overview</span></h2> | |
| <p>A Befunge program is laid out on a two-dimensional <i>playfield</i> of fixed size. The playfield is a rectangular grid of ASCII characters, each generally representing an instruction. The playfield is initially loaded with the program. | |
| </p><p>Execution proceeds by the means of a <i>program counter</i> (-93) or <i>instruction pointer</i> (-<a href="/wiki/Funge-98" title="Funge-98">98</a>). This points to a grid cell on the playfield. The instruction pointer has inertia: it can travel to any of the four cardinal directions, and keep traveling that way until an instruction changes the direction. The instruction pointer begins at a set location (the upper-left corner of the playfield) and is initially travelling in a set direction (right). As it encounters instructions, they are executed. Befunge-93 has no jumps farther than two cells, so control flow is done by altering the direction of the program counter, sending it to different literal code paths. (Befunge-98 has far jumps, but because of inertia in the community, these are rarely used.) The following, for example, is an <a href="/wiki/Infinite_loop" title="Infinite loop">infinite loop</a>: | |
| </p> | |
| <pre>>v | |
| ^< | |
| </pre> | |
| <p>Befunge programs mostly store data on a <a href="/wiki/Stack" title="Stack">stack</a> in the manner of Forth, but they can also read and write the contents of any cell in the playfield, given its coordinates, thus Befunge code can be self-modifying. | |
| </p> | |
| <h2><span class="mw-headline" id="History">History</span></h2> | |
| <p>Befunge is believed to be the first two-dimensional, ASCII-based, general-purpose (in the sense of "you could plausibly write <a class="extiw" href="https://en.wikipedia.org/wiki/Hunt_the_Wumpus" title="wikipedia:Hunt the Wumpus">Hunt the Wumpus</a> in it" <a class="external autonumber" href="https://catseye.tc/view/befunge-93/eg/wumpus.bf" rel="nofollow">[1]</a>) programming language. Its form was influenced in part by the multimedia scripting application AmigaVision, and in part by <a href="/wiki/Forth" title="Forth">Forth</a>. | |
| </p><p>The original Befunge (known as "Befunge-93" to distinguish it from others) has spawned many descendants and <a href="#Related_languages">remote cousins</a>. The closest commonly recognized relative, and most direct extension, of Befunge-93 is Befunge-98 of the <a href="/wiki/Funge-98" title="Funge-98">Funge-98</a> family of languages. However, Funge-98 actually derives from Funge-97, which derives from Befunge-96, which is in turn derived from Befunge-93. <a href="/wiki/Befunge/96_and_97" title="Befunge/96 and 97">This page</a> contains the original specs for these variants as well as a functioning link to a combined Befunge-93/Befunge-96/Funge-97 interpreter called MTFI. Each Funge extends the central concepts of Befunge to a given number of dimensions (for example, Unefunge is one-dimensional, Trefunge is three-dimensional, Nefunge is <i>n</i>-dimensional, etc.). | |
| </p><p>Today, Befunge powers fungot, an IRC bot that enjoys some popularity in the esoteric programming community. Its source code is so small that it fits on a T-shirt. | |
| </p> | |
| <h3><span class="mw-headline" id="Etymology">Etymology</span></h3> | |
| <p>The word "Befunge" started life as a typographical error for the word "before", typed by Curtis Coleman at 4AM on a BBS chat system. | |
| </p><p>It was then reverse-endowed with a fictional morphology where it took on the meaning <i>Be-</i> (a corruption of the prefix <i>bi-</i>, for "two") + <i>funge</i> (fictional root of the word <a class="external text" href="http://dictionary.reference.com/search?q=fungible" rel="nofollow">fungible</a>, i.e. "interchangeable"). That is, to interchange (program codes with data) in two (dimensions). | |
| </p><p>The name is pronounced /biː'fʌndʒ/. | |
| </p> | |
| <h2><span class="mw-headline" id="Instructions">Instructions</span></h2> | |
| <p>Befunge-93 has the following commands: | |
| </p> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <th>Cmd | |
| </th> | |
| <th>Description | |
| </th></tr> | |
| <tr> | |
| <td><code>+</code> | |
| </td> | |
| <td>Addition: Pop two values a and b, then push the result of a+b | |
| </td></tr> | |
| <tr> | |
| <td><code>-</code> | |
| </td> | |
| <td>Subtraction: Pop two values a and b, then push the result of b-a | |
| </td></tr> | |
| <tr> | |
| <td><code>*</code> | |
| </td> | |
| <td>Multiplication: Pop two values a and b, then push the result of a*b | |
| </td></tr> | |
| <tr> | |
| <td><code>/</code> | |
| </td> | |
| <td>Integer division: Pop two values a and b, then push the result of b/a, rounded down. According to the specifications, if a is zero, ask the user what result they want. | |
| </td></tr> | |
| <tr> | |
| <td><code>%</code> | |
| </td> | |
| <td>Modulo: Pop two values a and b, then push the remainder of the integer division of b/a. | |
| </td></tr> | |
| <tr> | |
| <td><code>!</code> | |
| </td> | |
| <td>Logical NOT: Pop a value. If the value is zero, push 1; otherwise, push zero. | |
| </td></tr> | |
| <tr> | |
| <td><code>`</code> | |
| </td> | |
| <td>Greater than: Pop two values a and b, then push 1 if b>a, otherwise zero. | |
| </td></tr> | |
| <tr> | |
| <td><code>></code> | |
| </td> | |
| <td>PC direction right | |
| </td></tr> | |
| <tr> | |
| <td><code><</code> | |
| </td> | |
| <td>PC direction left | |
| </td></tr> | |
| <tr> | |
| <td><code>^</code> | |
| </td> | |
| <td>PC direction up | |
| </td></tr> | |
| <tr> | |
| <td><code>v</code> | |
| </td> | |
| <td>PC direction down | |
| </td></tr> | |
| <tr> | |
| <td><code>?</code> | |
| </td> | |
| <td>Random PC direction | |
| </td></tr> | |
| <tr> | |
| <td><code>_</code> | |
| </td> | |
| <td>Horizontal IF: pop a value; set direction to right if value=0, set to left otherwise | |
| </td></tr> | |
| <tr> | |
| <td><code>|</code> | |
| </td> | |
| <td>Vertical IF: pop a value; set direction to down if value=0, set to up otherwise | |
| </td></tr> | |
| <tr> | |
| <td><code>"</code> | |
| </td> | |
| <td>Toggle stringmode (push each character's ASCII value all the way up to the next <code>"</code>) | |
| </td></tr> | |
| <tr> | |
| <td><code>:</code> | |
| </td> | |
| <td>Duplicate top stack value | |
| </td></tr> | |
| <tr> | |
| <td><code>\</code> | |
| </td> | |
| <td>Swap top stack values | |
| </td></tr> | |
| <tr> | |
| <td><code>$</code> | |
| </td> | |
| <td>Pop top of stack and discard | |
| </td></tr> | |
| <tr> | |
| <td><code>.</code> | |
| </td> | |
| <td>Pop top of stack and output as integer | |
| </td></tr> | |
| <tr> | |
| <td><code>,</code> | |
| </td> | |
| <td>Pop top of stack and output as ASCII character | |
| </td></tr> | |
| <tr> | |
| <td><code>#</code> | |
| </td> | |
| <td>Bridge: jump over next command in the current direction of the current PC | |
| </td></tr> | |
| <tr> | |
| <td><code>g</code> | |
| </td> | |
| <td>A "get" call (a way to retrieve data in storage). Pop two values y and x, then push the ASCII value of the character at that position in the program. If (x,y) is out of bounds, push 0 | |
| </td></tr> | |
| <tr> | |
| <td><code>p</code> | |
| </td> | |
| <td>A "put" call (a way to store a value for later use). Pop three values y, x and v, then change the character at the position (x,y) in the program to the character with ASCII value v | |
| </td></tr> | |
| <tr> | |
| <td><code>&</code> | |
| </td> | |
| <td>Get integer from user and push it | |
| </td></tr> | |
| <tr> | |
| <td><code>~</code> | |
| </td> | |
| <td>Get character from user and push it | |
| </td></tr> | |
| <tr> | |
| <td><code>@</code> | |
| </td> | |
| <td>End program | |
| </td></tr> | |
| <tr> | |
| <td><code>0</code> – <code>9</code> | |
| </td> | |
| <td>Push corresponding number onto the stack | |
| </td></tr></tbody></table> | |
| <p>See <a href="/wiki/Funge-98#Instructions" title="Funge-98">the separate Funge-98 article</a> for the instructions of that dialect. | |
| </p> | |
| <h2><span class="mw-headline" id="Computational_class">Computational class</span></h2> | |
| <p>Because Befunge-93 programs are given an explicit limit of 80x25 cells on the size of their playfield, but are also given a working stack, any Befunge-93 program should be simulatable by a <a href="/wiki/Push-down_automaton" title="Push-down automaton">push-down automaton</a>. | |
| </p><p>However, the converse is not true; there surely exist some push-down automata which cannot be simulated by any Befunge-93 program (because they contain more states than can be encoded in the 80x25 playfield). | |
| </p><p>Befunge-98 removes the fixed-size restriction on the playfield, and thus should be <a href="/wiki/Turing-complete" title="Turing-complete">Turing-complete</a>. | |
| </p> | |
| <h2><span class="mw-headline" id="Compilation">Compilation</span></h2> | |
| <p>As stated, the design goal for Befunge was to create a language which was difficult to compile. This was realized by two main features: | |
| </p> | |
| <ul><li>self-modifying – the <code>p</code> instruction can write new instructions into the playfield; and</li> | |
| <li>multi-dimensional – the same instruction can be executed in four different contexts (in a left-to-right series of instructions, or right-to-left, or upward or downward.)</li></ul> | |
| <p>Nevertheless, these obstacles have been overcome to some degree, and Befunge compilers have been written, using appropriate techniques. | |
| </p><p>The bf2c compiler included with the standard Befunge-93 distribution uses <i>threaded code</i>: each instruction is compiled to a snippet of C code, and control flows through the snippets just as it does in a Befunge interpreter (that is, conditionally on the value of some 'direction' register.) This does not result in a significant advantage over a good interpreter. Note that the bf2c compiler is not correct since it does not handle <code>p</code> correctly, but it would not be impossible to make it do so (although the C language might not be well-suited for this.) | |
| </p><p>The Betty compiler, for example, treats every possible straight line of instructions as a subprogram, and if a <code>p</code> instruction alters that subprogram, that subprogram is recompiled. This is an interesting variation on just-in-time compilation, and it results in a much better advantage over an interpreter, since many instructions can be executed in native code without making intervening decisions on the 'direction' register. | |
| </p><p>The Befunjit and Bejit compilers, similarly to the Betty compiler, split the original code into subprograms which are lazily compiled and executed. They, however, divide the original playfield into "static paths" - code paths which do not contain instructions that conditionally change direction (i.e. <code>|</code>, <code>_</code> or <code>?</code>). The "static paths" may span on more cells than the "straight line paths" of Betty, which results in fewer and longer subprograms. Thus, there are fewer context jumps between the compiler and the compiled code and allows more optimisations. | |
| </p><p>There are also programs which combine a Befunge interpreter and a copy of a given Befunge program into a single executable which runs the Befunge program when started. For Befunge-93 this can easily be done by having a preallocated 80×25 cell storage space in the interpreter, and filling it in with the chosen Befunge program. This might be considered a sort of pathological version of threaded code, and while it produces a similar effect to a compiler, that is, it generates a "native executable", it is not really considered the same thing. Sometimes such a tool is called a <i>pseudo-compiler</i> or <i>linker</i>. <a class="external text" href="http://quadium.net/funge/tbc/" rel="nofollow">TBC (Tim's Befunge Compiler)</a>, and BFC (BeFunge Compiler) written by Uranium-239, are examples of such tools. | |
| </p> | |
| <h2><span class="mw-headline" id="Examples">Examples</span></h2> | |
| <h3><span class="mw-headline" id="Befunge-93_and_Befunge-98">Befunge-93 and Befunge-98</span></h3> | |
| <h4><span id="Hello.2C_World.21"></span><span class="mw-headline" id="Hello,_World!"><a class="mw-redirect" href="/wiki/Hello,_World!" title="Hello, World!">Hello, World!</a></span></h4> | |
| <pre> > v | |
| v"Hello World!"< | |
| >:v | |
| ^,_@ | |
| </pre> | |
| <p>Here is another one by <a href="/wiki/User:None1" title="User:None1">User:None1</a>: | |
| </p> | |
| <pre>"!dlroW olleH",,,,,,,,,,,,@ | |
| </pre> | |
| <p>And an even shorter one, also by <a href="/wiki/User:None1" title="User:None1">User:None1</a>: | |
| </p> | |
| <pre>"!dlroW olleH">:#,_@ | |
| </pre> | |
| <p>Without usage of letters or loops: | |
| </p> | |
| <pre>89*,52*5*2*1+,92*6*,92*6*,52*1+52**1+,48*,52*8*7+,52*1+52**1+,52*1+52**4+,v | |
| v < | |
| >52*52**8+,52*52**,48*1+,@ | |
| </pre> | |
| <p>Without directly Changing to a Certain direction: | |
| </p> | |
| <pre>?0|0 | |
| 0 0 @,,,,,,,,,,,,,_ | |
| _0_"!dlroW ,olleH"0| | |
| 0 1 | |
| </pre> | |
| <p>Without text nor numbers: | |
| </p> | |
| <pre>v > v | |
| > &!| | |
| >!>!::++:*:+:+:+,!!::::++++:*:+:+:!!+:,:!!:::::+++++++:::,,!!::+++,!!::::::::::++++++++++:+:+,!!:+:+:+:+:+::,!!::::::::::::::++++++++++++++:+:!!-:!!::++*,:!!:::::::::+++++++++::!!+*:!!+:,:!!::+++,:!!::++::**:+:+,:!!::::++++:*,:!!+,@ | |
| </pre> | |
| <h4><span class="mw-headline" id="Cat_program"><a href="/wiki/Cat_program" title="Cat program">Cat program</a></span></h4> | |
| <pre>~:1+!#@_, | |
| </pre> | |
| <h4><span class="mw-headline" id="Truth_Machine"><a class="mw-redirect" href="/wiki/Truth_Machine" title="Truth Machine">Truth Machine</a></span></h4> | |
| <pre>&#::_.@# | |
| </pre> | |
| <h4><span class="mw-headline" id="Factorial"><a href="/wiki/Factorial" title="Factorial">Factorial</a></span></h4> | |
| <pre>&>:1-:v v *_$.@ | |
| ^ _$>\:^ | |
| </pre> | |
| <h4><span class="mw-headline" id="Fibonacci_sequence"><a href="/wiki/Fibonacci_sequence" title="Fibonacci sequence">Fibonacci sequence</a></span></h4> | |
| <pre>0:09p1>09g\:09p+:.84*,v | |
| ^ < | |
| </pre> | |
| <h4><span class="mw-headline" id="Fizz_Buzz"><a class="mw-redirect" href="/wiki/Fizz_Buzz" title="Fizz Buzz">Fizz Buzz</a></span></h4> | |
| <pre>>0099+p67+,1+:3%!#v_>:5%!#v_099+g#v_v | |
| , " | |
| , z | |
| , z | |
| , u | |
| " p B | |
| z + " | |
| z 9 | |
| i 9 : | |
| F 0 , . | |
| " 1 , | |
| > ^ , | |
| , | |
| ^ < < < | |
| </pre> | |
| <h4><span id="Number_Guessing_Game_.28from_1_to_3.29"></span><span class="mw-headline" id="Number_Guessing_Game_(from_1_to_3)">Number Guessing Game (from 1 to 3)</span></h4> | |
| <pre>>>v | |
| v1?2v | |
| 3 | |
| > > >: v | |
| |-&< | |
| $ | |
| >"!tcerroC">:v | |
| |,< | |
| @ | |
| </pre> | |
| <h4><span class="mw-headline" id="DNA-code">DNA-code</span></h4> | |
| <p>Output a string of 56 As,Cs,Gs, and Ts. | |
| </p> | |
| <pre>7^DN>vA | |
| v_#v? v | |
| 7^<"""" | |
| 3 ACGT | |
| 90!"""" | |
| 4*:>>>v | |
| +8^-1,< | |
| > ,+,@) | |
| </pre> | |
| <h4><span class="mw-headline" id="Compact_DNA-code">Compact DNA-code</span></h4> | |
| <p>Output a string of 68 As, Cs, Gs, and Ts. | |
| </p> | |
| <pre>vDN>"A"v | |
| >#v?"C"v | |
| v>"G"v | |
| @ >>"T"v | |
| |!p01-<, | |
| 10g:1^> | |
| </pre> | |
| <h4><span class="mw-headline" id="Sieve_of_Eratosthenes">Sieve of Eratosthenes</span></h4> | |
| <pre>2>:3g" "-!v\ g30 < | |
| |!`"O":+1_:.:03p>03g+:"O"`| | |
| @ ^ p3\" ":< | |
| 2 234567890123456789012345678901234567890123456789012345678901234567890123456789 | |
| </pre> | |
| <h4><span class="mw-headline" id="Quine"><a href="/wiki/Quine" title="Quine">Quine</a></span></h4> | |
| <pre>01->1# +# :# 0# g# ,# :# 5# 8# *# 4# +# -# _@ | |
| </pre> | |
| <p>Another one using string mode to put the program on the stack: | |
| </p> | |
| <pre>0 v | |
| "<@_ #! #: #,<*2-1*92,*84,*25,+*92*4*55.0 | |
| </pre> | |
| <p>The shortest method that doesn't use <code>g</code>: | |
| </p> | |
| <pre><@,+2*48_,#! #:<,_$#-:#*8#4<8" | |
| </pre> | |
| <p>Although it can be slightly shorter using the <code>'</code> command from Befunge-97/Funge-98: | |
| </p> | |
| <pre><@,+2 '_,#! #:<,_$#-:# ' $<" | |
| </pre> | |
| <p>One that includes a bit of text of a pre-decided length: | |
| </p> | |
| <pre>:0g,:"~"`#@_1+0"Quines are Fun">_ | |
| </pre> | |
| <p>Arbitrary text can be inserted in between the second set of quotes, though the text is limited to 58 characters. | |
| </p><p>A pseudo-quine which uses some Befunge-97 commands: | |
| </p> | |
| <pre> 060p070 p'O80v | |
| pb2*90p4$4> $4$>v> | |
| v4$>4$>4$>4$># ARGH>! | |
| <{[BEFUNGE_97]}> FUNGE! | |
| ##:-:## #####* 4$*>4$ >060p> 60g80g -!#v_ 60g1+ 60p60v | |
| #vOOGAH **>4$>^!!eg nufeB^ $4$4$4 $4<v#<<v-*2a:: v7-1g< | |
| #>70g>90g-! #@_^Befunge!! 123456 123456 VvVv!#!>Weird! >0ggv* | |
| ^$4$4p07+1g07 ,a<$4< <$4$4< <$4$4< <$4$4< <<#<*-=-=-=-=-* -=-=v* | |
| ::48*-#v_>,4$> 4$4$4 $4$4$ 4$4$4$ 4$4$4$ 4$^*!* XXXXXX XXX> | |
| BOINK>$60g1-7 0g+d2* %'A+,1 $1$1$1 $1$1$1 $>^<$ HAR!!! 8888 | |
| Befunge_is such_a pretty langua ge,_is n't_i t?_It_ 8888 | |
| looks_so much_l ike_li ne_noi se_and it's_ STILL_ ‘88’ | |
| Turing- Complet e!_Cam ouflag e_your code!! Confu se_the | |
| hell_out of_every one_re ading_ your_co de._Oh, AND_y ou.:-) ,o88o. | |
| Once_this_thing_i s_code d,_rea ding_it_back_ver ges_on the_imp 888888 | |
| ossible._Obfusc ate_the_obfus cated!_Befunge_ debuggers_are__ 888888 | |
| your_friends! By:_Alexios Chouchou las... X-X-X-X-X-X-X! 888888 | |
| -=*##*=- \*****/ 9797* -=97=- !@-*= ***** ‘"88P’ | |
| *!@-* | |
| =*!@- | |
| -=*!@ | |
| @-=*! | |
| </pre> | |
| <p>And it prints out: | |
| </p> | |
| <pre> GHIJKLM UVWXYZ | |
| FGHIJKLMNOP VWXYZA | |
| EFGHIJKLMNOPQR WXYZAB | |
| EFGHIJKLMNOPQRST XYZABC | |
| FGHIJKL PQRSTU EFGHIJ QRSTUV ABCDEF HIJKL OPQRS YZABCD | |
| GHIJKLM CDEFGHIJKLM RSTUVW BCDEFG IJKLMNOPQRSTUV ZABCDE | |
| HIJKLMNOPQR CDEFGHIJKLMNO STUVWX CDEFGH JKLMNOPQRSTUVW ABCDEF | |
| JKLMNOPQRSTUV CDEFGH LMNOPQ TUVWXY DEFGHI KLMNOPQRSTUVWXY BCDEFG | |
| LMNOPQRSTUVWXY DEFGH NOPQR UVWXYZ EFGHIJ LMNOPQ UVWXYZ DEFG | |
| OPQRSTUVWXYZA DEFGHI OPQRST VWXYZA FGHIJK MNOPQ WXYZAB EFGH | |
| STUVWXYZAB EFGHIJ PQRSTU WXYZAB GHIJKL NOPQR XYZABC FGHI | |
| WXYZABCD FGHIJK QRSTUV XYZABC HIJKLM OPQRS YZABCD GHIJ | |
| MNOPQRS YZABCDE GHIJKL RSTUVW YZABCD IJKLMN PQRST ZABCDE | |
| NOPQRSTU YZABCDEF HIJKLM STUVWX ZABCDEF IJKLMNO QRSTU ABCDEF HIJKLM | |
| PQRSTUVWXYZABCDEF JKLMNO STUVWX ABCDEFGHIJKLMNOP RSTUVW ABCDEFG IJKLMN | |
| RSTUVWXYZABCDEF LMNOPQRSTUVWX CDEFGHIJKLMNOPQ STUVWXYZABCDEFG JKLMNO | |
| TUVWXYZABCDEF NOPQRSTUVWX DEFGHIJK MNOPQR TUVWXYZABCDEFG KLMNOP | |
| XYZABCDE QRSTUVW GHIJK NOPQRS UVWXY BCDEF LMNOPQ | |
| VWXYZ | |
| WXYZA | |
| XYZAB | |
| YZABC | |
| </pre> | |
| <h4><span id="Simple_game_.28.22Less_or_More.22.29"></span><span class="mw-headline" id='Simple_game_("Less_or_More")'>Simple game ("Less or More")</span></h4> | |
| <pre>vv < < | |
| 2 | |
| ^ v< | |
| v1<?>3v4 | |
| ^ ^ | |
| > >?> ?>5^ | |
| v v | |
| v9<?>7v6 | |
| v v< | |
| 8 | |
| > > ^ | |
| vv < < | |
| 2 | |
| ^ v< | |
| v1<?>3v4 | |
| ^ ^ | |
| > >?> ?>5^ | |
| v v v ,*25 << | |
| v9<?>7v6 ,, | |
| v v< "" | |
| 8 >< | |
| > > ^ ""v | |
| >*: >0"!rebmun tupnI">:#,_$25*,:&:99p`|^< _0"!niw uoY">:#,_$25*,@ | |
| ^ < >:99g01-*+^ | |
| </pre> | |
| <p>Another one (inspired by the one above): | |
| </p> | |
| <pre>v>>> > v>>> > v | |
| 012 3 012 3 | |
| ^?^ ^?^ | |
| >>?#v?4>>?#v?4v | |
| v?v v?v | |
| 98765 98765 | |
| >>>>> ^>>>>> v | |
| v 0 + * + : 5 < | |
| >"!sseuG">:#,_v | |
| 0v_v#:-&:,+:5$< | |
| , v>0"!niw uoY" | |
| +0>:#,_$5:+,@ | |
| :>`0\"!"\v | |
| v"small"_"gib" | |
| ^>" ooT">:#,_$5 | |
| </pre> | |
| <h4><span id="Another_simple_game.28Tic-Tac-Toe.29"></span><span class="mw-headline" id="Another_simple_game(Tic-Tac-Toe)">Another simple game(Tic-Tac-Toe)</span></h4> | |
| <p>Create by User::PhongEsolang369 | |
| </p> | |
| <pre>>"EOT-CAT-CIT">:#,_52*,v | |
| x???v,gg20g10<<p20p10:1< | |
| y???>01g1+:01v|-4p20<>1."?",v | |
| t???XYv_v#-4p<>52*,#:^v&p34&< | |
| >1g03v 5>$101p02g1+^$>:43g\gv | |
| gvg2g<>#2 vv:&p34<| -"?"< | |
| 3>03g3gv*,v< >43g\v&>"X"\43g\pv | |
| 0>v#:++<>^"|! -"?"g<^,"?".2,*25< | |
| ^ >"X"3*-vO>$ 2."?",^ | |
| p >""# #v_0"!NIW X">:#,_@ | |
| ^301p\g34\5#< >"O"3*-#v_0"!NIW O">:#,_@ | |
| 2 , v-4:+1g30< v | |
| >*^#>#v_103p>103ggv v< | |
| ^ p30<vgg303gg302< > v | |
| >++: # "X"3*-^#^_0"!NIW X">:#,_@ | |
| v!:< "O WIN!"_v#!-*< | |
| @_, ^^ p< > "O"3^ | |
| >03^ v | |
| | -4:+1g30< | |
| >11g22g33g++:"X"3*-#v_0"!NIW X">:#,_@ | |
| "O WIN!"_v#!*3"O"< | |
| v-*3"X":++g13g22g31< | |
| >#v_0"!NIW X">:#,_@ | |
| >"O"3*#v_"!NIW O">:#,_@ | |
| # v>$$$$ | |
| </pre> | |
| <h4><span class="mw-headline" id="Calculator">Calculator</span></h4> | |
| <p>Type 1 to add, 2 to subtract, 3 to multiply, 4 to divide. | |
| </p> | |
| <pre>"rotaluclaC egnufeB">:v | |
| |,<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
| >52*:,,"/4 *3 -2 +1">:v ^^^^ | |
| |,< ^^^^ | |
| >52*:,,v^^^^ | |
| v<<<<<<<^^^^ | |
| & ^^^^ | |
| : ^^^^ | |
| 1 ^^^^ | |
| - ^^^^ | |
| v_$&&+.$>^^^^ | |
| : ^^^ | |
| 2 ^^^ | |
| - ^^^ | |
| v_$&&-.$>>>^^^ | |
| : ^^ | |
| 3 ^^ | |
| - ^^ | |
| v_$&&*.$>>>>>^^ | |
| : ^ | |
| 4 ^ | |
| - ^ | |
| @_$&&/.$>>>>>>>^ | |
| </pre> | |
| <h4><span class="mw-headline" id="99_Bottles_of_Beer">99 Bottles of Beer</span></h4> | |
| <p>Unfortunately, it doesn't work on some Befunge-93 interpreters (since the code is too large to fit in the 80x25 playfield), but it will still work on most interpreters. | |
| </p> | |
| <pre>v >v >v >v >v | |
| >992+*>:.:1`|>0" ,llaw eht no reeb fo selttob">:#,_$>:.:1`|>0".reeb fo selttob">:#,_$>91+,0" ,dnuora ti ssap dna nwod eno ekaT">:#,_$1-:|>:.:1`|>0".llaw eht no reeb fo selttob">:#,_$>91+:,,v | |
| >0" ,llaw eht no reeb fo elttob">:#,_$ ^ >0".reeb fo elttob">:#,_$ ^ v >0".llaw eht no reeb fo elttob">:#,_$ ^ | |
| >0".llaw eht no reeb fo selttob erom on">:#,_$v | |
| ^ < | |
| > v > v | |
| @<|,:<"Go to the store and buy some more, 99 bottles of beer on the wall.",+91<|,:<"No more bottles of beer on the wall, no more bottles of beer."0,,:+91< | |
| ^< ^< | |
| </pre> | |
| <p>Here's one that DOES work on all interpreters (80x25 playfield): (by <a href="/wiki/User:Tomrs123_2" title="User:Tomrs123 2">User:Tomrs123_2</a>) | |
| </p> | |
| <pre>55+55+*1->:." ,llaw eht no reeb fo selttob"v | |
| v,,,,,,,,,,,,,,,,,,,,,,,,,,,,, < | |
| >:.".reeb fo selttob"v | |
| v,,,,,,,,,,,,,,,, < | |
| >55+," ,dnuora ti ssap dna nwod eno ekaT"v | |
| v,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, < | |
| >1-:.".llaw eht no reeb fo selttob"v | |
| v,,,,,,,,,,,,,,,,,,,,,,,,,,,, < | |
| >55+:,,:2-v | |
| ^ _v | |
| v +55< | |
| >".reeb fo selttob 2 ,llaw eht no reeb fo selttob 2"v | |
| v ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, < | |
| >:,".llaw eht no reeb fo elttob 1 ,dnuora ti ssap dna nwod eno ekaT"v | |
| v ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, < | |
| >::,,".reeb fo elttob 1 ,llaw eht no reeb fo elttob 1"v | |
| v,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, < | |
| >:,".llaw eht no reeb fo selttob erom on ,dnuora ti ssap dna nwod eno ekaT"v | |
| v,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, < | |
| >55+:,".reeb fo selttob erom on ,llaw eht no reeb fo selttob erom oN"v | |
| v,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, < | |
| >,".llaw eht no reeb fo selttob 99 ,erom emos yub dna erots eht ot oG"v | |
| @,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, < | |
| </pre> | |
| <p>And here's one that's even shorter! (By <a href="/wiki/User:Darkloyd255" title="User:Darkloyd255">user:Darkloyd255</a>) | |
| </p> | |
| <pre>29+9*>:. 0 " ,llaw eht no reeb fo selttob " >:#,_ $v | |
| v < | |
| > :. 0 49+ "!reeb fo selttob " >:#,_ $ v | |
| v < | |
| > 0 " ,dnuora ti ssap ,nwod eno ekaT" >:#,_ $ 1- v | |
| > ^v < | |
| ^_v> :. 0 49+ ".llaw eht no reeb fo selttob " >:#,_ $ v | |
| ^: < | |
| > 0 " ,llaw eht no reeb fo selttob erom oN" >:#,_ v | |
| v < | |
| > 49+ "...reeb fo selttob erom on" >:#,_ v | |
| v < | |
| >",erom emos yub ,erots eht ot oG" >:#,_ v | |
| v < | |
| > "!llaw eht no reeb fo selttob 99">:#,_$@ | |
| </pre> | |
| <h4><span class="mw-headline" id="Random_Number_Generator">Random Number Generator</span></h4> | |
| <p>Input a positive integer n and output an integer chosen uniformly at random from [0,n) | |
| </p> | |
| <pre>& :v>00g2/.@ | |
| v00_^#!`/2g00:< | |
| >0p:1>>:10p` !| | |
| >+00p^?<*2g01:< | |
| ^ g00:< | |
| </pre> | |
| <h4><span id="A.2BB_Problem"></span><span class="mw-headline" id="A+B_Problem"><a href="/wiki/A%2BB_Problem" title="A+B Problem">A+B Problem</a></span></h4> | |
| <pre>&&+.@ | |
| </pre> | |
| <h4><span class="mw-headline" id="Do_Nothing">Do Nothing</span></h4> | |
| <pre>v@ | |
| >^ | |
| </pre> | |
| <p>Or simply: | |
| </p> | |
| <pre>@ | |
| </pre> | |
| <h3><span class="mw-headline" id="Befunge-98">Befunge-98</span></h3> | |
| <dl><dd><i>Main article: <a href="/wiki/Funge-98" title="Funge-98">Funge-98</a></i></dd></dl> | |
| <h4><span id="Hello.2C_world.21_.28without_string_reversion.29"></span><span class="mw-headline" id="Hello,_world!_(without_string_reversion)">Hello, world! (without string reversion)</span></h4> | |
| <pre><>>#;>:#,_@#:"Hello, World!" | |
| </pre> | |
| <h4><span class="mw-headline" id="Shorter_version_of_the_previous_one">Shorter version of the previous one</span></h4> | |
| <pre><>:#,_# @#"Hello, World!" | |
| </pre> | |
| <h4><span class="mw-headline" id="One_character_shorter">One character shorter</span></h4> | |
| <pre><>:#,_@#:"Hello, World!" | |
| </pre> | |
| <h4><span class="mw-headline" id="Multi-line_Hello_World_without_string_reversion">Multi-line Hello World without string reversion</span></h4> | |
| <pre><v"Hello, World!" | |
| >:v | |
| ^,_@ | |
| </pre> | |
| <h4><span id="Yet_another_.22Hello.2C_world.22"></span><span class="mw-headline" id='Yet_another_"Hello,_world"'>Yet another "Hello, world"</span></h4> | |
| <pre>;Hello, World!; >00ga6*1-->#@_1>:#<>#<0#<g#<:#<a#<6#<*#<1#<-#<-#<>#+>#1>#,_$$@ | |
| </pre> | |
| <p>This basically prints the characters between the semicolons. | |
| </p> | |
| <h4><span class="mw-headline" id="1D_Factorial">1D Factorial</span></h4> | |
| <pre>5 :>>#;1-:48*+01p*01g48*-#;1#+-#1:#<_$.@ | |
| </pre> | |
| <p>(the 5 is the input number) | |
| </p> | |
| <h4><span class="mw-headline" id="Convert_binary_number_to_decimal">Convert binary number to decimal</span></h4> | |
| <pre>v ;11101010; | |
| >>>>>>>>>>>>>>>a0g68*-90g68*-2*+80g68*-4*+70g68*-8*+v | |
| @.+***288-*86g03+**88-*86g04+**84-*86g05+**44-*86g06< | |
| </pre> | |
| <p>Just insert an 8-bit number between the semicolons in the first line. | |
| </p> | |
| <h4><span id="Looping_counter_.28with_newlines.29"></span><span class="mw-headline" id="Looping_counter_(with_newlines)"><a href="/wiki/Looping_counter" title="Looping counter">Looping counter</a> (with newlines)</span></h4> | |
| <pre>1v,*25< | |
| 1 . | |
| >+: ^ | |
| </pre> | |
| <h4><span class="mw-headline" id="The_Twelve_Days_of_Befungemas">The Twelve Days of Befungemas</span></h4> | |
| <p>Prints the entirety of the song "Twelve Days of Christmas". | |
| </p> | |
| <pre>0 >: 0 " eht nO" >:#,_ $ :#v_"tsrif" >:#,_ $ v | |
| >1-:#v_"dnoces" ^ < | |
| >1-:#v_"driht" ^ < | |
| >1-:#v_"htruof" ^ < | |
| >1-:#v_"htfif" ^ < | |
| >1-:#v_"htxis" ^ < | |
| >1-:#v_"htneves" ^ < | |
| >1-:#v_"hthgie" ^ < | |
| >1-:#v_"htnin" ^ < | |
| >1-:#v_"htnet" ^ < | |
| >^ >1-:#v_"htnevele" ^ | |
| >1-"htflewt" ^ | |
| v < | |
| > 0 49+ ",em ot evag evol eurt ym samtsirhc fo yad " >:#,_ $ v | |
| v < | |
| > :92+\`#v_> 0 49+ "gnimmurd sremmurd 21" >:#,_ $ v | |
| v < < | |
| > :91+\`#v_> 0 49+ "gnipip srepip nevelE" >:#,_ $ v | |
| v < < | |
| > :9\`#v_> 0 49+ "gnipael-a sdrol neT" >:#,_ $ v | |
| v < < | |
| > :8\`#v_> 0 49+ "gnicnad seidal eniN" >:#,_ $ v | |
| v < < | |
| > :7\`#v_> 0 49+ "gniklim a sdiam thgiE" >:#,_ $ v | |
| v < < | |
| > :6\`#v_> 0 49+ "gnimmiws-a snaws neveS" >:#,_ $ v | |
| v < < | |
| | > :5\`#v_> 0 49+ "gniyal-a eseeg xiS" >:#,_ $ v | |
| @ v < < | |
| # > :4\`#v_> 0 49+ "sgnir nedlog eviF" >:#,_ $ v | |
| ! v < < | |
| ` > :3\`#v_> 0 49+ "sdrib gnillac ruoF" >:#,_ $ v | |
| + v < < | |
| 2 > :2\`#v_> 0 49+ "sneh hcnerF eerhT" >:#,_ $ v | |
| 9 v < < | |
| : > :1\`#v_> 0 49+ "dna sevod-eltrut owt" >:#,_ $ v | |
| + v < < | |
| 1 > :0\`#v_> 0 49+ ".eert raep a ni egdirtrap a" >:#,_ $ v | |
| ^ < < | |
| </pre> | |
| <h2><span class="mw-headline" id="Interpreters">Interpreters</span></h2> | |
| <h3><span class="mw-headline" id="Befunge-93_Self-Interpreter">Befunge-93 Self-Interpreter</span></h3> | |
| <p>Reads a Befunge-93 program from stdin and runs it. Input program cannot be more than 20 lines high. Provide input to program in same file using <code>;</code> character to separate program from input. If you give the interpreter as input to itself, be sure to decrement the <code>4</code> in the middle of <code>*54p0</code> on the bottom line. Yes, you may provide it as input to itself running itself too, but decrement that number for each iteration. | |
| </p> | |
| <pre><xyXYvp01<>110vv5_v#`0+1:_v#+!-"g"\<v"<":::<>1v#p03-1_>! g20gp00g1+0v25p | |
| v2g02 < p0 20p<+vp020p01-10$_:"p"-!^>>-!\ v^ <>0p20pv|!*-";"\+1::~p0< | |
| v2-10<^v# ^#< <<$< < ^+!-"_"\+!-"?"<>#^_1v>vp<:^00 _$20g1+20p^ | |
| v21p010>#<40g20v> %:40p5+g:92p:75*1--00g!\#^_00p$v>4v>91+-^ | |
| <3+g01g 03p04+g<^\++g04g02:*54p03:%\++g03g01:"P"<<p0< | |
| </pre> | |
| <h3><span class="mw-headline" id="befunge93.js">befunge93.js</span></h3> | |
| <p><a class="external text" href="https://github.com/amicloud/befunge93" rel="nofollow">befunge93.js</a> is a Befunge-93 interpreter written in Javascript available as an <a class="external text" href="https://www.npmjs.com/package/befunge93" rel="nofollow">npm</a> package to use in your own applications or make your own IDE or interactive interpreter. | |
| </p><p><a class="external text" href="https://amicloud.github.io/fungide/" rel="nofollow">Fungide</a> is an interactive interpreter powered by befunge93.js. | |
| </p><p>Features: | |
| </p> | |
| <ul><li>Decent UI</li> | |
| <li>Visual program execution</li> | |
| <li>Crawl or Step through your code</li> | |
| <li>Can run your program without UI updating for fast execution</li></ul> | |
| <h3><span class="mw-headline" id="BefunExec">BefunExec</span></h3> | |
| <p><a class="external text" href="http://www.mikescher.de/programs/view/BefunUtils" rel="nofollow">BefunExec</a> is a befunge-93 interpreter written in C#. (<a class="external text" href="https://github.com/Mikescher/BefunExec" rel="nofollow">On Github</a>) | |
| It only understands the befunge-93 instruction set but can work with program sizes greater than 80x25. | |
| </p><p>It has advanced features like | |
| </p> | |
| <ul><li>breakpoints</li> | |
| <li>stepping the instruction pointer backwards</li> | |
| <li>showing a graph of the possible program flow paths</li> | |
| <li>context-aware syntax highlighting</li> | |
| <li>supporting programs with extended size (tested with an 2000x12039 program)</li></ul> | |
| <h3><span class="mw-headline" id="jsFunge_IDE">jsFunge IDE</span></h3> | |
| <p><a class="external text" href="http://esolang.rutteric.com/fungejs/" rel="nofollow">jsFunge</a> is a Befunge-93 interpreter written in Javascript. | |
| It also optionally allows use of some Befunge-97 instructions and can work with arbitrarily-sized programs. | |
| </p><p>It has most of the features of BefunExec, plus: | |
| </p> | |
| <ul><li>Multidirectional Grid Editing</li> | |
| <li>Cell Annotations</li> | |
| <li>Shareable links to annotated programs (a la TryItOnline)</li> | |
| <li>Continuously variable speed setting</li> | |
| <li>Non-blocking keyboard I/O</li> | |
| <li>I/O via xterm emulator</li> | |
| <li>Translation, rotation, and reflection of selected regions</li> | |
| <li>Somewhat usable on mobile devices</li></ul> | |
| <h3><span class="mw-headline" id="Befunge_JavaScript_interpreter"><a href="/wiki/Befunge_JavaScript_interpreter" title="Befunge JavaScript interpreter">Befunge JavaScript interpreter</a></span></h3> | |
| <p>It is a Befunge-93 interpreter by <a href="/wiki/User:None1" title="User:None1">User:None1</a>. | |
| </p><p>It has the following features: | |
| </p> | |
| <ul><li>Non-interactive I/O (since JavaScript doesn't have input)</li> | |
| <li>Division or modulo by 0 results in 0</li> | |
| <li>Unrestricted size of playfield</li></ul> | |
| <h2><span class="mw-headline" id="Related_languages">Related languages</span></h2> | |
| <p>Befunge was preceded in 1991 by a similar but less featureful language <a href="/wiki/Biota" title="Biota">Biota</a>, which was designed for experiments in self-reproduction. It was followed soon after, in 1994, by another similar language, <a href="/wiki/Orthagonal" title="Orthagonal">Orthagonal</a>, the design of which was spurred by a discussion on alt.folklore.computers. Each of these three languages originated (as far as anyone can tell) completely independently of the other two. | |
| </p><p>Befunge has also provided inspiration to the design of subsequent languages, the most similar of these are known as <a href="/wiki/Fungeoid" title="Fungeoid">fungeoids</a>. Most of the languages are not similar enough to be called direct descendants, but often the author mentions the influence of Befunge in the accompanying commentary. Fungeoid languages include | |
| </p> | |
| <ul><li><a href="/wiki/Wierd" title="Wierd">Wierd</a>, a two-dimensional <a href="/wiki/Turing_tarpit" title="Turing tarpit">Turing tarpit</a></li> | |
| <li><a href="/wiki/Befreak" title="Befreak">Befreak</a>, a reversible language</li> | |
| <li><a href="/wiki/PATH" title="PATH">PATH</a>, which adds elements of <a href="/wiki/Brainfuck" title="Brainfuck">Brainfuck</a></li> | |
| <li><a href="/wiki/Flobnar" title="Flobnar">Flobnar</a>, a "functional-programming" fungeoid</li> | |
| <li><a href="/wiki/Fish" title="Fish">><></a>, a two-dimensional esolang inspired by Befunge</li> | |
| <li><a href="/wiki/Ndim" title="Ndim">Ndim</a>, a multidimensional language in which the only working memory available is the code space itself</li> | |
| <li><a href="/wiki/Nopfunge" title="Nopfunge">Nopfunge</a> is a minimalization of Befunge. It has only the direction changing commands but remains Turing complete.</li></ul> | |
| <h2><span class="mw-headline" id="External_resources">External resources</span></h2> | |
| <h3><span class="mw-headline" id="Befunge-93">Befunge-93</span></h3> | |
| <ul><li><a class="external text" href="https://catseye.tc/projects/befunge93/doc/befunge93.html" rel="nofollow">Befunge-93 documentation.</a></li> | |
| <li><a class="external text" href="http://www.tutorialspoint.com/compile_befunge_online.php" rel="nofollow">Befunge-93 Online Compilation.</a></li> | |
| <li><a class="external text" href="http://www.quirkster.com/iano/js/befunge.html" rel="nofollow">JavaScript Befunge-93 interpreter.</a></li> | |
| <li><a class="external text" href="https://github.com/programble/befungee" rel="nofollow">befungee</a>, a Befunge-93 interpreter written in python, with a debugger and a concurrent mode.</li> | |
| <li><a class="external text" href="http://bephunge.sadowl.com/" rel="nofollow">Bephunge</a>, an implementation of Befunge-93 in PHP (command-line) (<a class="external text" href="https://github.com/graue/esofiles/blob/master/befunge/impl/bephunge.phps" rel="nofollow">mirror</a> in <a href="/wiki/The_Esoteric_File_Archive" title="The Esoteric File Archive">the Esoteric File Archive</a>).</li> | |
| <li><a class="external text" href="https://github.com/graue/esofiles/tree/master/befunge/src/" rel="nofollow">Befunge programs</a> in <a href="/wiki/The_Esoteric_File_Archive" title="The Esoteric File Archive">the Esoteric File Archive</a>.</li> | |
| <li><a class="external text" href="https://sourceforge.net/projects/yabi93/" rel="nofollow">YaBI93</a> - multiplatform Befunge93 interpreter (with IDE) for Java 1.5.</li> | |
| <li><a class="external text" href="https://github.com/serprex/Befunge" rel="nofollow">Marsh/Bejit/funge.py/bf.vim</a> Fast interpreters/quasi JITs & a vim debug mode. <a class="external text" href="https://serprex.github.io/Befunge" rel="nofollow">now with a WASM JIT online</a></li> | |
| <li><a class="external text" href="http://befunge.aurlien.net" rel="nofollow">Another interpreter in JavaScript</a> - (<a class="external text" href="https://github.com/arnemart/befungius" rel="nofollow">On GitHub</a>)</li> | |
| <li><a class="external text" href="https://adrianton3.github.io/befunjit/demos/visualizer-lazy/visualizer.html" rel="nofollow">Befunjit</a> - A just-in-time compiler for Befunge-93</li> | |
| <li><a class="external text" href="https://github.com/nilp0inter/awkfunge" rel="nofollow">awkfunge</a> Befunge-93 interpreter written in AWK.</li> | |
| <li><a class="external text" href="https://github.com/CzechsMix/FungePP" rel="nofollow">FungePP</a> Interpreter for Funge++, a Procedural Befunge-93 Extension, written in C++</li> | |
| <li><a class="external text" href="https://github.com/Mikescher/BefunCompile" rel="nofollow">BefunCompile</a> a restricted Befunge-93 to C (and C#, and Python) compiler</li> | |
| <li><a class="external text" href="https://github.com/fbastos1/beefunge" rel="nofollow">Beefunge</a> A Befunge-93 graphical IDE written in C++. Features a field as large as Funge-98. Currently under testing and development.</li> | |
| <li><a class="external text" href="https://github.com/DarkKitsune/NemFunge93" rel="nofollow">NemFunge93</a> Command line Befunge-93 interpreter written in imperative Nemerle for .NET and Mono.</li> | |
| <li><a class="external text" href="https://github.com/FreedomSka/befunge" rel="nofollow">FreedomSka/befunge</a> - More befunge code examples</li> | |
| <li><a class="external text" href="https://befunje.ivan.sh/" rel="nofollow">Befunje</a> - Befunge-93 interpreter with visualization</li> | |
| <li><a class="external text" href="https://github.com/amicloud/befunge93" rel="nofollow">befunge93.js</a> is a Befunge-93 interpreter written in Javascript available as an <a class="external text" href="https://www.npmjs.com/package/befunge93" rel="nofollow">npm</a> package</li> | |
| <li><a class="external text" href="https://amicloud.github.io/fungide/" rel="nofollow">Fungide</a> is a visual interactive interpreter powered by befunge93.js.</li> | |
| <li><a class="external text" href="http://esolang.rutteric.com/fungejs/index.html" rel="nofollow">jsFunge</a> is a fully-featured browser-based Befunge-93 development environment.</li> | |
| <li><a class="external text" href="https://github.com/Camroku/befunpy" rel="nofollow">BefunPY</a> is a Befunge-93 interpreter written in Python with extension support and a few built-in extensions</li> | |
| <li><a class="external text" href="https://github.com/kleinesfilmroellchen/boxfunge" rel="nofollow">Boxfunge</a> is a Befunge-93 interpreter and just-in-time-compiler written in Rust.</li> | |
| <li><a class="external text" href="https://github.com/DoctorDanD/befunge-93-plus" rel="nofollow">Befunge-93+</a> is another interpreter for Befunge-93 written in Rust. It also expands the playing field to a near-infinite size.</li> | |
| <li><a class="external text" href="https://none-none1.github.io/Interpret-Esolangs-Online/" rel="nofollow">Interpret Esolangs Online</a> is a webpage by <a href="/wiki/User:None1" title="User:None1">User:None1</a> that can run programs in many esolangs including Befunge-93. It supports unrestricted size of playfield.</li> | |
| <li><a class="external text" href="https://www.luogu.com/article/82g3vjyv" rel="nofollow">A Chinese-language explanation of Befunge-93</a> on Luogu <b>NOTE</b>: This page may contain mistakes. The division command actually rounds down. The "skip" command actually skips a cell.</li></ul> | |
| <h3><span class="mw-headline" id="Befunge-98_and_beyond">Befunge-98 and beyond</span></h3> | |
| <ul><li><a class="external text" href="https://catseye.tc/node/Funge-98.html" rel="nofollow">Funge-98 documentation.</a></li> | |
| <li><a class="external text" href="https://codeberg.org/catseye/Funge-98/src/branch/master/doc/funge98.markdown" rel="nofollow">Funge-98 specification</a></li> | |
| <li><a class="external text" href="http://quadium.net/funge/" rel="nofollow">vsync's Funge stuff.</a></li> | |
| <li><a class="external text" href="https://github.com/tngreene/BefungeSharp" rel="nofollow">BefungeSharp</a> A Funge-98 IDE written in C#. Features a command-line editor and a compliant interpreter.</li> | |
| <li><a class="external text" href="https://web.archive.org/web/20070322234225/http://www.teepop.net/fungus/" rel="nofollow">Fungus</a> <i>(from the <a class="extiw" href="https://en.wikipedia.org/wiki/Wayback_Machine" title="wikipedia:Wayback Machine">Wayback Machine</a>; retrieved on 22 March 2007)</i> - a nice Befunge-98 IDE for Win32. Warning: its interperter is not fully standards compliant.</li> | |
| <li><a class="external text" href="https://web.archive.org/web/20060925154455/http://kotisivu.mtv3.fi/quux/befunge.html" rel="nofollow">mooz' Befunge page</a> <i>(from the <a class="extiw" href="https://en.wikipedia.org/wiki/Wayback_Machine" title="wikipedia:Wayback Machine">Wayback Machine</a>; retrieved on 25 September 2006)</i> - contains a Javascript interpreter and several interesting Befunge programs.</li> | |
| <li><a class="external text" href="http://www.purplehatstands.com/bequnge" rel="nofollow">BeQunge</a> A cross-platform Funge-98 interpreter, code editor, and debugger. Works in any number of dimensions.</li> | |
| <li><a class="external text" href="http://www.quote-egnufeb-quote-greaterthan-colon-hash-comma-underscore-at.info/befunge/" rel="nofollow">J^4: Befunge</a> Jeffrey Lee's Befunge site, features plenty of interesting programs.</li> | |
| <li><a class="external text" href="http://www.iki.fi/deewiant/" rel="nofollow">Mycology and CCBI</a> A complete Befunge-98 test suite based on the specification, and an interpreter which passes all the tests.</li> | |
| <li><a class="external text" href="https://github.com/VorpalBlade/cfunge" rel="nofollow">cfunge</a> - Small fast Befunge-98 interpreter in C, standard compliant.</li> | |
| <li><a class="external text" href="https://web.archive.org/web/20220426161352/http://rcfunge98.com/index.html" rel="nofollow">Rc/Funge-98</a> - Compliant Funge-98 implementation in C; diagnostics, tutorials and documentation, fingerprints include the TRDS time traveler.</li> | |
| <li><a class="external text" href="http://cubonegro.orgfree.com/sponge/sponge.html" rel="nofollow">Sponge</a> - a compiler (in Common Lisp) from a tiny subset of Scheme to Befunge 98.</li> | |
| <li><a class="external text" href="http://mearie.org/projects/pyfunge/" rel="nofollow">PyFunge</a> - A Befunge-93/Funge-98 interpreter in Python. Its goal is a fully functional, compliant and optimizing implementation of Funge-98.</li> | |
| <li><a class="external text" href="http://hackage.haskell.org/package/Fungi" rel="nofollow">Fungi</a> - A standards compliant Funge-98 interpreter and debugger written in Haskell.</li> | |
| <li><a class="external text" href="https://web.archive.org/web/20200426013923/https://tech.labs.oliverwyman.com/blog/2012/08/25/tdd-for-esoteric-programming-languages-using-clojure-and-befunge/" rel="nofollow">Closidrium</a> <i>(from the <a class="extiw" href="https://en.wikipedia.org/wiki/Wayback_Machine" title="wikipedia:Wayback Machine">Wayback Machine</a>; retrieved on 26 April 2020)</i> - Author retrospective of creating a Befunge-98 Interpreter in Clojure.</li> | |
| <li><a class="external text" href="https://github.com/TieSoul/Multilang" rel="nofollow">Multilang</a> - A shell supporting multiple languages, including Befunge-98.</li> | |
| <li><a class="external text" href="https://github.com/Mikescher/BefunGen" rel="nofollow">BefunGen</a> - A Befunge compiler / code generator, compiles to Befunge code from a c-like language</li> | |
| <li><a class="external text" href="https://github.com/electrodude/fungewars" rel="nofollow">Fungewars</a> - A programming game in Funge-98.</li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20251207141404 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.070 seconds | |
| Real time usage: 0.124 seconds | |
| Preprocessor visited node count: 340/1000000 | |
| Post‐expand include size: 3394/2097152 bytes | |
| Template argument size: 1087/2097152 bytes | |
| Highest expansion depth: 5/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 55429/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 15.063 1 -total | |
| 70.73% 10.654 3 Template:Catseye | |
| 9.63% 1.450 3 Template:Wayback | |
| 8.95% 1.348 1 Template:Infobox_proglang | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:1005-0!canonical and timestamp 20251207141404 and revision id 170190. Rendering was triggered because: diff-page | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b>Binary lambda calculus</b> (<b>BLC</b>) is an extremely small Turing-complete language which can be represented as a series of bits or bytes. Unlike <a href="/wiki/Binary_combinatory_logic" title="Binary combinatory logic">Binary combinatory logic</a>, another binary language with a similar acronym, it is capable of input and output. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#BLC_Syntax"><span class="tocnumber">1</span> <span class="toctext">BLC Syntax</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Basic_Program_Information"><span class="tocnumber">2</span> <span class="toctext">Basic Program Information</span></a></li> | |
| <li class="toclevel-1 tocsection-3"><a href="#SKI_combinator_calculus"><span class="tocnumber">3</span> <span class="toctext">SKI combinator calculus</span></a></li> | |
| <li class="toclevel-1 tocsection-4"><a href="#BLC8"><span class="tocnumber">4</span> <span class="toctext">BLC8</span></a></li> | |
| <li class="toclevel-1 tocsection-5"><a href="#Programs_(BLC)"><span class="tocnumber">5</span> <span class="toctext">Programs (BLC)</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-6"><a href="#self-interpreter"><span class="tocnumber">5.1</span> <span class="toctext">self-interpreter</span></a></li> | |
| <li class="toclevel-2 tocsection-7"><a href="#prime_number_sieve"><span class="tocnumber">5.2</span> <span class="toctext">prime number sieve</span></a></li> | |
| <li class="toclevel-2 tocsection-8"><a href="#Brainfuck_interpreter"><span class="tocnumber">5.3</span> <span class="toctext">Brainfuck interpreter</span></a></li> | |
| <li class="toclevel-2 tocsection-9"><a href="#Universal_Turing_Machine"><span class="tocnumber">5.4</span> <span class="toctext">Universal Turing Machine</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-10"><a href="#Programs_(BLC8)"><span class="tocnumber">6</span> <span class="toctext">Programs (BLC8)</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-11"><a href="#self-interpreter_2"><span class="tocnumber">6.1</span> <span class="toctext">self-interpreter</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-12"><a href="#Computational_Class"><span class="tocnumber">7</span> <span class="toctext">Computational Class</span></a></li> | |
| <li class="toclevel-1 tocsection-13"><a href="#See_Also"><span class="tocnumber">8</span> <span class="toctext">See Also</span></a></li> | |
| <li class="toclevel-1 tocsection-14"><a href="#External_Resources"><span class="tocnumber">9</span> <span class="toctext">External Resources</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="BLC_Syntax">BLC Syntax</span></h2> | |
| <p>The BLC program is a sequence of bits read left to right. The following commands are defined. Feel free to change how the commands are explained if you think it's too confusing. | |
| </p> | |
| <ul><li><code>00x</code> = Lambda function with body x</li> | |
| <li><code>x0</code>, where x is one or more "1" bits = the number of "1" bits serves as the <a href="/wiki/De_Bruijn_indexing" title="De Bruijn indexing">De Bruijn index</a>, 1-indexed | |
| <ul><li>For example <code>10</code> corresponds to a De Bruijn index of 1, <code>110</code> to 2, <code>1110</code> to 3, etc.</li> | |
| <li>To be clear, this means 10 refers to the final lambda, 110 to the second-last, 1110 to the third-last, etc.</li></ul></li> | |
| <li><code>01xy</code>, where x and y are more code = x is applied to y. | |
| <ul><li>By default, the output of a lambda is one term in this language. Using 01 allows the function to output both x and y, which is the same as applying x to y in lambda calculus because both of the outputs are also lambdas.</li> | |
| <li>If you want to take in one input and output it once, you would write 0010 = 00 10.</li> | |
| <li>If you want to take in one input and output it twice, you would write 00011010 = 00 01 10 10.</li> | |
| <li>If you want to take in two inputs and output the first one three times, you would write 00000101110110110 = 00 00 01 01 110 110 110.</li> | |
| <li>If you want to output code directly starting with 00, it doesn't need to have 01 directly before it. If there is a term before the function, then 01 is needed before the term.</li></ul></li></ul> | |
| <p>It is possible for the code to have padding at the right end, i.e. code which doesn't affect the result of the command. This fact is especially useful when trying to use bytes to represent this language. | |
| </p> | |
| <h2><span class="mw-headline" id="Basic_Program_Information">Basic Program Information</span></h2> | |
| <p>A program is a lambda calculus term that transforms an input to an output. Standard input is represented as a list of boolean values, and standard output has the same format. | |
| </p><p>A 0 bit in BLC is 0000110 (True), and a 1 bit is 000010 (False), which are the normal lambda calculus representations of these values. | |
| </p> | |
| <pre>0000110 = 00 00 110 | |
| *taking two inputs (with the two lambda functions represented by 00), return the second argument from the inside i.e. the first argument | |
| 000010 = 00 00 10 | |
| *taking two inputs (with the two lambda functions represented by 00), return the innermost / last argument i.e. the second argument | |
| </pre> | |
| <p>The empty list, called nil, is 000010 (False). | |
| </p><p>A list with multiple elements is represented by the pairing or cons function 00010110xy, where x is the head of the list and y is the tail. | |
| </p> | |
| <pre>00010110xy = 00 01 01 10 x y | |
| *taking one input, output that input, the head of the list, and the tail of the list | |
| </pre> | |
| <p>You might expect programs to consist of multiple bytes, considering all of these have been six bits or over. However, printing out input in this language is done through the code <code>0010</code>, which takes one input (which is the innermost by default) and prints it out. Because padding is ignored and lambdas only output one term by default in this language, a program consisting of just a cat can be represented by any bytes between 32 (00100000) and 47 (00101111) because everything after 0010 is ignored (remember that you have to type 00011010 to output the input twice). | |
| </p> | |
| <h2><span class="mw-headline" id="SKI_combinator_calculus"><a class="mw-redirect" href="/wiki/SKI_combinator_calculus" title="SKI combinator calculus">SKI combinator calculus</a></span></h2> | |
| <p>The encoding of lambda term S is λxλyλz.((xz)(yz)), which is written as λλλ.((3 1)(2 1)) using De Bruijn indexes instead of names, and as 00 00 00 01 01 1110 10 01 110 10 in BLC. | |
| </p><p>The K combinator is written as λxλy.x or λλ.2 in a corresponding format, so it would be 00 00 110 in BLC. | |
| </p><p>The identity function I is the same as the cat: 00 10. | |
| </p><p>Therefore, you can implement SKI combinator calculus in BLC. | |
| </p> | |
| <h2><span class="mw-headline" id="BLC8">BLC8</span></h2> | |
| <p>BLC operates on a stream of bits (values of 0 and 1), while BLC8 is the same, but operates on a stream of bytes (values from 0 - 255) with the most significant bit in the smallest value (big-endian). In the following programs, BLC and BLC8 programs are put into different parts. | |
| </p> | |
| <h2><span id="Programs_.28BLC.29"></span><span class="mw-headline" id="Programs_(BLC)">Programs (BLC)</span></h2> | |
| <h3><span class="mw-headline" id="self-interpreter">self-interpreter</span></h3> | |
| <pre> 01010001 | |
| 10100001 | |
| 00000001 | |
| 10000001 | |
| 01110011 | |
| 00001111 | |
| 11100001 | |
| 01110011 | |
| 1111100000 | |
| 011110000001 | |
| 01110111001101 | |
| 1110011111111000 | |
| 01111111 10000101 | |
| 11101001 11010010 | |
| 11111010 01011010 | |
| 10011010 00011001 | |
| 00011010 00011010 | |
| </pre> | |
| <h3><span class="mw-headline" id="prime_number_sieve">prime number sieve</span></h3> | |
| <pre>000100011001100101000110100 | |
| 000000101100000100100010101 | |
| 11110111 101001000 | |
| 11010000 111001101 | |
| 000000000010110111001110011 | |
| 11111011110000000011111001 | |
| 10111000 | |
| 00010110 | |
| 0000110110 | |
| </pre> | |
| <h3><span class="mw-headline" id="Brainfuck_interpreter"><a href="/wiki/Brainfuck" title="Brainfuck">Brainfuck</a> interpreter</span></h3> | |
| <pre>0000000 01a15144 02d55584 223070b7 00f032ff | |
| 0000020 7f85f9bf 956fe15e c0ee7d7f 006854e5 | |
| 0000040 fbfd5558 fd5745e0 b6f0fbeb 07d62ff0 | |
| 0000060 d7736fe1 c0bc14f1 1f2eff0b 17666fa1 | |
| 0000100 2fef5be8 ff13ffcf 2034cae1 0bd0c80a | |
| 0000120 e51fee99 6a5a7fff ff0fff1f d0049d87 | |
| 0000140 db0500ab 3bb74023 b0c0cc28 10740e6c | |
| 0000160 | |
| </pre> | |
| <h3><span class="mw-headline" id="Universal_Turing_Machine">Universal Turing Machine</span></h3> | |
| <pre>0101000110100001000000011000000101110011000011111 | |
| 1100001011100111111100000011110000001011101110011 | |
| 0111100111111110000111111110000101111010011101001 | |
| 0111110100101101010011010000110010001101000011010 | |
| </pre> | |
| <h2><span id="Programs_.28BLC8.29"></span><span class="mw-headline" id="Programs_(BLC8)">Programs (BLC8)</span></h2> | |
| <h3><span class="mw-headline" id="self-interpreter_2">self-interpreter</span></h3> | |
| <pre> 19468 | |
| 05580 | |
| 05f00 | |
| bfe5f | |
| 85f3f | |
| 03c2d | |
| b9fc3f8 | |
| 5e9d65e5f | |
| 0decb f0fc3 | |
| 9befe 185f7 | |
| 0b7fb 00cf6 | |
| 7bb03 91a1a | |
| </pre> | |
| <p><br/> | |
| There is also a universal Turing machine written in BLC8 which is slightly longer than the one in BLC. | |
| </p> | |
| <h2><span class="mw-headline" id="Computational_Class">Computational Class</span></h2> | |
| <p>Lambda calculus is Turing-complete, and because binary lambda calculus is a way of writing lambda calculus, it is also Turing-complete. It can also implement SKI combinator calculus as seen above, so it is Turing-complete in that way. As a final indication of Turing-completeness, Brainfuck and a Universal Turing Machine have both been represented in this language. | |
| </p> | |
| <h2><span class="mw-headline" id="See_Also">See Also</span></h2> | |
| <ul><li><a href="/wiki/Binary_combinatory_logic" title="Binary combinatory logic">Binary combinatory logic</a></li></ul> | |
| <h2><span class="mw-headline" id="External_Resources">External Resources</span></h2> | |
| <ul><li><a class="external text" href="https://web.archive.org/web/20161019165606/https://en.wikipedia.org/wiki/Binary_lambda_calculus" rel="nofollow">Binary lambda calculus at Wikipedia</a> <i>(from the <a class="extiw" href="https://en.wikipedia.org/wiki/Wayback_Machine" title="wikipedia:Wayback Machine">Wayback Machine</a>; retrieved on 19 October 2016)</i></li> | |
| <li><a class="extiw" href="https://en.wikipedia.org/wiki/Binary_combinatory_logic" title="wikipedia:Binary combinatory logic">Wikipedia:Binary combinatory logic</a></li> | |
| <li><a class="external text" href="https://tromp.github.io/cl/Binary_lambda_calculus.html" rel="nofollow">John's BLC Explanation</a></li> | |
| <li><a class="external text" href="https://tromp.github.io/cl/cl.html" rel="nofollow">John's Lambda Calculus and Combinatory Logic Playground</a></li> | |
| <li><a class="external text" href="https://www.ioccc.org/2012/tromp/index.html" rel="nofollow">IOCCC 2012 Description of BLC and BLC8</a></li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20251223205553 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.016 seconds | |
| Real time usage: 0.053 seconds | |
| Preprocessor visited node count: 91/1000000 | |
| Post‐expand include size: 239/2097152 bytes | |
| Template argument size: 115/2097152 bytes | |
| Highest expansion depth: 4/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 1993/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 12.651 1 Template:Wayback | |
| 100.00% 12.651 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:2753-0!canonical and timestamp 20251223205553 and revision id 171068. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><table style="float:right;border:1px solid silver;background-color:rgb(249, 249, 249);max-width:256px;padding:5px;"> | |
| <caption><b>bitch</b></caption> | |
| <tbody><tr> | |
| <th style="text-align: left;vertical-align: top;"><a href="/wiki/Esolang:Categorization#Paradigm" title="Esolang:Categorization">Paradigm(s)</a></th> | |
| <td>imperative, structured</td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;">Designed by</th> | |
| <td><a href="/wiki/User:Helen" title="User:Helen">User:Helen</a></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;"><a href="/wiki/Category:Years" title="Category:Years">Appeared in</a></th> | |
| <td><a href="/wiki/Category:2019" title="Category:2019">2019</a></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;"><a href="/wiki/Esolang:Categorization#Memory" title="Esolang:Categorization">Memory system</a></th> | |
| <td>accumulator-based</td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;"><a href="/wiki/Esolang:Categorization#Dimensions" title="Esolang:Categorization">Dimensions</a></th> | |
| <td>one-dimensional</td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;"><a href="/wiki/Computational_class" title="Computational class">Computational class</a></th> | |
| <td><a href="/wiki/Category:Turing_complete" title="Category:Turing complete">Turing complete</a></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;">Reference implementation</th> | |
| <td><a class="external text" href="https://github.com/Helen0903/bitch" rel="nofollow">bitch v4.12</a></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;">Major implementations</th> | |
| <td><a class="external text" href="https://github.com/Helen0903/bitch" rel="nofollow">bitch v4.12</a> <a class="external free" href="https://github.com/int-e/bits" rel="nofollow">https://github.com/int-e/bits</a></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;">Influenced by</th> | |
| <td>BITCHWISE</td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;">File extension(s)</th> | |
| <td>Unspecified</td> | |
| </tr> | |
| </tbody></table> | |
| <p><a class="mw-selflink selflink">bitch</a> (alternatively <a class="mw-selflink selflink">bit**</a>) is a minimalistic language created by <a href="/wiki/User:Helen" title="User:Helen">User:Helen</a> inspired by <a class="new" href="/w/index.php?title=User:Arphimigon&action=edit&redlink=1" title="User:Arphimigon (page does not exist)">User:Arphimigon</a>'s BITCHWISE<sup class="reference" id="cite_ref-1"><a href="#cite_note-1">[1]</a></sup>. | |
| </p><p>It has a total of 15 instructions<sup class="reference" id="cite_ref-2"><a href="#cite_note-2">[2]</a></sup> (one of which is no-op<sup class="reference" id="cite_ref-nope_3-0"><a href="#cite_note-nope-3">[3]</a></sup>) and a (technically) infinite number of instruction characters, as all unrecognised characters are no-ops<sup class="reference" id="cite_ref-nope_3-1"><a href="#cite_note-nope-3">[3]</a></sup>. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Etymology"><span class="tocnumber">1</span> <span class="toctext">Etymology</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Storage"><span class="tocnumber">2</span> <span class="toctext">Storage</span></a></li> | |
| <li class="toclevel-1 tocsection-3"><a href="#Instruction_Set"><span class="tocnumber">3</span> <span class="toctext">Instruction Set</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-4"><a href="#Flow_Instructions"><span class="tocnumber">3.1</span> <span class="toctext">Flow Instructions</span></a> | |
| <ul> | |
| <li class="toclevel-3 tocsection-5"><a href="#Basic_Flow_Instructions"><span class="tocnumber">3.1.1</span> <span class="toctext">Basic Flow Instructions</span></a></li> | |
| <li class="toclevel-3 tocsection-6"><a href="#Conditional_Flow_Instructions"><span class="tocnumber">3.1.2</span> <span class="toctext">Conditional Flow Instructions</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-2 tocsection-7"><a href="#I/O_Instructions"><span class="tocnumber">3.2</span> <span class="toctext">I/O Instructions</span></a></li> | |
| <li class="toclevel-2 tocsection-8"><a href="#Bitwise_Instructions"><span class="tocnumber">3.3</span> <span class="toctext">Bitwise Instructions</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-9"><a href="#Shift_Storage"><span class="tocnumber">4</span> <span class="toctext">Shift Storage</span></a></li> | |
| <li class="toclevel-1 tocsection-10"><a href="#Computational_class"><span class="tocnumber">5</span> <span class="toctext">Computational class</span></a></li> | |
| <li class="toclevel-1 tocsection-11"><a href="#Common_Algorithms"><span class="tocnumber">6</span> <span class="toctext">Common Algorithms</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-12"><a href="#Addition"><span class="tocnumber">6.1</span> <span class="toctext">Addition</span></a></li> | |
| <li class="toclevel-2 tocsection-13"><a href="#Subtraction"><span class="tocnumber">6.2</span> <span class="toctext">Subtraction</span></a></li> | |
| <li class="toclevel-2 tocsection-14"><a href="#More_Bitwise_Operations"><span class="tocnumber">6.3</span> <span class="toctext">More Bitwise Operations</span></a> | |
| <ul> | |
| <li class="toclevel-3 tocsection-15"><a href="#The_^^_Trick"><span class="tocnumber">6.3.1</span> <span class="toctext">The ^^ Trick</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-2 tocsection-16"><a href="#Swapping_two_values"><span class="tocnumber">6.4</span> <span class="toctext">Swapping two values</span></a></li> | |
| <li class="toclevel-2 tocsection-17"><a href="#Bounded_storage"><span class="tocnumber">6.5</span> <span class="toctext">Bounded storage</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-18"><a href="#A_Turing_machine"><span class="tocnumber">7</span> <span class="toctext">A Turing machine</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-19"><a href="#Data_layout"><span class="tocnumber">7.1</span> <span class="toctext">Data layout</span></a></li> | |
| <li class="toclevel-2 tocsection-20"><a href="#Circuit_building_blocks"><span class="tocnumber">7.2</span> <span class="toctext">Circuit building blocks</span></a></li> | |
| <li class="toclevel-2 tocsection-21"><a href="#Implementing_the_Turing_machine"><span class="tocnumber">7.3</span> <span class="toctext">Implementing the Turing machine</span></a></li> | |
| <li class="toclevel-2 tocsection-22"><a href="#Finishing_touches"><span class="tocnumber">7.4</span> <span class="toctext">Finishing touches</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-23"><a href="#Popular_Problem_solutions_in_bitch"><span class="tocnumber">8</span> <span class="toctext">Popular Problem solutions in bitch</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-24"><a href="#Possible"><span class="tocnumber">8.1</span> <span class="toctext">Possible</span></a> | |
| <ul> | |
| <li class="toclevel-3 tocsection-25"><a href="#Truth-machine"><span class="tocnumber">8.1.1</span> <span class="toctext">Truth-machine</span></a></li> | |
| <li class="toclevel-3 tocsection-26"><a href="#Infinite_loop"><span class="tocnumber">8.1.2</span> <span class="toctext">Infinite loop</span></a></li> | |
| <li class="toclevel-3 tocsection-27"><a href="#Looping_counter"><span class="tocnumber">8.1.3</span> <span class="toctext">Looping counter</span></a></li> | |
| <li class="toclevel-3 tocsection-28"><a href="#Binary_to_unary_conversion"><span class="tocnumber">8.1.4</span> <span class="toctext">Binary to unary conversion</span></a></li> | |
| <li class="toclevel-3 tocsection-29"><a href="#Fibonacci_sequence"><span class="tocnumber">8.1.5</span> <span class="toctext">Fibonacci sequence</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-2 tocsection-30"><a href="#Possible_with_adjustments"><span class="tocnumber">8.2</span> <span class="toctext">Possible with adjustments</span></a> | |
| <ul> | |
| <li class="toclevel-3 tocsection-31"><a href="#Cat_program"><span class="tocnumber">8.2.1</span> <span class="toctext">Cat program</span></a></li> | |
| <li class="toclevel-3 tocsection-32"><a href="#Hello,_world!"><span class="tocnumber">8.2.2</span> <span class="toctext">Hello, world!</span></a></li> | |
| <li class="toclevel-3 tocsection-33"><a href="#Quine"><span class="tocnumber">8.2.3</span> <span class="toctext">Quine</span></a></li> | |
| <li class="toclevel-3 tocsection-34"><a href="#ROT13"><span class="tocnumber">8.2.4</span> <span class="toctext">ROT13</span></a></li> | |
| <li class="toclevel-3 tocsection-35"><a href="#99_bottles_of_beer"><span class="tocnumber">8.2.5</span> <span class="toctext">99 bottles of beer</span></a></li> | |
| <li class="toclevel-3 tocsection-36"><a href="#Mandelbrot_set"><span class="tocnumber">8.2.6</span> <span class="toctext">Mandelbrot set</span></a></li> | |
| <li class="toclevel-3 tocsection-37"><a href="#Bounded-storage_machine:_brainfuck_interpreter"><span class="tocnumber">8.2.7</span> <span class="toctext">Bounded-storage machine: brainfuck interpreter</span></a></li> | |
| </ul> | |
| </li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-38"><a href="#Implementation"><span class="tocnumber">9</span> <span class="toctext">Implementation</span></a></li> | |
| <li class="toclevel-1 tocsection-39"><a href="#References"><span class="tocnumber">10</span> <span class="toctext">References</span></a></li> | |
| <li class="toclevel-1 tocsection-40"><a href="#See_also"><span class="tocnumber">11</span> <span class="toctext">See also</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Etymology">Etymology</span></h2> | |
| <p>BITCHWISE's name is a portmanteau between "bitch" and "bitwise". It originates from the word "bitwise", as to mean "bitwise operations" - the only mathematical operations available in both languages.<br/> | |
| The usage of the expletive "bitch" in "BITCHWISE" is to convey anger in a brusque and uncouth manner.<br/> | |
| These combine to help convey the combination of difficulty and esoteric design in the language. | |
| </p><p><a class="mw-selflink selflink">bitch</a>'s name, in turn, originates from a shortening of BITCHWISE, its influencer.<br/> | |
| However, the "bitwise" is deleted from the name, implying that bitch doesn't contain any interesting esotericism but rather only agonising language design.<br/> | |
| This is quite reflective of the language, which keeps the same core concepts of BITCHWISE whilst significantly pushing the limits of what is necessary. | |
| </p> | |
| <h2><span class="mw-headline" id="Storage">Storage</span></h2> | |
| <p><a class="mw-selflink selflink">bitch</a> has a single place to store values, the accumulator. | |
| </p><p>The value of the accumulator is accessible by every function, but certain functions don't use them.<br/> | |
| Some instructions in bitch allow a constant integer to be input as a second (or sometimes only) parameter. | |
| </p> | |
| <h2><span class="mw-headline" id="Instruction_Set">Instruction Set</span></h2> | |
| <p>There are 3 types of instructions, which I will call flow, I/O<sup class="reference" id="cite_ref-io_4-0"><a href="#cite_note-io-4">[4]</a></sup> and bitwise instructions<sup class="reference" id="cite_ref-5"><a href="#cite_note-5">[5]</a></sup>. | |
| </p><p>Many of the major implementations implement the rest of the commands as syntax errors, and the program will exit immediately.<br/> | |
| However, this was ignored in the documentation, and is therefore not portable. | |
| </p> | |
| <h3><span class="mw-headline" id="Flow_Instructions">Flow Instructions</span></h3> | |
| <hr/> | |
| <p>There are 5 flow instructions, 2 of which are conditional instructions<sup class="reference" id="cite_ref-6"><a href="#cite_note-6">[6]</a></sup>.<br/> | |
| Basic flow instructions do not use the accumulator value, however, the conditional flow instructions do. | |
| </p> | |
| <h4><span class="mw-headline" id="Basic_Flow_Instructions">Basic Flow Instructions</span></h4> | |
| <ul><li><code>></code> - marks the beginning of a loop block</li> | |
| <li><code><</code> - jumps to the latest marked <code>></code> (this causes undefined behaviour if there is no beginning <code>></code>)</li> | |
| <li><code>.</code> - ends the program</li></ul> | |
| <p>So <code>>code<</code>, where <code>code</code> contains no <code><</code> nor <code>></code>, is a loop that will run the code <code>code</code> indefinitely. | |
| </p> | |
| <h4><span class="mw-headline" id="Conditional_Flow_Instructions">Conditional Flow Instructions</span></h4> | |
| <ul><li><code>:</code> - only executes the next instruction if the value in the accumulator is equal to 0</li> | |
| <li><code>;</code> - only executes the next instruction if the value in the accumulator is NOT equal to 0</li></ul> | |
| <p>This makes clever usage of conditionals essential for short code, as a conditional block is completely impossible. | |
| </p><p>Each instruction would have to be preceded by a conditional symbol, doubling the length of the conditional code. | |
| </p> | |
| <h3><span id="I.2FO_Instructions"></span><span class="mw-headline" id="I/O_Instructions">I/O Instructions</span></h3> | |
| <hr/> | |
| <p>There are only two <i>actual</i> I/O<sup class="reference" id="cite_ref-io_4-1"><a href="#cite_note-io-4">[4]</a></sup> instructions, since <a class="mw-selflink selflink">bitch</a> is a relatively restricted language.<br/> | |
| In addition, there is a number literal form which is also included here. | |
| </p> | |
| <ul><li><code>\</code> - stores one integer of input in the accumulator and clears the storage</li> | |
| <li><code>/</code> - outputs the accumulator value</li> | |
| <li><code>#number</code> - stores the specified constant in the accumulator and clears the storage</li></ul> | |
| <p>Certain implementations will implement other I/O<sup class="reference" id="cite_ref-io_4-2"><a href="#cite_note-io-4">[4]</a></sup> operations, such as character I/O.<br/> | |
| For example, <a href="/wiki/User:Helen" title="User:Helen">Helen</a>'s <a class="external text" href="https://github.com/Helen0903/bitch" rel="nofollow">GitHub</a> interpreter implements a flag to turn on character I/O. | |
| </p><p>However, only integer I/O is specified as part of the language.<br/> | |
| Any other I/O is implementation specific and will need to be researched for that specific implementation. | |
| </p> | |
| <h3><span class="mw-headline" id="Bitwise_Instructions">Bitwise Instructions</span></h3> | |
| <hr/> | |
| <p>There are 6 bitwise instructions, less than the normal set of bitwise instructions. | |
| </p><p>This is because other instructions can be formed from a combination of these. | |
| </p> | |
| <ul><li><code>&number</code> - AND bitwise instruction, equivalent to <code>accumulator</code> AND <code>number</code></li> | |
| <li><code>|number</code> - OR bitwise instruction, equivalent to <code>accumulator</code> OR <code>number</code></li> | |
| <li><code>~</code> - NOT bitwise instruction, equivalent to finding the 1's complement of a number</li> | |
| <li><code>^number</code> - XOR bitwise instruction, equivalent to <code>accumulator</code> XOR <code>number</code></li> | |
| <li><code>[number</code> - left shift instruction, equivalent to <code>accumulator</code> left shift by <code>number</code></li> | |
| <li><code>]number</code> - right shift instruction, equivalent to <code>accumulator</code> right shift by <code> number</code></li></ul> | |
| <p>In the above (including the section on I/O<sup class="reference" id="cite_ref-io_4-3"><a href="#cite_note-io-4">[4]</a></sup> instructions), <code>number</code> can be either a number literal (without a <code>#</code>) or any valid <a class="mw-selflink selflink">bitch</a> instruction. | |
| </p><p>In case that <code>number</code> is an instruction, the given instruction is evaluated on a copy of the accumulator and storage and the resulting accumulator value is used as the argument for the instruction.<br/> | |
| In particular this means that any effect that instruction has on the storage and accumulator will be discarded.<br/> | |
| Non-I/O effects, i.e., termination (by <code>.</code>) or remembering or jumping to a code block (by <code>></code> or <code><</code>), are discarded as well. | |
| </p><p>When bitshifting, there is no such thing as sign extension or no sign extension since integers in bitch are supposed to be of infinite precision.<br/> | |
| Therefore, there are no empty spaces to fill since there are an infinite number of digits leftwards and there is always a digit that can replace another. | |
| </p> | |
| <h2><span class="mw-headline" id="Shift_Storage">Shift Storage</span></h2> | |
| <p>When bit-shifting, a bit storage is used. | |
| </p><p>Right shifting (<code>]</code>) moves bits from the end of the binary number into the top of the storage.<br/> | |
| Left shifting (<code>[</code>) moves bits from the top of the storage into the end of the binary number. | |
| </p><p>Number literals and input reset this storage.<br/> | |
| However, when used as an argument to bitwise operators, they do not. | |
| </p><p>This simply means that: | |
| </p> | |
| <ul><li>When you right shift a binary number <code>abcdefg</code> by <code>3</code> places, you store <code>efg</code> and the accumulator is set to <code>abcd</code>.</li> | |
| <li>When you left shift a binary number <code>abcdefg</code> by <code>3</code> places and the storage is empty, the accumulator is set to <code>abcdefg000</code> and nothing is stored.</li> | |
| <li>When you left shift a binary number <code>abcdefg</code> by <code>3</code> places and the storage is set to <code>hijk</code>, the accumulator is set to <code>abcdefghij</code> and the storage is set to <code>k</code>.</li> | |
| <li>When you use either <code>#number</code> or <code>\</code>, the storage is emptied.</li> | |
| <li>When you use <code><u>x</u>number</code> where <u><code>x</code></u> is a bitwise operator (but not a bitshift), the storage remains unchanged.</li></ul> | |
| <h2><span class="mw-headline" id="Computational_class">Computational class</span></h2> | |
| <p><a class="mw-selflink selflink">bitch</a> is <a href="/wiki/Turing-complete" title="Turing-complete">Turing-complete</a> (see <a href="#A_Turing_machine"><i>A Turing machine</i></a> ). | |
| </p><p>In particular, <a class="mw-selflink selflink">bitch</a> can simulate any <a href="/wiki/Finite-state_automaton" title="Finite-state automaton">finite-state automaton</a>.<br/> | |
| The storage can easily be used as a stack (using <code>]</code> for push and <code>[</code> for pop), so <a class="mw-selflink selflink">bitch</a> is also capable of implementing <a class="mw-redirect" href="/wiki/Push-down_automata" title="Push-down automata">push-down automata</a>.<br/> | |
| For practical programming, using the <a href="#Bounded_storage">bounded random-access memory</a> is more convenient than the Turing machine construction. | |
| </p> | |
| <h2><span class="mw-headline" id="Common_Algorithms">Common Algorithms</span></h2> | |
| <p>This section is simply for the purpose of documenting useful algorithms in <a class="mw-selflink selflink">bitch</a>. | |
| </p> | |
| <h3><span class="mw-headline" id="Addition">Addition</span></h3> | |
| <pre>\]32|\>[32^]32]32&^[32^^[1&-2]32&0[32;<[32/</pre> | |
| <p>The logic behind this is fairly simple: | |
| </p><p>Given <code>a</code> and <code>b</code>, the carry overs are <code>a AND b</code>, which would become <code>(a AND b) LS 1</code> when carried over.<br/> | |
| The bits that stay in place are <code>a XOR b</code>. | |
| </p><p><code>a</code> becomes <code>a XOR b</code> and <code>b</code> becomes <code>(a AND b) LS 1</code>. | |
| </p><p>Given that the new value of <code>b</code> is non-zero, we repeat this.<br/> | |
| The value of <code>a</code> after the end of repetitions is the correct value of the sum. | |
| </p><p>Or in pseudocode: | |
| </p> | |
| <pre>a <- input # a is stored in the lower 32 bits of the storage | |
| b <- input # b is stored in the accumulator | |
| while (b != 0) { | |
| a <- a XOR b | |
| b <- (b AND (b XOR a)) LS 1 # (b XOR a) is the original value of a! | |
| }</pre> | |
| <h3><span class="mw-headline" id="Subtraction">Subtraction</span></h3> | |
| <pre>\]32|\>[32^]32]32&[32^^[1&-2]32&0[32;<[32/</pre> | |
| <p>The logic is the same as for addition, except that the carry is <code>(b AND (a XOR b)) LS 1</code>. | |
| </p><p>For operands of known size, it is possible to avoid the use of <code>></code> and <code><</code> by unrolling the inner loop, which allows some simplifications. | |
| For example, 8-bit subtraction can be implemented by | |
| </p> | |
| <pre> SUB(8) = | |
| ]8|[7 | |
| [8^]15]8&[15 | |
| [7^]14]7&[14 | |
| [6^]13]6&[13 | |
| [5^]12]5&[12 | |
| [4^]11]4&[11 | |
| [3^]10]3&[10 | |
| [2^]9 ]2&[9 | |
| [1^]8 ]1 | |
| &0[8 | |
| </pre> | |
| <h3><span class="mw-headline" id="More_Bitwise_Operations">More Bitwise Operations</span></h3> | |
| <p>There are 16 different bitwise operations on two operands.<br/> | |
| We can derive the 8 operations that map 0,0 to 0 per the following table, where <i>a</i> is an accumulator bit and <i>b</i> is the corresponding bit in the other operand <i>B</i>. | |
| </p> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <th rowspan="2">op | |
| </th> | |
| <th><i>a</i>=0</th> | |
| <th>0</th> | |
| <th>1</th> | |
| <th>1</th> | |
| <th rowspan="2">code</th> | |
| <th rowspan="2">comment | |
| </th> | |
| <th rowspan="2">op | |
| </th> | |
| <th><i>a</i>=0</th> | |
| <th>0</th> | |
| <th>1</th> | |
| <th>1</th> | |
| <th rowspan="2">code</th> | |
| <th rowspan="2">comment | |
| </th></tr> | |
| <tr> | |
| <th><i>b</i>=0</th> | |
| <th>1</th> | |
| <th>0</th> | |
| <th>1 | |
| </th> | |
| <th><i>b</i>=0</th> | |
| <th>1</th> | |
| <th>0</th> | |
| <th>1 | |
| </th></tr> | |
| <tr> | |
| <th style="text-align:right;">0 | |
| </th> | |
| <td style="text-align:right;">0</td> | |
| <td>0</td> | |
| <td>0</td> | |
| <td>0 | |
| </td> | |
| <td><code>&0</code>, <code>^|&B</code></td> | |
| <td>the variant may be useful if <code>B</code> does I/O | |
| </td> | |
| <th style="text-align:right;"><i>a</i> AND <i>b</i> | |
| </th> | |
| <td style="text-align:right;">0</td> | |
| <td>0</td> | |
| <td>0</td> | |
| <td>1 | |
| </td> | |
| <td><code>&B</code></td> | |
| <td>built in | |
| </td></tr> | |
| <tr> | |
| <th style="text-align:right;"><i>a</i> AND (NOT <i>b</i>) | |
| </th> | |
| <td style="text-align:right;">0</td> | |
| <td>0</td> | |
| <td>1</td> | |
| <td>0 | |
| </td> | |
| <td><code>&^B</code></td> | |
| <td> | |
| </td> | |
| <th style="text-align:right;"><i>a</i> | |
| </th> | |
| <td style="text-align:right;">0</td> | |
| <td>0</td> | |
| <td>1</td> | |
| <td>1 | |
| </td> | |
| <td><code></code>, <code>|&B</code></td> | |
| <td>the variant may be useful if <code>B</code> does I/O | |
| </td></tr> | |
| <tr> | |
| <th style="text-align:right;">(NOT <i>a</i>) AND <i>b</i> | |
| </th> | |
| <td style="text-align:right;">0</td> | |
| <td>1</td> | |
| <td>0</td> | |
| <td>0 | |
| </td> | |
| <td><code>^|B</code></td> | |
| <td> | |
| </td> | |
| <th style="text-align:right;"><i>b</i> | |
| </th> | |
| <td style="text-align:right;">0</td> | |
| <td>1</td> | |
| <td>0</td> | |
| <td>1 | |
| </td> | |
| <td><code>^^B</code></td> | |
| <td>see below | |
| </td></tr> | |
| <tr> | |
| <th style="text-align:right;"><i>a</i> XOR <i>b</i> | |
| </th> | |
| <td style="text-align:right;">0</td> | |
| <td>1</td> | |
| <td>1</td> | |
| <td>0 | |
| </td> | |
| <td><code>^B</code></td> | |
| <td>built in | |
| </td> | |
| <th style="text-align:right;"><i>a</i> OR <i>b</i> | |
| </th> | |
| <td style="text-align:right;">0</td> | |
| <td>1</td> | |
| <td>1</td> | |
| <td>1 | |
| </td> | |
| <td><code>|B</code></td> | |
| <td>built in | |
| </td></tr></tbody></table> | |
| <p>The remaining 8 bitwise operations can be obtained by first computing the complement of the result and then executing <code>~</code>.<br/> | |
| The constant 1 function and NOT <i>a</i> can also be computed in a single instruction, using <code>|-1</code> and <code>~</code>, respectively. | |
| </p> | |
| <h4><span id="The_.5E.5E_Trick"></span><span class="mw-headline" id="The_^^_Trick">The ^^ Trick</span></h4> | |
| <p>The <code>^^</code> case is surprisingly useful. | |
| </p><p>The effect of <code>^^i</code> on the accumulator is that of <code>i</code> but without modifying the storage.<br/> | |
| To wit, if the old accumulator value is A, and the new accumulator value after <code>i</code> is B, then the resulting accumulator after <code>^^i</code> is A^(A^B) = B.<br/> | |
| However, it does not modify the storage, as <code>i</code> is working on a copy of the current state and <code>^</code> doesn't affect the storage directly either. | |
| </p><p>Examples: | |
| </p> | |
| <ul><li><code>^^n</code> sets the accumulator to n without clearing the storage</li> | |
| <li><code>^^[8</code> shifts the accumulator to the left, copying the lower 8 bits of storage into the lower 8 bit of the accumulator in reverse order</li> | |
| <li><code>^^]8</code> shifts the accumulator to the right, destroying 8 bits</li></ul> | |
| <h3><span class="mw-headline" id="Swapping_two_values">Swapping two values</span></h3> | |
| <pre>\[32\^]32^[32^]32/ | |
| </pre> | |
| <p>Equivalent to the C alternative <code>x^=y^=x^=y</code>. | |
| </p><p>This is limited to 32 bits, but it can be extended.<br/> | |
| It outputs both of the values as 1 value. | |
| </p><p>Here is an alternate version: | |
| </p> | |
| <pre>\[32\^]32^[32^]32]32/&0[32/ | |
| </pre> | |
| <h3><span class="mw-headline" id="Bounded_storage">Bounded storage</span></h3> | |
| <p><a class="mw-selflink selflink">bitch</a> can implement bounded storage in the form of random-access memory with fixed address and word size. | |
| </p><p>To this end, the storage is filled alternatingly with data words and the corresponding address.<br/> | |
| Adresses are given in bits, and must be aligned to two times the word size. | |
| </p><p>We will call the word size <i>B</i>, and assume it's a power of 2.<br/> | |
| Furthermore, we define <i>M = 2<sup>B</sup></i> and <i>m = M-1</i>. | |
| </p><p>There are two key operations, <code>PEEK</code> and <code>POKE</code>. | |
| </p><p>The operation <code>PEEK</code> takes an address in the accumulator and replaces it by the value at that address: | |
| </p> | |
| <pre> # comment format: # accumulator | reverse storage | |
| PEEK = # A | ... A W ... | |
| ^^[^<i>B</i> # A ... A W | ... A W ... | |
| ]<i>B</i>&0[<i>B</i> # W | ... A W ... | |
| </pre> | |
| <p>The operation <code>POKE</code> takes two words in the accumulator, with the address in the lower word, and the value to be written in the upper word: | |
| </p> | |
| <pre> # comment format: # accumulator | reverse storage | |
| POKE = # X A | ... A W (A+2<i>B</i>) ... | |
| [&<i>m</i> # X A ... A | W (A+2<i>B</i>) ... | |
| [<i>B</i> # X A ... A W | (A+2<i>B</i>) ... | |
| &-<i>M</i> # X A ... A 0 | (A+2<i>B</i>) ... | |
| ^^[<i>B</i> # X A ... A 0 (A+2B) | (A+2<i>B</i>) ... | |
| ^]&<i>m</i> # X A ... A X ?? | (A+2<i>B</i>) ... | |
| ^^]<i>B</i> # X A ... A X | (A+2<i>B</i>) ... | |
| ]<i>B</i> # X A ... A | X (A+2<i>B</i>) ... | |
| ]&<i>m</i> # X A | ... A X (A+2<i>B</i>) ... | |
| </pre> | |
| <p>Note that <code>POKE</code> relies on the stored <code>(A+2<i>B</i>)</code> value in order to find the original accumulator. | |
| </p><p>Memory can be initialized as follows, | |
| </p> | |
| <pre> INIT = >DEC&-(2<i>B</i>)](2<i>B</i>)|[(2<i>B</i>);<[(2<i>B</i>) | |
| </pre> | |
| <p>where <code>DEC</code> is a loop-free <i>B</i>-bit decrement operation. | |
| </p> | |
| <h2><span class="mw-headline" id="A_Turing_machine">A Turing machine</span></h2> | |
| <p>Any <a href="/wiki/Turing_machine" title="Turing machine">Turing machine</a> is characterized by a transition function that takes a state and a tape value, and produces a new tape value, a new state, and whether to move the read head left, right, or not at all before the next step.<br/> | |
| If we encode states as binary strings, the transition function can be computed by a Boolean circuit<sup class="reference" id="cite_ref-7"><a href="#cite_note-7">[7]</a></sup>. | |
| </p> | |
| <h3><span class="mw-headline" id="Data_layout">Data layout</span></h3> | |
| <p>We store the left part of the tape and the current state in the accumulator, and the right part of the tape in the storage. | |
| </p><p>In order to implement the Boolean circuit, we use only every third bit of the accumulator/store data, encoding the bit <i>b</i> as <code><span style="color:blue">0</span> <i>b</i> <span style="color:blue">0</span></code>.<br/> | |
| Let us write <code><<i>b</i>></code> for the encoding of a bit, that is, <code><span style="color:blue">0</span> <i>b</i> <span style="color:blue">0</span></code>.<br/> | |
| For lists of bits, <code><<i>x<sub>0</sub>...x<sub>n-1</sub></i>></code> expands to <code><<i>x<sub>0</sub></i>>...<<i>x<sub>n-1</sub></i>></code>. | |
| </p><p>In addition to storing bits as triplets, we use the lowest bit of the accumulator as a one-bit accumulator <i>A</i>. | |
| </p> | |
| <h3><span class="mw-headline" id="Circuit_building_blocks">Circuit building blocks</span></h3> | |
| <p>In order to implement arbitrary Boolean circuits, we define the following basic operations. | |
| </p> | |
| <ul><li>Set, clear, or negate <i>A</i>.</li></ul> | |
| <pre> STA := |1 | |
| CLA := &-2 | |
| NOTA := ^1 | |
| </pre> | |
| <ul><li>Set, clear, or negate <i>b<sub>n</sub></i>.</li></ul> | |
| <pre> SET(<i>n</i>) := |{1<<3*<i>n</i>+1} | |
| CLR(<i>n</i>) := &{~(1<<3*<i>n</i>+1)} | |
| NOT(<i>n</i>) := ^{1<<3*<i>n</i>+1} | |
| </pre> | |
| <ul><li>Store <i>A</i> into <i>b<sub>n</sub></i>. Note that <code>^[{3*<i>n</i>+1}</code> copies bits in the left tape part of the accumulator to unused <code><span style="color:blue">0</span></code> bits; these copies are cleaned up again by <code>&]{3*<i>n</i>+1}</code>.</li></ul> | |
| <pre> STORE(<i>n</i>) := SET(<i>n</i>) ^[{3*<i>n</i>+1} NOT(<i>n</i>) &]{3*<i>n</i>+1} | |
| </pre> | |
| <ul><li>Or <i>A</i> with <i>b<sub>n</sub></i>. This is a slight variation of <code>LOAD</code>. This follows the same basic principle as <code>STORE</code>, but we need to add some scratch space first because otherwise the cleanup <code>&[{3*<i>n</i>+1}</code> would destroy <i>3n</i> precious bits.</li></ul> | |
| <pre> OR(<i>n</i>) := ^^[{3*<i>n</i>+1} |]{3*<i>n</i>+1} |1 &[{3*<i>n</i>+1} ^^]{3*<i>n</i>+1} | |
| </pre> | |
| <ul><li>Load <i>A</i> from <i>b<sub>n</sub></i>.</li></ul> | |
| <pre> LOAD(<i>n</i>) := CLA OR(<i>n</i>) | |
| </pre> | |
| <p>These operations are sufficient for encoding arbitrary Boolean circuits (we have negation, binary or, and arbitrary fan-out). | |
| </p> | |
| <h3><span class="mw-headline" id="Implementing_the_Turing_machine">Implementing the Turing machine</span></h3> | |
| <p>Using the basic building blocks from the previous section, we can program a circuit that takes as input a Turing machine configuration encoded in the form | |
| </p> | |
| <pre> ... <<i>k</i>> <<i>l</i>> <<i>ss</i>> <<span style="color:blue">0</span>> <<span style="color:blue">0</span>> <<span style="color:blue">0</span>> <<span style="color:blue">0</span>> <<i>r</i>> | <<i>q</i>> ... | |
| </pre> | |
| <p>where <i>...:k:l</i> is the left part of the tape, <i>r:q:...</i> is the right part of the tape, and <i>ss</i> is the current state as a string of bits, possibly padded to make room for scratch bits. The circuit produces as output | |
| </p> | |
| <pre> ... <<i>k</i>> <<i>l'</i>> <<i>ss'</i>> <<span style="color:blue">0</span>> <<span style="color:blue">0</span>> <<span style="color:blue">0</span>> <<span style="color:blue">0</span>> <<i>r</i>> | <<i>q</i>> ... # if standing still | |
| ... <<i>k</i>> <<i>l'</i>> <<i>r</i>> <<i>ss'</i>> <<span style="color:green">1</span>> <<span style="color:blue">0</span>> <<span style="color:blue">0</span>> <<span style="color:blue">0</span>> | <<i>q</i>> ... # if moving left | |
| ... <<i>k</i>> <<i>ss'</i>> <<span style="color:blue">0</span>> <<span style="color:blue">0</span>> <<span style="color:blue">0</span>> <<span style="color:green">1</span>> <<i>l'</i>> <<i>r</i>> | <<i>q</i>> ... # if moving right | |
| </pre> | |
| <p>where <i>ss'</i> and <i>l'</i> are the new state and tape symbol, respectively. | |
| </p><p>The actual move of the tape head can then be performed by: | |
| </p> | |
| <pre> ADJUST := ]9 LOAD(0) [&3 [3 LOAD(0) ]&3 [6 &{~((3<<3)|(3<<12))} | |
| </pre> | |
| <p>The whole Turing machine can then be implemented as a loop of the following shape, where <i>s</i> is the initial state, <i>circuit</i> implements the transition function circuit, and the tape starts out empty: | |
| </p> | |
| <pre> MAIN := #<i>s</i> [15 > <i>circuit</i> ADJUST < | |
| </pre> | |
| <h3><span class="mw-headline" id="Finishing_touches">Finishing touches</span></h3> | |
| <p><big><b>Termination:</b></big> | |
| </p><p>One can implement a halting state that stops the machine when the tape contents to the left is empty: | |
| </p> | |
| <pre> ]15 ^<i>h</i> :. ^<i>h</i> [15 | |
| </pre> | |
| <p>where <i>h</i> is the integer encoding the halting state. | |
| </p><p>Alternatively, one can replace the main program as follows (this variant allows later code to be executed): | |
| </p> | |
| <pre> MAIN := #<i>(s XOR h)</i> > ^<i>h</i> [15 <i>circuit</i> ADJUST ]15 ^<i>h</i> ;< | |
| </pre> | |
| <hr/> | |
| <p><big><b>All-at-once input and output:</b></big> | |
| </p><p>We can easily prepend a loop that reads all input and stores it to the right (in reverse order), and append a loop that outputs the remaining data on the tape after the Turing machine halts. | |
| </p> | |
| <hr/> | |
| <p><big><b>Interactive input and output:</b></big> | |
| </p><p>Because <code>\</code> and <code>/</code> operate on the whole accumulator, and the accumulator contains the tape contents to the left of the head, interactive I/O will only work when the tape to the left is empty.<br/> | |
| Even then it is tricky, but a proof of concept is implemented in the <a href="#Bounded-storage_machine:_brainfuck_interpreter">bounded storage Brainfuck interpreter</a>. | |
| </p> | |
| <h2><span class="mw-headline" id="Popular_Problem_solutions_in_bitch">Popular Problem solutions in <a class="mw-selflink selflink">bitch</a></span></h2> | |
| <p>These are solutions (written in <a class="mw-selflink selflink">bitch</a>) to problems on the <a href="/wiki/Popular_problem" title="Popular problem">Popular Problems</a> page. | |
| </p> | |
| <h3><span class="mw-headline" id="Possible">Possible</span></h3> | |
| <h4><span class="mw-headline" id="Truth-machine"><a href="/wiki/Truth-machine" title="Truth-machine">Truth-machine</a></span></h4> | |
| <p>Will print nothing if input doesn't equal 0 or 1 (behaviour here not defined by the article). | |
| </p> | |
| <pre>\:/:.&-2;.#1>/<</pre> | |
| <h4><span class="mw-headline" id="Infinite_loop"><a href="/wiki/Infinite_loop" title="Infinite loop">Infinite loop</a></span></h4> | |
| <p>This is pretty straightforward: | |
| </p> | |
| <pre>><</pre> | |
| <h4><span class="mw-headline" id="Looping_counter"><a href="/wiki/Looping_counter" title="Looping counter">Looping counter</a></span></h4> | |
| <p>This counts from 99 to 1: | |
| </p> | |
| <pre>#99>/]7^1[7^]7]7&[7[6^]6]6&[6[5^]5]5&[5[4^]4]4&[4[3^]3]3&[3[2^]2]2&[2[1^]1]1&[1&0[7;<</pre> | |
| <p>Counting to infinity in powers of 2 minus 1.<br/> | |
| The counter here is <code>log<sub>2</sub>(accumulator + 1) - 1</code>, it goes from 1 to the size of the accumulator (assuming an unsigned accumulator): | |
| </p> | |
| <pre>#1>/|[1<</pre> | |
| <h4><span class="mw-headline" id="Binary_to_unary_conversion"><a href="/wiki/Binary_to_unary_conversion" title="Binary to unary conversion">Binary to unary conversion</a></span></h4> | |
| <p>This is definitely "cheating", as it does not use replaces and is only binary to unary by a technicality.<br/> | |
| The maximum input size is 7 bits and input must be in decimal form - <a class="mw-selflink selflink">bitch</a> stores numbers in binary but takes in input in decimal. | |
| </p> | |
| <pre>\>]7^^0/^1[7^]7]7&[7[6^]6]6&[6[5^]5]5&[5[4^]4]4&[4[3^]3]3&[3[2^]2]2&[2[1^]1]1&[1&0[7;<</pre> | |
| <h4><span class="mw-headline" id="Fibonacci_sequence"><a href="/wiki/Fibonacci_sequence" title="Fibonacci sequence">Fibonacci sequence</a></span></h4> | |
| <p>Prints out the first few <a class="mw-redirect" href="/wiki/Fibonacci_number" title="Fibonacci number">Fibonacci numbers</a>.<br/> | |
| This doesn't show anything about the language as its output is constant. | |
| </p> | |
| <pre>#0/#1/#1/#2/#3/#5/#8/#13/#21/#34/#55/#89/#144/#233/#377/#610/#987/#1597/#2584/#4181/</pre> | |
| <h3><span class="mw-headline" id="Possible_with_adjustments">Possible with adjustments</span></h3> | |
| <p>The most common adjustment is to do character-based I/O, where <code>\</code> stores the Unicode value of the next character (-1 on EOF) and <code>/</code> outputs a character with the given Unicode value.<br/> | |
| A byte-oriented version is possible as well. | |
| </p> | |
| <h4><span class="mw-headline" id="Cat_program"><a href="/wiki/Cat_program" title="Cat program">Cat program</a></span></h4> | |
| <p>We use character-based I/O. | |
| </p> | |
| <pre>>\/<</pre> | |
| <p>This is a variation that halts on EOF: | |
| </p> | |
| <pre>>\^-1:.^-1/<</pre> | |
| <p>A simplified program that is equivalent to the program above: | |
| </p> | |
| <pre>>\~:.~/<</pre> | |
| <p>Reverse cat (reverses input per line): | |
| </p> | |
| <pre>\~>]32&\~;<>&0[32:.]32~[32~/<</pre> | |
| <h4><span id="Hello.2C_world.21"></span><span class="mw-headline" id="Hello,_world!"><a href="/wiki/Hello,_world!" title="Hello, world!">Hello, world!</a></span></h4> | |
| <p>We use character-based I/O. | |
| </p> | |
| <pre>#72/#101/#108/#108/#111/#44/#32/#119/#111/#114/#108/#100/#33/</pre> | |
| <p>In Chinese: | |
| </p> | |
| <pre>#20320/#22909/#65292/#19990/#30028/</pre> | |
| <h4><span class="mw-headline" id="Quine"><a href="/wiki/Quine" title="Quine">Quine</a></span></h4> | |
| <p>See <a href="/wiki/List_of_quines#bitch" title="List of quines">List of Quines</a> for a quine using character-based I/O. | |
| </p> | |
| <h4><span class="mw-headline" id="ROT13"><a class="mw-redirect" href="/wiki/ROT13" title="ROT13">ROT13</a></span></h4> | |
| <p>We use character-based I/O. The following is a naive ROT13 implementation that replaces A by N, B by O, and so on, testing for each case individually. This should make for an interesting golfing exercise. | |
| </p> | |
| <pre class="rectwrap">>\~:.~^65:^271^3:^269^1:^275^7:^277^1:^279^3:^277^1:^275^15:^285^1:^287^3:^285^1:^275^7:^277^1:^279^3:^15^1:^13^31:^19^1:^21^3:^23^1:^21^7:^19^1:^29^3:^31^1:^29^15:^19^1:^21^3:^23^59:^271^3:^269^1:^275^7:^277^1:^279^3:^277^1:^275^15:^285^1:^287^3:^285^1:^275^7:^277^1:^279^3:^15^1:^13^31:^19^1:^21^3:^23^1:^21^7:^19^1:^29^3:^31^1:^29^15:^19^1:^21^3:^23^122]8&0[8/<</pre> | |
| <p>Similar, but handling lower and upper case in one go (cf. <a class="external text" href="https://github.com/int-e/bits/blob/d8d5bd1989dab81b6b2e4f9b554cf204d437cfb0/examples/rot13.pp" rel="nofollow">rot13.pp</a> for some comments): | |
| </p> | |
| <pre class="rectwrap">>\~:.~]8|[8|32^97:^47^3:^45^1:^51^7:^53^1:^55^3:^53^1:^51^15:^61^1:^63^3:^61^1:^51^7:^53^1:^55^3:^15^1:^13^31:^19^1:^21^3:^23^1:^21^7:^19^1:^29^3:^31^1:^29^15:^19^1:^21^3:^23^90[8&-8416^]8&255/<</pre> | |
| <p>Another version using a lookup table (cf. <a class="external text" href="https://github.com/int-e/bits/blob/d8d5bd1989dab81b6b2e4f9b554cf204d437cfb0/examples/rot13-lut.pp" rel="nofollow">rot13-lut.pp</a>): | |
| </p> | |
| <pre class="rectwrap">>\]8;.|[11|256^9495516882517365034402269903000168120394070347137372457794342656^^]&2040&31^[8&255/<</pre> | |
| <h4><span class="mw-headline" id="99_bottles_of_beer"><a href="/wiki/99_bottles_of_beer" title="99 bottles of beer">99 bottles of beer</a></span></h4> | |
| <p><a class="external text" href="https://tio.run/##5d3LbhNBEIXhh/Eaue62Xwc2ZEOQyPNj4mvGIIUNJr91Fh4pnZ6Z6s5JFp9qJp@fXr583e9XvVkfPxnr1W67Xrn74TCXgx3G7DjWp1mnGRaLc47fP02q5SS3y1fHS9V51mlo93ry5nqH10Odz71DSXU8b73a1uWmm5taLsW@DZldx3eLlRxPPs28ru063MuSrM/1vp1W10veXOVm3cP4UZz36/AhlXW/nXqchDQzIc1LSIsmpJgJKV5CSjQhyUxI8hKSogkJZkKCl5AQTYgzE@K8hLhoQoyZEOMlxDQTUjtkQihl3W@nHichW2ZCtryEbAUTMhy8XCZkeKY6oqY6TFMdnqmOqKkO01SHZ6ojaqrDNNXhmeqImuowTXV4pjqipjpMUx2eqY6oqQ7TVIdnqiNqqsM01eGZ6oia6jBNdXimOqKmOkxTHZ6pjqipNtNUm2eqLWqqzTTV5plqi5pqM021eabaoqbaTFNtnqm2qKk201SbZ6otaqrNNNXmmWqLmmozTbV5ptqiptpMU22eqbaoqTbTVJtnqi1qqs001eaZaouaajFNtXimWqKmWkxTLZ6plqipFtNUi2eqJWqqxTTV4plqiZpqMU21eKZaoqZaTFMtnqmWqKkW01SLZ6olaqrFNNXimWqJmmoxTbV4plqiplpMUy2eqZaoqSbTVJNnqilqqsk01eSZaoqaajJNNXmmmqKmmkxTTZ6ppqipJtNUk2eqKWqqyTTV5JlqippqMk01eaaaoqaaTFNNnqmmqKkm01STZ6opaqrJNNXkmWqKmmowTTV4phqiphpMUw2eqYaoqQbTVINnqiFqqsE01eCZaoiaajBNNXimGqKmGkxTDZ6phqipBtNUg2eqIWqqwTTV4JlqiJpqME01eKYaoqYaTFMNnqmGqKk601SdZ6ouaqrONFXnmaqLmqozTdV5puqipupMU3WeqbqoqTrTVJ1nqi5qqs40VeeZqouaqjNN1Xmm6qKm6kxTdZ6puqipOtNUnWeqLmqqzjRV55mqi5qqMU3VeKZqoqZqTFM1nqmaqKka01SNZ6omaqrGNFXjmaqJmqoxTdV4pmqipmpMUzWeqZqoqRrTVI1nqiZqqsY0VeOZqomaqjFN1XimaqKmakxTNZ6pmqapHn4rgKZKKut@O/U4CRlmQoaXkBFNSDMT0ryEtGhCipmQ4iWkRBOSzIQkLyEpmpBgJiR4CQnRhDgzIc5LiIsmxJgJMV5CTDMhQFMllXW/nXqchGyZCdnyEqLYpwrsUYX1pyr2pgL7UmE9qYr9qMBeVFgfqmIPKrD/FNZ7Kvo/p4Bv8Ye9wV/xXWTA95DB3kGm@DQl8ElK2FOUiv1gwF4wWB@Yomj9dc3/FbI@uJp/vi8PEYPTiF8r2F2nL/cL9Kdjs32Aej9icy@btPHlPU@X9Heq7@Ws3yr7I3inWg/DcXsBv6zP3lntUgI5Xrrf/3z@/vL0/O3H/tOXXw" rel="nofollow">Try it Online</a>.<br/> | |
| This cheats and does not use loops. | |
| </p> | |
| <h4><span class="mw-headline" id="Mandelbrot_set"><a href="/wiki/Mandelbrot_set" title="Mandelbrot set">Mandelbrot set</a></span></h4> | |
| <p>See <a class="external text" href="https://tio.run/##7VtJDsIwDHxMz6gQAw@CC71QJHg/Yadb6ri0JW4zB0uIIlTNjD1x4uyyy/5gbUImRTCx3jJB999s0mS1BE6d8XM8A45CDM1Ld4944kjAsguGT9zoHaaGJ5XwLH0GnoweqcCPi7pOY8eU85WyJr24buPLf4mf@HybxVTwf63vFUHNqNdTV343nlGBrVjbxqF10677Sg7NPBckuv4F8y5R8cvSO3y/pzh8tE33ocKpBTPfnGjL/dA8ODmYWW3i@pMxa0/vuqVgzSRes/QN0scBywcp4IRkuHbhQTMHUp//Nydcj9RYf9TXIBKOSGeN0ugh0vriw/Oz7zKXHAnBB6tnGkBfpN83JD38mHx4fYAG1piZMB8jcOH1ZVPd650qdiFywrfv5fXUidePMfOg4RXAJVjfh3xQmA/wB6yZsGZCPxFZbqDf1ttvYz9K75kG9mx17dnibEPn2QbO/uKYl8R5OOZDMB@CmSnMEWKOEDO1mBnHzDjuOOAeDu6IQZu4t6j4Hq211/x0yfLj2S72Nw" rel="nofollow">Try it Online</a> for code which reproduces the ASCII output of a Mandlebrot set plot without calculation. | |
| </p> | |
| <h4><span class="mw-headline" id="Bounded-storage_machine:_brainfuck_interpreter"><a href="/wiki/Bounded-storage_machine" title="Bounded-storage machine">Bounded-storage machine</a>: <a href="/wiki/Brainfuck" title="Brainfuck">brainfuck</a> <a href="/wiki/Interpreter" title="Interpreter">interpreter</a></span></h4> | |
| <p>This bounded <a class="external text" href="https://github.com/int-e/bits/blob/d8d5bd1989dab81b6b2e4f9b554cf204d437cfb0/examples/brainfuck" rel="nofollow">brainfuck interpreter</a> by <a href="/wiki/User:Int-e" title="User:Int-e">User:int-e</a> uses 16 bit cells and is limited to a maximum nested loop depth of 63, and combined data area and program size of ~1900 cells. | |
| </p> | |
| <h2><span class="mw-headline" id="Implementation">Implementation</span></h2> | |
| <p>A nice n-line implementation of the latest spec of <a class="mw-selflink selflink">bitch</a> is possible in Java: | |
| </p> | |
| <pre>TODO</pre> | |
| <p>A .jar might be available <a class="external text" href="https://puu.sh/xxxxx/TODO.jar" rel="nofollow">here</a>.<br/> | |
| If so, you can use it like this: | |
| </p> | |
| <pre>java -jar bitch.jar</pre> | |
| <p>This implementation has an infinite loop of getting the next line (on which a bitch program would be written) and then running the bitch program.<br/> | |
| All bitch instructions are compatible with this implementation. | |
| </p><p>Alternate implementations are available at <a class="external text" href="https://tio.run/#bitch" rel="nofollow">Try It Online</a> or in the <a class="external text" href="https://github.com/Helen0903/bitch" rel="nofollow">GitHub for bitch</a>. | |
| </p><p>More implementations (in Haskell and in C++, both with bignum state) can be found at <a class="external free" href="https://github.com/int-e/bits" rel="nofollow">https://github.com/int-e/bits</a>. | |
| </p> | |
| <h2><span class="mw-headline" id="References">References</span></h2> | |
| <div class="mw-references-wrap"><ol class="references"> | |
| <li id="cite_note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">No available webpage for BITCHWISE as of 05/01/2019.</span> | |
| </li> | |
| <li id="cite_note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">Link to <a class="external text" href="https://en.wikipedia.org/wiki/Instruction_set_architecture#Instructions" rel="nofollow">Wikipedia's article</a> on instructions and instruction set architecture.</span> | |
| </li> | |
| <li id="cite_note-nope-3"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-nope_3-0">3.0</a></sup> <sup><a href="#cite_ref-nope_3-1">3.1</a></sup></span> <span class="reference-text">Link to <a class="external text" href="https://en.wikipedia.org/wiki/NOP_(code)" rel="nofollow">Wikipedia's article</a> on no-ops.</span> | |
| </li> | |
| <li id="cite_note-io-4"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-io_4-0">4.0</a></sup> <sup><a href="#cite_ref-io_4-1">4.1</a></sup> <sup><a href="#cite_ref-io_4-2">4.2</a></sup> <sup><a href="#cite_ref-io_4-3">4.3</a></sup></span> <span class="reference-text">Link to <a class="external text" href="https://en.wikipedia.org/wiki/Input/output" rel="nofollow">Wikipedia's article</a> on I/O.</span> | |
| </li> | |
| <li id="cite_note-5"><span class="mw-cite-backlink"><a href="#cite_ref-5">↑</a></span> <span class="reference-text">Link to <a class="external text" href="https://en.wikipedia.org/wiki/Bitwise_operation" rel="nofollow">Wikipedia's article</a> on bitwise instructions.</span> | |
| </li> | |
| <li id="cite_note-6"><span class="mw-cite-backlink"><a href="#cite_ref-6">↑</a></span> <span class="reference-text">Link to <a class="external text" href="https://en.wikipedia.org/wiki/Conditional_(computer_programming)" rel="nofollow">Wikipedia's article</a> on conditional instructions.</span> | |
| </li> | |
| <li id="cite_note-7"><span class="mw-cite-backlink"><a href="#cite_ref-7">↑</a></span> <span class="reference-text">Link to <a class="external text" href="https://en.wikipedia.org/wiki/Boolean_circuit" rel="nofollow">Wikipedia's article</a> on Boolean circuits.</span> | |
| </li> | |
| </ol></div> | |
| <h2><span class="mw-headline" id="See_also">See also</span></h2> | |
| <ul><li><a href="/wiki/Talk:Bitch" title="Talk:Bitch">Talk:bitch</a> (Although it is a mess, it still provides useful information.)</li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20250724015503 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.112 seconds | |
| Real time usage: 0.243 seconds | |
| Preprocessor visited node count: 557/1000000 | |
| Post‐expand include size: 2799/2097152 bytes | |
| Template argument size: 613/2097152 bytes | |
| Highest expansion depth: 5/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 5034/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 7.347 1 -total | |
| 82.66% 6.073 1 Template:Infobox_proglang | |
| 14.78% 1.086 1 Template:Lowercase | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:12080-0!canonical and timestamp 20250724015503 and revision id 75634. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p>Bitdeque is an esoteric programming language created by <a href="/wiki/User:Nobody" title="User:Nobody">User:Nobody</a> in 2019. It operates on a <a href="/wiki/Deque" title="Deque">deque</a> of bits and a register. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Overview"><span class="tocnumber">1</span> <span class="toctext">Overview</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Instructions"><span class="tocnumber">2</span> <span class="toctext">Instructions</span></a></li> | |
| <li class="toclevel-1 tocsection-3"><a href="#Examples"><span class="tocnumber">3</span> <span class="toctext">Examples</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-4"><a href="#Hello,_world!"><span class="tocnumber">3.1</span> <span class="toctext">Hello, world!</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-5"><a href="#Computational_class"><span class="tocnumber">4</span> <span class="toctext">Computational class</span></a></li> | |
| <li class="toclevel-1 tocsection-6"><a href="#Implementation"><span class="tocnumber">5</span> <span class="toctext">Implementation</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Overview">Overview</span></h2> | |
| <p>Bitdeque operates on a <a href="/wiki/Deque" title="Deque">deque</a> of bits and a register. When the program starts, the deque is empty and the value in the register is 0. There is (currently) no I/O. | |
| </p> | |
| <h2><span class="mw-headline" id="Instructions">Instructions</span></h2> | |
| <p>Bitdeque has 6 instructions: | |
| </p> | |
| <ul><li><code>PUSH</code>: Push the bit in the register to the right side of the deque (Does not change the bit in the register)</li> | |
| <li><code>INJECT</code>: Push the bit in the register to the left side of the deque (Does not change the bit in the register)</li> | |
| <li><code>EJECT</code>: Pop the bit from the left side of the deque to the register (This removes the bit on the left. The register becomes 0 if the deque is empty)</li> | |
| <li><code>POP</code>: Pop the bit from the right side of the deque to the register (This removes the bit on the right. The register becomes 0 if the deque is empty)</li> | |
| <li><code>INVERT</code>: Invert the bit in the register</li> | |
| <li><code>GOTO</code>: Take a number <code>N</code> (specified in the program) and go to the <code>N</code>th operation in the program if the bit in the register is 1</li></ul> | |
| <h2><span class="mw-headline" id="Examples">Examples</span></h2> | |
| <h3><span id="Hello.2C_world.21"></span><span class="mw-headline" id="Hello,_world!"><a href="/wiki/Hello,_world!" title="Hello, world!">Hello, world!</a></span></h3> | |
| <p>The following example stores the binary ASCII values of each character in 'Hello, world!' in the deque: | |
| </p> | |
| <pre>[H] 100 1000: INVERT PUSH INVERT PUSH PUSH INVERT PUSH INVERT PUSH PUSH PUSH | |
| [e] 110 0101: INVERT PUSH PUSH INVERT PUSH PUSH INVERT PUSH INVERT PUSH INVERT PUSH | |
| [l] 110 1100: PUSH PUSH INVERT PUSH INVERT PUSH PUSH INVERT PUSH PUSH | |
| [l] 110 1100: INVERT PUSH PUSH INVERT PUSH INVERT PUSH PUSH INVERT PUSH PUSH | |
| [o] 110 1111: INVERT PUSH PUSH INVERT PUSH INVERT PUSH PUSH PUSH PUSH | |
| [,] 010 1100: INVERT PUSH INVERT PUSH INVERT PUSH INVERT PUSH PUSH INVERT PUSH PUSH | |
| [ ] 010 0000: PUSH INVERT PUSH INVERT PUSH PUSH PUSH PUSH PUSH | |
| [w] 111 0111: INVERT PUSH PUSH PUSH INVERT PUSH INVERT PUSH PUSH PUSH | |
| [o] 110 1111: PUSH PUSH INVERT PUSH INVERT PUSH PUSH PUSH PUSH | |
| [r] 111 0010: PUSH PUSH PUSH INVERT PUSH PUSH INVERT PUSH INVERT PUSH | |
| [l] 110 1100: INVERT PUSH PUSH INVERT PUSH INVERT PUSH PUSH INVERT PUSH PUSH | |
| [d] 110 0100: INVERT PUSH PUSH INVERT PUSH PUSH INVERT PUSH INVERT PUSH PUSH | |
| [!] 010 0001: PUSH INVERT PUSH INVERT PUSH PUSH PUSH PUSH INVERT PUSH | |
| </pre> | |
| <h2><span class="mw-headline" id="Computational_class">Computational class</span></h2> | |
| <p>A variant of <a class="mw-redirect" href="/wiki/Cyclic_tag" title="Cyclic tag">Cyclic tag</a> which halts when the last production is produced from (rather than when the queue becomes empty) can be easily compiled to Bitdeque as follows: | |
| </p> | |
| <ul><li>Program start: initial string, with each 0 encoded as <code>PUSH</code> and each 1 encoded as <code>INVERT PUSH INVERT</code>.</li> | |
| <li>Productions, with each production encoded as: | |
| <ul><li><code>EJECT INVERT</code>, then</li> | |
| <li><code>GOTO</code> to the first command of the next production (or the first command of the first production, if this is the last production), then</li> | |
| <li>the production itself, with each 0 encoded as <code>PUSH</code> and each 1 encoded as <code>INVERT PUSH INVERT</code>.</li></ul></li></ul> | |
| <p>This construction works by using the Bitdeque deque as the cyclic tag queue, ensuring that the register is 0 throughout the body of productions (skipping them if the register is 1). If a production is not produced from, it jumps to the next production in cyclic order; if a production is produced from, it falls through into the next production (thus causing the program to end if the last production is produced from). | |
| </p><p>Cyclic tag is <a class="mw-redirect" href="/wiki/Turing_complete" title="Turing complete">Turing complete</a> even when using this alternative halt condition (the compiled program naturally ends up with this halt condition when compiling a <a href="/wiki/Tag_system" title="Tag system">tag system</a> with an explicit halt symbol into cyclic tag), proving that Bitdeque is also Turing complete. | |
| </p> | |
| <h2><span class="mw-headline" id="Implementation">Implementation</span></h2> | |
| <ul><li>A <a class="external text" href="https://github.com/bangyen/esolangs" rel="nofollow">Python interpreter</a> by <a href="/wiki/User:Bangyen" title="User:Bangyen">User:Bangyen</a>.</li> | |
| <li><a href="/wiki/User:Nobody" title="User:Nobody">User:Nobody</a> is also currently writing an interpreter for this.</li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20251212064825 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.009 seconds | |
| Real time usage: 0.066 seconds | |
| Preprocessor visited node count: 24/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:12251-0!canonical and timestamp 20251212064825 and revision id 170480. Rendering was triggered because: diff-page | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><dl><dd><span class="dablink"><i>Not to be confused with <a href="/wiki/Bitwise_Cyclic_Tack" title="Bitwise Cyclic Tack">Bitwise Cyclic Tack</a>.</i></span></dd></dl> | |
| <p><b>Bitwise Cyclic Tag (BCT)</b> is a <a href="/wiki/Turing-complete" title="Turing-complete">Turing-complete</a> programming language using only two commands (0 and 1) to operate on a finite data-bitstring extensible without bound on the right. Its extremely simple syntax and semantics make it a useful target for <a href="/wiki/Computational_class#Simulation" title="Computational class">simulation</a>-based proofs of a language's computational class. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#BCT_programs"><span class="tocnumber">1</span> <span class="toctext">BCT programs</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-2"><a href="#Example"><span class="tocnumber">1.1</span> <span class="toctext">Example</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-3"><a href="#BCT_emulation_of_cyclic_tag_systems"><span class="tocnumber">2</span> <span class="toctext">BCT emulation of cyclic tag systems</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-4"><a href="#The_language_CT"><span class="tocnumber">2.1</span> <span class="toctext">The language <b>CT</b></span></a></li> | |
| <li class="toclevel-2 tocsection-5"><a href="#Example_(simple_illustration)"><span class="tocnumber">2.2</span> <span class="toctext">Example (simple illustration)</span></a></li> | |
| <li class="toclevel-2 tocsection-6"><a href="#Example_(Collatz_sequence)"><span class="tocnumber">2.3</span> <span class="toctext">Example (Collatz sequence)</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-7"><a href="#Arithmetic_interpretation_of_BCT"><span class="tocnumber">3</span> <span class="toctext">Arithmetic interpretation of BCT</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-8"><a href="#Gödel_numbering"><span class="tocnumber">3.1</span> <span class="toctext">Gödel numbering</span></a></li> | |
| <li class="toclevel-2 tocsection-9"><a href="#Example_2"><span class="tocnumber">3.2</span> <span class="toctext">Example</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-10"><a href="#Computations_in_BCT"><span class="tocnumber">4</span> <span class="toctext">Computations in BCT</span></a></li> | |
| <li class="toclevel-1 tocsection-11"><a href="#Self_BCT"><span class="tocnumber">5</span> <span class="toctext">Self BCT</span></a></li> | |
| <li class="toclevel-1 tocsection-12"><a href="#Authorship"><span class="tocnumber">6</span> <span class="toctext">Authorship</span></a></li> | |
| <li class="toclevel-1 tocsection-13"><a href="#See_also"><span class="tocnumber">7</span> <span class="toctext">See also</span></a></li> | |
| <li class="toclevel-1 tocsection-14"><a href="#External_resources"><span class="tocnumber">8</span> <span class="toctext">External resources</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="BCT_programs">BCT programs</span></h2> | |
| <p>A <b>BCT program</b> is any finite string of bits (commands), executed as follows: | |
| </p> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <th>Command</th> | |
| <th>Execution | |
| </th></tr> | |
| <tr> | |
| <td>0</td> | |
| <td>Delete the leftmost data-bit. | |
| </td></tr> | |
| <tr> | |
| <td>1</td> | |
| <td>Goto the next command (say x). If the leftmost data-bit is 1, copy x to the right end of the data-string. | |
| </td></tr></tbody></table> | |
| <p>If the program-string or the data-string is initially empty, execution halts immediately; otherwise, starting at the leftmost program-bit and halting only when the data-string becomes empty, the commands are executed in cyclic sequence from left to right (the leftmost bit following next after the rightmost bit). | |
| </p><p>The program pointer advances one bit after each command-execution, and also advances one bit when the goto in a 1-command is executed; consequently, a 1-command always pairs with the next command after it (say x), such that 1x is effectively a composite command whose execution is | |
| </p> | |
| <pre>if the leftmost data-bit is 1: | |
| copy x to the right end of the data-string | |
| </pre> | |
| <p>Four equivalent variations of BCT are obtained by exchanging the roles of symbols 0 and 1 as commands, and by varying the parity required in the condition for copying a bit to the end of the data-string. | |
| </p> | |
| <h3><span class="mw-headline" id="Example">Example</span></h3> | |
| <pre>Program: 00111 | |
| Execution sequence: 00111 (00111) (00111) (00111) ... | |
| = 0 (0 11 10) (0 11 10) (0 11 10) ... | |
| Initial data-string: 101 | |
| System evolution: | |
| Commands Data- | |
| Executed String | |
| -------- ------- | |
| 0 101 | |
| 0 01 | |
| 11 1 | |
| 10 11 | |
| 0 110 | |
| 11 10 | |
| 10 101 | |
| 0 1010 | |
| 11 010 | |
| 10 010 | |
| 0 010 | |
| 11 10 | |
| ... ... | |
| </pre> | |
| <h2><span class="mw-headline" id="BCT_emulation_of_cyclic_tag_systems">BCT emulation of cyclic tag systems</span></h2> | |
| <p>For any <a href="/wiki/Cyclic_tag_system" title="Cyclic tag system">cyclic tag system</a> on a binary alphabet, there is a BCT program that emulates it (thus establishing that BCT is Turing-complete, since the set of cyclic tag systems is Turing-complete). | |
| </p><p>Specifically, a BCT program that emulates a given cyclic tag system is obtained by writing the cyclic tag system productions as ';'-terminated strings, concatenating these strings, and then applying the following substitutions: | |
| </p> | |
| <pre> 0 <-- 10 | |
| 1 <-- 11 | |
| ; <-- 0 | |
| </pre> | |
| <p>The initial data-string for the BCT program is the unaltered initial binary word for the cyclic tag system. | |
| </p><p><b>*Note*</b>: BCT remains Turing complete even if the initial data-string is always just a single <b>1</b>. This is because, for any BCT (program-string, data-string) pair, say (<b>P</b>,<b>Q</b>), there is a pair (<b>P'</b>,<b>1</b>) that simulates the same computation. This follows from a result in <a class="external text" href="http://arxiv.org/abs/1312.6700" rel="nofollow">Undecidability in binary tag systems and the Post correspondence problem for four pairs of words</a> (Turlough Neary, 2013), to the effect that for any cyclic tag system with initial word <b>w</b> (say), the same computation is simulated by some cyclic tag system whose initial word is a single <b>1</b>. | |
| </p> | |
| <h3><span class="mw-headline" id="The_language_CT">The language <b>CT</b></span></h3> | |
| <p>BCT was created upon noticing that the operation of a cyclic tag system is exactly duplicated by interpreting the concatenation of its semicolon-terminated productions as a program that uses three commands {<b>0</b>, <b>1</b>, <b>;</b>} to operate on the current word (interpeted as a data bit-string). Calling this three-instruction language <b>CT</b>, with programs that may be any finite string on {<b>0</b>, <b>1</b>, <b>;</b>}, the commands of a CT program are executed left-to-right in cyclic sequence, halting only when the data-string becomes empty: | |
| </p> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <th>CT Command</th> | |
| <th>Execution</th> | |
| <th>Equivalent BCT Command | |
| </th></tr> | |
| <tr> | |
| <td>0</td> | |
| <td>If the leftmost data-bit is 1, append 0.</td> | |
| <td>10 | |
| </td></tr> | |
| <tr> | |
| <td>1</td> | |
| <td>If the leftmost data-bit is 1, append 1.</td> | |
| <td>11 | |
| </td></tr> | |
| <tr> | |
| <td>;</td> | |
| <td>Delete the leftmost data-bit.</td> | |
| <td>0 | |
| </td></tr></tbody></table> | |
| <p>The purpose of replacing CT by BCT was merely to obtain a language whose programs are binary (rather than ternary) strings. | |
| </p><p>CT programs that might interest someone: | |
| </p> | |
| <ul><li>Program "1", data "1". Creates 'a pyramid of 1s'.</li> | |
| <li>Program ";", data whatever. Removes all data and halts.</li> | |
| <li>A sort of quines: Programs where the data remains forever identical to the initial program (and identical to data -- itself -- too). Any string consisting only of 0s and 1s, and which begins with a 0, suffices. Thus, for example: Program "0", data "0" (this is the shortest one possible). Program "0100111", data "0100111".</li></ul> | |
| <h3><span id="Example_.28simple_illustration.29"></span><span class="mw-headline" id="Example_(simple_illustration)">Example (simple illustration)</span></h3> | |
| <p>This is just to illustrate how things work ... | |
| </p> | |
| <pre>Cyclic tag system | |
| Productions: (011, 10, 101) | |
| CT program: 011;10;101; | |
| Translation to a BCT program | |
| 011;10;101; --> 10 11 11 0 11 10 0 11 10 11 0 | |
| Initial data-string: 1 | |
| System evolution: | |
| Commands | |
| Executed Data-string | |
| -------- ------------- | |
| 10 1 | |
| 11 10 | |
| 11 101 | |
| 0 1011 | |
| * 11 011 | |
| 10 011 | |
| 0 011 | |
| * 11 11 | |
| 10 111 | |
| 11 1110 | |
| 0 11101 | |
| * 10 1101 | |
| 11 11010 | |
| 11 110101 | |
| 0 1101011 | |
| * 11 101011 | |
| 10 1010111 | |
| 0 10101110 | |
| * 11 0101110 | |
| 10 0101110 | |
| 11 0101110 | |
| 0 0101110 | |
| * 10 101110 | |
| ... ... | |
| </pre> | |
| <p>The data-strings marked by '*' are those just after each deletion, and are the strings occurring in the evolution of the equivalent cyclic tag system, as follows: | |
| </p> | |
| <pre>Production Data-string | |
| ---------- ------------- | |
| 011 1 | |
| 10 011 | |
| 101 11 | |
| 011 1101 | |
| 10 101011 | |
| 101 0101110 | |
| 011 101110 | |
| ... ... | |
| </pre> | |
| <h3><span id="Example_.28Collatz_sequence.29"></span><span class="mw-headline" id="Example_(Collatz_sequence)">Example (<a href="/wiki/Collatz_sequence" title="Collatz sequence">Collatz sequence</a>)</span></h3> | |
| <p>Here are B/CT programs that compute a <a href="/wiki/Collatz_sequence" title="Collatz sequence">Collatz sequence</a> for the Collatz function in the form | |
| C(n) = (if n is even then n/2 else (3n+1)/2), based on <a class="external text" href="https://www.sciencedirect.com/science/article/pii/S0304397507007700?via%3Dihub" rel="nofollow">Liesbeth De Mol's tag system implementation of Collatz</a>. | |
| </p> | |
| <pre>Cyclic tag system: (010001, 100, 100100100, e, e, e) (where e is the empty word) | |
| CT program: 010001;100;100100100;;;; | |
| BCT program: 10 11 10 10 10 11 0 11 10 10 0 11 10 10 11 10 10 11 10 10 0 0 0 0 | |
| Initial data-string: (100)<sup><i>n</i></sup> (<i>n</i> concatenated copies of '100', where <i>n</i> is a postive integer) | |
| </pre> | |
| <p>In the computation, when (and only when) the data-string takes the form (100)<sup><i>k</i></sup> immediately before beginning a cycle through the program, it represents the integer <i>k</i> -- and these will be the successive terms of the Collatz sequence for <i>n</i>. Here is a sample computation for <i>n</i> = 3, showing the data-strings at the beginning of each program-cycle: | |
| </p> | |
| <pre>B/CT | |
| step# Collatz term B/CT data-string | |
| ----- ------------ ------------------------ | |
| 0000 3 100100100 | |
| 0024 100010001 | |
| 0048 001010001 | |
| 0072 001100100100 | |
| 0096 5 100100100100100 | |
| 0120 100100100010001 | |
| 0144 100010001010001 | |
| 0168 001010001010001 | |
| 0192 001010001100100100 | |
| 0216 001100100100100100100 | |
| 0240 8 100100100100100100100100 | |
| 0264 100100100100100100010001 | |
| 0288 100100100100010001010001 | |
| 0312 100100010001010001010001 | |
| 0336 010001010001010001010001 | |
| 0360 010001010001010001100 | |
| 0384 010001010001100100 | |
| 0408 010001100100100 | |
| 0432 4 100100100100 | |
| 0456 100100010001 | |
| 0480 010001010001 | |
| 0504 010001100 | |
| 0528 2 100100 | |
| 0552 010001 | |
| 0576 1 100 | |
| 0600 001 | |
| 0624 2 100100 | |
| 0648 010001 | |
| 0672 1 100 | |
| ... ... ... | |
| </pre> | |
| <p>(The step-numbers are the multiples of 24, because there are 24 commands executed in each program-cycle.) | |
| </p> | |
| <h2><span class="mw-headline" id="Arithmetic_interpretation_of_BCT">Arithmetic interpretation of BCT</span></h2> | |
| <p>The BCT data-string can be interpreted as the unique numeral of a nonnegative integer written in <a class="external text" href="http://en.wikipedia.org/wiki/bijective_numeration" rel="nofollow">bijective base-2 representation</a>, as follows: | |
| </p> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <th>BCT data-string</th> | |
| <th>Bijective base-2 numeral</th> | |
| <th>Integer represented | |
| </th></tr> | |
| <tr> | |
| <td>b<sub>0</sub> b<sub>1</sub> ... b<sub>k</sub></td> | |
| <td>(b<sub>k</sub> + 1)(b<sub>k-1</sub> + 1)...(b<sub>0</sub> + 1)</td> | |
| <td>SUM{(b<sub>i</sub> + 1) 2<sup>i</sup>: i = 0..k} | |
| </td></tr></tbody></table> | |
| <p>Note that the digits 1,2 are represented by the bits 0,1 respectively, and the numeral is read in <i>reverse</i> order from the bit-string. E.g., the BCT data-string 011 corresponds to the bijective base-2 numeral 221, representing the integer <u><b>2</b></u>*2<sup>2</sup> + <u><b>2</b></u>*2<sup>1</sup> + <u><b>1</b></u>*2<sup>0</sup> = 13. | |
| </p><p>Each BCT command in a program then corresponds to an explicit numerical function defined on the set <b>N</b> of nonnegative integers, as follows: | |
| </p> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <th>Command</th> | |
| <th>Equivalent numerical function (mapping <b>N</b> to <b>N</b>) | |
| </th></tr> | |
| <tr> | |
| <td>0</td> | |
| <td>f(n) = [n is positive] * floor((n-1)/2) | |
| </td></tr> | |
| <tr> | |
| <td>10</td> | |
| <td>g<sub>0</sub>(n) = n + [n is positive and even] * 2<sup>(floor(log<sub>2</sub>(n+1)) + 0)</sup> | |
| </td></tr> | |
| <tr> | |
| <td>11</td> | |
| <td>g<sub>1</sub>(n) = n + [n is positive and even] * 2<sup>(floor(log<sub>2</sub>(n+1)) + 1)</sup> | |
| </td></tr></tbody></table> | |
| <p>where we've shown separately the two cases for the program-bit that's next after the 1-command. Here [<i>condition</i>] is an <a class="external text" href="http://en.wikipedia.org/wiki/Iverson_bracket" rel="nofollow">Iverson bracket</a>, meaning 1 if <i>condition</i> is true, else 0; so the integer 0 is a fixed-point of all three of the functions f, g<sub>0</sub>, g<sub>1</sub>, and represents a permanent "halt" condition. (Also note that floor(log<sub>2</sub>(n+1)) is just the number of digits in the bijective base-2 numeral for n.) | |
| </p><p>Thus a BCT program is equivalent to a composition of finitely-many instances of the three functions f, g<sub>0</sub>, g<sub>1</sub>, all but some initial portion of which is iterated. Just as the sequence of successive data-strings encodes all input and output in a BCT computation, in the arithmetic interpretation the same role is fulfilled by the sequence of successive nonnegative integer arguments. | |
| </p> | |
| <h3><span id="G.C3.B6del_numbering"></span><span class="mw-headline" id="Gödel_numbering">Gödel numbering</span></h3> | |
| <p>A <a class="external text" href="http://en.wikipedia.org/wiki/G%C3%B6del_number" rel="nofollow">Gödel numbering</a> of BCT programs is automatically provided by similarly interpreting each BCT program as the bijective base-2 numeral of an integer (now in the usual digit-order, unlike the data-string). Thus, <u>a BCT program is (the numeral of) its own Gödel number</u>. E.g., the program 011 is interpreted as the integer 10 (ten = 122 in bijective base-2) — and indeed 011 is the tenth nonempty BCT program in a <a class="external text" href="http://en.wikipedia.org/wiki/Shortlex_order" rel="nofollow">shortlex ordering</a> of the set of all BCT programs. | |
| </p> | |
| <h3><span class="mw-headline" id="Example_2">Example</span></h3> | |
| <pre> bit-string bij. base-2 decimal | |
| ---------- ----------- ------- | |
| Program: 110100 221211 115 | |
| Initial data: 10 12 4 | |
| Execution-trace: | |
| data (at beginning of each step) | |
| -------------------------------- | |
| step# cmd function bit-string bij. base-2 decimal function evaluation | |
| ----- ---- -------- ---------- ----------- ------- ------------------- | |
| 0001 11 * g<sub>1</sub> 10 12 4 | |
| 0002 0 f 101 212 12 = g<sub>1</sub>(4) | |
| 0003 10 g<sub>0</sub> 01 21 5 = f(12) | |
| 0004 0 f 01 21 5 = g<sub>0</sub>(5) | |
| 0005 11 * g<sub>1</sub> 1 2 2 = f(5) | |
| 0006 0 f 11 22 6 = g<sub>1</sub>(2) | |
| 0007 10 g<sub>0</sub> 1 2 2 = f(6) | |
| 0008 0 f 10 12 4 = g<sub>0</sub>(2) | |
| 0009 11 * g<sub>1</sub> 0 1 1 = f(4) | |
| 0010 0 f 0 1 1 = g<sub>1</sub>(1) | |
| (halt) - - 0 = f(1) | |
| ----- | |
| deletion sequence: 10110 | |
| </pre> | |
| <p>An asterisk marks the first command executed in each cycle through the program — the first function evaluated in each iteration. | |
| </p> | |
| <h2><span class="mw-headline" id="Computations_in_BCT">Computations in BCT</span></h2> | |
| <p>It can be shown that for any Turing machine computation, there is a BCT system (program plus data-string) that simulates it — halting if and only if the TM halts, and encoding the TM's input and output in the sequence of deleted data-bits. This is a consequence of the Turing-completeness of cyclic tag systems, together with the fact that BCT can simulate any cyclic tag system. | |
| </p><p>There are many possible proofs that cyclic tag is <a href="/wiki/Turing-complete" title="Turing-complete">Turing-complete</a>. An esolang-based proof goes via <a href="/wiki/DownRight" title="DownRight">DownRight</a>; it's possible to compile DownRight into cyclic tag (and thus BCT), and (regular) <a href="/wiki/Tag_system" title="Tag system">tag systems</a> into DownRight, thus demonstrating BCT's Turing-completeness in a non-circular way (because unlike many computational class proofs based on esolang chaining, the chain of compilers does not end up going back through cyclic tag or BCT at any point). It's also fairly easy to show directly that cyclic tag systems can emulate regular tag systems (the basic trick is to encode the tag system's symbols using a "1-hot" encoding in which each all symbols encode to the same length and each encoding contains exactly one 1 bit; then cyclic tag effectively devolves into using a lookup table for each popped bit, and you can alternate between the tag system's lookup table to handle the lookup, and an empty lookup table to handle the deletion). | |
| </p> | |
| <h2><span class="mw-headline" id="Self_BCT">Self BCT</span></h2> | |
| <p>Any string of bits L...R, when read in cyclic sequence (rightward | |
| from L, with L next after R), parses into a unique sequence of | |
| instructions from the set {0, 10, 11}. Thus, any such string can | |
| be interpreted as a self-modifying program whose instructions are | |
| executed in cyclic sequence as follows (with labels L/R revised | |
| appropriately when a bit is deleted/appended): | |
| </p> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <th>Instruction</th> | |
| <th>Execution | |
| </th></tr> | |
| <tr> | |
| <td>0</td> | |
| <td>Delete L. | |
| </td></tr> | |
| <tr> | |
| <td>1x</td> | |
| <td>If L > 0: append x to R. | |
| </td></tr></tbody></table> | |
| <p>Program execution halts if and when the program deletes itself. | |
| </p><p>This is essentially BCT, but with the data-string identified with | |
| the program-string itself. | |
| </p> | |
| <pre>Example (^ or ^^ indicating the current instruction as 0 or 1x): | |
| Step Program-string | |
| ----- ---------------------- | |
| 00000 1011110111 | |
| ^^ | |
| 00001 10111101110 | |
| ^^ | |
| 00002 101111011101 | |
| ^^ | |
| 00003 1011110111011 | |
| ^ | |
| 00004 011110111011 | |
| ^^ | |
| 00005 011110111011 | |
| ^^ | |
| 00006 011110111011 | |
| ^^ | |
| 00007 011110111011 | |
| ^ | |
| 00008 11110111011 | |
| ^^ | |
| 00009 111101110111 | |
| ^^ | |
| 00010 1111011101111 | |
| ^ | |
| 00011 111011101111 | |
| ^^ | |
| 00012 1110111011111 | |
| ^^ | |
| 00013 11101110111110 | |
| ^^ | |
| 00014 111011101111101 | |
| ^^ | |
| 00015 1110111011111011 | |
| ^^ | |
| 00016 11101110111110110 | |
| ^^ | |
| 00017 111011101111101101 | |
| ^ | |
| 00018 11011101111101101 | |
| ^ ^ | |
| 00019 110111011111011011 | |
| ^^ | |
| ... ... | |
| 00031 011101111101101101011011 | |
| ^ | |
| 00032 11101111101101101011011 | |
| ^^ | |
| 00033 111011111011011010110111 | |
| ^ ^ | |
| 00034 1110111110110110101101111 | |
| ^^ | |
| ... ... | |
| 43074 (empty) | |
| </pre> | |
| <p>This language might well be a Turing tarpit, with the 43,074 steps for the program "1011110111" already showing some characteristically rapid growth in the associated uncomputable <a class="extiw" href="https://en.wikipedia.org/wiki/Busy_beaver#Maximum_shifts_function_S" title="wikipedia:Busy beaver">Radó S-sequence</a>. | |
| </p><p><b>NB</b>: Both BCT and Self BCT generalise in obvious ways to languages that process a base-k data-string using k (≥ 2) instructions of the form dX, where d is any base-k digit and X is any base-k digit-string of length d. Thus, the command 0 unconditionally deletes the leftmost data-symbol, and the command dX (with 1 ≤ d ≤ k-1, and X of length d) appends X to the data-string iff the leftmost data-symbol <i>is not</i> 0 (or, as a variant, iff the leftmost data-symbol <i>is</i> d). A program would then be any base-k digit-string. | |
| </p> | |
| <h2><span class="mw-headline" id="Authorship">Authorship</span></h2> | |
| <p>The languages CT and BCT were created by "<a href="/wiki/R.e.s." title="R.e.s.">r.e.s.</a>" in December 2005. | |
| "Self BCT" was created by "r.e.s." in 2005-2006 (posted 2006 in a | |
| comp.theory usegroup message, <a class="external text" href="http://groups.google.com/group/comp.theory/browse_thread/thread/29b22b6fbd89179f/da69c701096e1c6d?hl=en&ie=UTF-8&q=BCT+%22cyclic+tag%22&fwc=1" rel="nofollow">"Variations on Cyclic Tag"</a>). | |
| </p> | |
| <h2><span class="mw-headline" id="See_also">See also</span></h2> | |
| <ul><li><a class="mw-redirect" href="/wiki/Cyclic_tag" title="Cyclic tag">Cyclic tag</a></li> | |
| <li><a href="/wiki/Bitwise_Cyclic_Tack" title="Bitwise Cyclic Tack">Bitwise Cyclic Tack</a></li> | |
| <li><a href="/wiki/Bitwise_Cyclic_Teap" title="Bitwise Cyclic Teap">Bitwise Cyclic Teap</a></li></ul> | |
| <p>Other languages operating on bits (implemented only): | |
| </p> | |
| <ul><li><a href="/wiki/FlipJump" title="FlipJump">FlipJump</a></li> | |
| <li><a href="/wiki/BIT" title="BIT">BIT</a></li> | |
| <li><a href="/wiki/BoolX" title="BoolX">BoolX</a></li> | |
| <li><a href="/wiki/Bitch" title="Bitch">Bitch</a></li> | |
| <li><a href="/wiki/Boolfuck" title="Boolfuck">Boolfuck</a></li> | |
| <li><a href="/wiki/BitChanger" title="BitChanger">BitChanger</a></li> | |
| <li><a href="/wiki/Bitter" title="Bitter">Bitter</a></li> | |
| <li><a href="/wiki/Boolet" title="Boolet">Boolet</a></li> | |
| <li><a href="/wiki/BitBitJump" title="BitBitJump">BitBitJump</a></li> | |
| <li><a href="/wiki/Smallfuck" title="Smallfuck">Smallfuck</a></li></ul> | |
| <h2><span class="mw-headline" id="External_resources">External resources</span></h2> | |
| <ul><li><a class="external text" href="http://www.73b.org/programs/bct.b" rel="nofollow">Bitwise Cyclic Tag interpreter</a> written in <a href="/wiki/Brainfuck" title="Brainfuck">brainfuck</a> and <a class="external text" href="http://yiap.nfshost.com/esoteric/thue/bct.t" rel="nofollow">interpreter</a> in <a href="/wiki/Thue" title="Thue">Thue</a> (by <a href="/wiki/User:Keymaker" title="User:Keymaker">User:Keymaker</a>)</li> | |
| <li><a class="external text" href="http://oerjan.nvg.org/esoteric/slashes/bct.sss" rel="nofollow">Interpreter</a> in <a href="/wiki////" title="///">///</a> and <a class="external text" href="http://oerjan.nvg.org/esoteric/eodermdrome/bct.eode" rel="nofollow">interpreter</a> in <a href="/wiki/Eodermdrome" title="Eodermdrome">Eodermdrome</a> (by <a href="/wiki/User:Oerjan" title="User:Oerjan">User:Oerjan</a>)</li> | |
| <li><a class="external text" href="https://github.com/graue/esofiles/tree/master/sortle/src/bct.sort" rel="nofollow">Interpreter</a> in <a href="/wiki/Sortle" title="Sortle">Sortle</a> (by <a href="/wiki/User:Graue" title="User:Graue">User:Graue</a>)</li> | |
| <li><a class="external text" href="https://github.com/Coates-36411/BCT-interpreter" rel="nofollow">Interpreter</a> in C (by <a href="/wiki/User:Coates" title="User:Coates">User:Coates</a>)</li> | |
| <li><a class="external text" href="https://github.com/hornc/abctag" rel="nofollow">Arithmetic Interpreter</a> over HTTP, in Python (by <a href="/wiki/User:Salpynx" title="User:Salpynx">User:Salpynx</a>)</li> | |
| <li><a href="/wiki/Talk:Bitwise_Cyclic_Tag#Python_Interpreter" title="Talk:Bitwise Cyclic Tag">BCT Interpreter</a> in Python 3 by User:CosmicMan08</li> | |
| <li><a class="extiw" href="https://en.wikipedia.org/wiki/Cyclic_tag_system" title="wikipedia:Cyclic tag system">Wikipedia: Cyclic tag system</a></li> | |
| <li><a class="external text" href="https://scratch.mit.edu/projects/710460945" rel="nofollow">Interpreter</a> in Scratch by <a href="/wiki/User:ChuckEsoteric08" title="User:ChuckEsoteric08">User:ChuckEsoteric08</a></li> | |
| <li><a href="/wiki/None1/BCT_Python" title="None1/BCT Python">Interpreter</a> in <a href="/wiki/Python" title="Python">Python</a> by <a href="/wiki/User:None1" title="User:None1">User:None1</a></li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20260201092152 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.030 seconds | |
| Real time usage: 0.103 seconds | |
| Preprocessor visited node count: 79/1000000 | |
| Post‐expand include size: 101/2097152 bytes | |
| Template argument size: 19/2097152 bytes | |
| Highest expansion depth: 5/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 5.129 1 Template:Distinguish/Confusion | |
| 100.00% 5.129 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:1621-0!canonical and timestamp 20260201092152 and revision id 174732. Rendering was triggered because: edit-page | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b>Black</b> is a two-dimensional <a href="/wiki/Esoteric_programming_language" title="Esoteric programming language">esoteric programming language</a> created in <a href="/wiki/Category:2006" title="Category:2006">2006</a> by <a href="/wiki/User:Ais523" title="User:Ais523">User:ais523</a>. It was inspired by <a href="/wiki/1L" title="1L">1L</a> and <a href="/wiki/BackFlip" title="BackFlip">BackFlip</a>, as an attempt to create a symmetrical <a href="/wiki/Turing-complete" title="Turing-complete">Turing-complete</a> language with only one instruction (two counting <a class="mw-redirect" href="/wiki/NOP" title="NOP">NOP</a>), that uses code as data (<a href="/wiki/BackFlip" title="BackFlip">BackFlip</a>-style). | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Commands"><span class="tocnumber">1</span> <span class="toctext">Commands</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Examples_of_commands"><span class="tocnumber">2</span> <span class="toctext">Examples of commands</span></a></li> | |
| <li class="toclevel-1 tocsection-3"><a href="#Example_program"><span class="tocnumber">3</span> <span class="toctext">Example program</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-4"><a href="#Another_example"><span class="tocnumber">3.1</span> <span class="toctext">Another example</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-5"><a href="#Extensions"><span class="tocnumber">4</span> <span class="toctext">Extensions</span></a></li> | |
| <li class="toclevel-1 tocsection-6"><a href="#Computational_class"><span class="tocnumber">5</span> <span class="toctext">Computational class</span></a></li> | |
| <li class="toclevel-1 tocsection-7"><a href="#Black_implementations"><span class="tocnumber">6</span> <span class="toctext">Black implementations</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-8"><a href="#ALPACA"><span class="tocnumber">6.1</span> <span class="toctext">ALPACA</span></a></li> | |
| <li class="toclevel-2 tocsection-9"><a href="#C"><span class="tocnumber">6.2</span> <span class="toctext">C</span></a></li> | |
| <li class="toclevel-2 tocsection-10"><a href="#Javascript"><span class="tocnumber">6.3</span> <span class="toctext">Javascript</span></a></li> | |
| <li class="toclevel-2 tocsection-11"><a href="#Golly"><span class="tocnumber">6.4</span> <span class="toctext">Golly</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-12"><a href="#See_also"><span class="tocnumber">7</span> <span class="toctext">See also</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Commands">Commands</span></h2> | |
| <p>A Black program has only two commands: space (a <a class="mw-redirect" href="/wiki/NOP" title="NOP">NOP</a>) and non-space (which can be represented by any character, which could be different for different commands; <tt>#</tt> is commonly used). The program runs in an unbounded area (unbounded in all four directions); any cells not initially specified are filled with spaces. The effects of non-space are as follows: | |
| </p> | |
| <ul><li>If the instruction pointer moves into a non-space, it pushes that non-space one space in its own direction (leaving a space behind in the cell it moved from), and causes the instruction pointer to turn 180 degrees.</li> | |
| <li>If the above action would push a non-space into a cell already occupied by a non-space, program execution terminates.</li> | |
| <li>If there is a non-space behind and to the left of the instruction pointer (from the point of view of the direction the instruction pointer is moving in), and the instruction pointer is not on a non-space, the instruction pointer turns right.</li> | |
| <li>Likewise, if there is a non-space behind and to the right of the instruction pointer, and the instruction pointer is not on a non-space, the instruction pointer turns left.</li> | |
| <li>If both the two above conditions are true, the instruction pointer continues in its original direction (thus, it is possible for the instruction pointer to go between a pair of non-spaces).</li></ul> | |
| <p>The instruction pointer starts at the third row and third column of the input, going right. | |
| </p> | |
| <h2><span class="mw-headline" id="Examples_of_commands">Examples of commands</span></h2> | |
| <p>(In these simple examples, arrows have been added to show how the IP moves, or Xs if it moves in more than one direction; they are not non-spaces in the examples.) | |
| </p><p><i>Due to technical considerations, there are not enough blank rows before some of these examples; the place where the IP enters marks the third row and third column of these examples.</i> | |
| </p><p>How a non-space affects program flow: | |
| </p> | |
| <pre> # | |
| >>>>>>>>V | |
| V | |
| V | |
| </pre> | |
| <p>How to create an infinite loop: | |
| </p> | |
| <pre> # # | |
| >>>>>>>>>V | |
| #^ V | |
| ^ V# | |
| ^<<<<< | |
| # | |
| </pre> | |
| <p>Here, the pair of #s on the left shows how an irreversible construct can be created. | |
| </p><p>How to cause the IP to rebound: | |
| </p> | |
| <pre> ## | |
| XXXXXX>>V | |
| ^# V | |
| ^ V# | |
| ^<<< | |
| # | |
| </pre> | |
| <p>If this is wanted at the edge of the map, there is a simpler but less efficient method: | |
| </p> | |
| <pre>XXXXXXX# | |
| </pre> | |
| <p>(This has the advantage that it moves further away every time it is used, and so it is easy to ensure that closer moving objects never catch up to it.) | |
| </p><p>How to turn a corner reversibly: | |
| </p> | |
| <pre> ## | |
| >>>>>>>>V | |
| # V# | |
| V<<< | |
| V | |
| </pre> | |
| <p>(If the IP enters from the output here, it will leave through the input.) | |
| </p> | |
| <h2><span class="mw-headline" id="Example_program">Example program</span></h2> | |
| <pre> 1 | |
| # # # # | |
| N | |
| # # | |
| # | |
| # # # | |
| # | |
| # | |
| # # | |
| # # | |
| # | |
| # | |
| # # | |
| # # # # | |
| # # # | |
| # | |
| # | |
| # | |
| % | |
| # # | |
| + | |
| ## | |
| # # | |
| # | |
| # | |
| # # | |
| + | |
| # # | |
| # | |
| ## # # | |
| + | |
| # # | |
| # | |
| # | |
| # | |
| # | |
| # | |
| * * | |
| * | |
| ! | |
| </pre> | |
| <p>If extensions are used, this program produces the following output: | |
| </p> | |
| <pre>11111111111111111111111111 | |
| 111111111111111111111111111 | |
| 1111111111111111111111111111 | |
| 11111111111111111111111111111 | |
| 111111111111111111111111111111 | |
| 1111111111111111111111111111111 | |
| 11111111111111111111111111111111 | |
| 111111111111111111111111111111111 | |
| 1111111111111111111111111111111111 | |
| 11111111111111111111111111111111111 | |
| 111111111111111111111111111111111111 | |
| 1111111111111111111111111111111111111 | |
| </pre> | |
| <p>(the pattern continues to infinity). Even without extensions, the program does the same thing (but its progress can only be monitored with a debugger). This output cannot be produced by a <a href="/wiki/Bounded-storage_machine" title="Bounded-storage machine">bounded-storage machine</a> or even a <a href="/wiki/Push-down_automaton" title="Push-down automaton">push-down automaton</a>, making it more likely that Black is <a href="/wiki/Turing-complete" title="Turing-complete">Turing-complete</a>. | |
| The main activity of the program consists of moving the <tt>%</tt> down to the set of <tt>*</tt>s and back to its original location, with the IP bouncing off the <tt>1</tt> or the <tt>!</tt> as it goes. To produce the increase in length, the entire set of <tt>*</tt>s is moved downwards! (This is why the program is so large). In effect, this creates an unbounded integer. Every time the <tt>%</tt> returns to its original location, the <tt>N</tt> is moved. (All nonspaces but the <tt>#</tt>s are moved during the course of the program.) | |
| </p> | |
| <h3><span class="mw-headline" id="Another_example">Another example</span></h3> | |
| <p>There is a truth-machine in Black here: <a href="/wiki/Truth-machine#Black" title="Truth-machine">Truth-machine#Black</a>. It needs to be run in an interpreter that uses the output extension if one wants to see any output. The input (0/1) is calibrated by changing the position of a single '*'. | |
| </p> | |
| <h2><span class="mw-headline" id="Extensions">Extensions</span></h2> | |
| <p>The above example uses the following extension: | |
| </p> | |
| <ul><li>Whenever a non-space consisting of a single digit is moved, that digit is output;</li> | |
| <li>Whenever the non-space N is moved, a newline is output.</li></ul> | |
| <p>This extension is not part of the language, and does not interfere with any program that does not use it, except possibly to produce garbage output (or, in rare cases, useful debugging traces). | |
| </p> | |
| <h2><span class="mw-headline" id="Computational_class">Computational class</span></h2> | |
| <figure class="mw-halign-center" typeof="mw:File/Thumb"><a class="mw-file-description" href="/wiki/File:MMtoBlack23123.png"><img class="mw-file-element" decoding="async" height="275" src="/w/images/thumb/5/57/MMtoBlack23123.png/611px-MMtoBlack23123.png" srcset="/w/images/thumb/5/57/MMtoBlack23123.png/917px-MMtoBlack23123.png 1.5x, /w/images/5/57/MMtoBlack23123.png 2x" width="611"/></a><figcaption>A MM program translation, running at step 23123.</figcaption></figure> | |
| <p>The language was suspected to be Turing-complete, but it was not proven until 2018. The <a href="/wiki/Black_Turing-completeness_proof" title="Black Turing-completeness proof">Black Turing-completeness proof</a> uses a method of translating Minsky Machine into an intermediate language (Exeter) and then that into Black. | |
| </p> | |
| <h2><span class="mw-headline" id="Black_implementations">Black implementations</span></h2> | |
| <h3><span class="mw-headline" id="ALPACA">ALPACA</span></h3> | |
| <p>The following is an <a href="/wiki/ALPACA" title="ALPACA">ALPACA</a> implementation of Black; it only works on an <a href="/wiki/ALPACA" title="ALPACA">ALPACA</a> implementation with an unbounded area, and requires preprocessing (all nonspaces must be changed into the <tt>#</tt> character, and a <tt>></tt> character must be placed in the third row and third column). | |
| </p> | |
| <pre>class UpIP; class DownIP; class RightIP; class LeftIP; | |
| state Space " " | |
| to RightSp when (v is UpIP and v< NonSpace and v> Space) | |
| or (^ is DownIP and ^< NonSpace and ^> Space) | |
| or (< is RightIP and ^< Space and v< Space) | |
| or (< is RightIP and ^< NonSpace and v< NonSpace), | |
| to LeftSp when (v is UpIP and v> NonSpace and v< Space) | |
| or (^ is DownIP and ^> NonSpace and ^< Space) | |
| or (> is LeftIP and ^> Space and v> Space) | |
| or (> is LeftIP and ^> NonSpace and v> NonSpace), | |
| to UpSp when (< is RightIP and v< NonSpace and ^< Space) | |
| or (> is LeftIP and v> NonSpace and ^> Space) | |
| or (v is UpIP and v< Space and v> Space) | |
| or (v is UpIP and v< NonSpace and v> NonSpace), | |
| to DownSp when (< is RightIP and ^< NonSpace and v< Space) | |
| or (> is LeftIP and ^> NonSpace and v> Space) | |
| or (^ is DownIP and ^< Space and ^> Space) | |
| or (^ is DownIP and ^< NonSpace and ^> NonSpace), | |
| to NonSpace when > MoveLeft or ^ MoveDown or v MoveUp or < MoveRight; | |
| state NonSpace "#" | |
| to MoveLeft when > LeftSp, | |
| to MoveUp when v UpSp, | |
| to MoveRight when < RightSp, | |
| to MoveDown when ^ DownSp; | |
| state MoveLeft "L" is RightIP to Space; | |
| state MoveRight "R" is LeftIP to Space; | |
| state MoveUp "U" is DownIP to Space; | |
| state MoveDown "D" is UpIP to Space; | |
| state RightSp ">" is RightIP to Space; | |
| state LeftSp "<" is LeftIP to Space; | |
| state UpSp "^" is UpIP to Space; | |
| state DownSp "V" is DownIP to Space. | |
| </pre> | |
| <h3><span class="mw-headline" id="C">C</span></h3> | |
| <p>An <a class="external text" href="http://exoprog.110mb.com/blak" rel="nofollow">interpreter in C</a> is also available. (The original page appears to be dead and not archived; a copy of the interpreter itself has been rehosted <a class="external text" href="http://nethack4.org/mirrors/blak.tar.gz" rel="nofollow">here</a>.) | |
| </p> | |
| <h3><span class="mw-headline" id="Javascript">Javascript</span></h3> | |
| <p>A simple, visual interpreter in Javascript can be found <a class="external text" href="http://yiap.nfshost.com/esoteric/black/black.html" rel="nofollow">here</a>. | |
| </p> | |
| <h3><span class="mw-headline" id="Golly">Golly</span></h3> | |
| <p>A visual interpreter in Golly was originally written by _zM <a class="external text" href="http://conwaylife.com/forums/viewtopic.php?p=55539#p55539" rel="nofollow">here</a>; an improved version by Wright is available <a class="external text" href="https://gist.github.com/supposedly/14cf078c61c3540fdc2e06b5280ab341" rel="nofollow">here</a>. | |
| </p> | |
| <h2><span class="mw-headline" id="See_also">See also</span></h2> | |
| <ul><li><a href="/wiki/1L" title="1L">1L</a></li> | |
| <li><a href="/wiki/BackFlip" title="BackFlip">BackFlip</a></li> | |
| <li><a href="/wiki/Nopstacle" title="Nopstacle">Nopstacle</a></li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20250723223634 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.020 seconds | |
| Real time usage: 0.023 seconds | |
| Preprocessor visited node count: 58/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 1723/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:1787-0!canonical and timestamp 20250723223634 and revision id 158348. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b>Blindfolded Arithmetic</b> is an esoteric language that <a href="/wiki/User:Ais523" title="User:Ais523">User:ais523</a> has published in 2018-04 on Code Golf Stack Exchange. It is similar to a language called Babbage's Analytical Engine that was published in 1992 for IOCCC. Blindfolded Arithmetic is Turing-complete, in fact it can efficiently simulate an unrestricted state machine with two stacks. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Definition"><span class="tocnumber">1</span> <span class="toctext">Definition</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Proof_of_Turing-completeness"><span class="tocnumber">2</span> <span class="toctext">Proof of Turing-completeness</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-3"><a href="#General_structure_of_compilation"><span class="tocnumber">2.1</span> <span class="toctext">General structure of compilation</span></a></li> | |
| <li class="toclevel-2 tocsection-4"><a href="#Compiling_individual_steps"><span class="tocnumber">2.2</span> <span class="toctext">Compiling individual steps</span></a></li> | |
| <li class="toclevel-2 tocsection-5"><a href="#Four_variables"><span class="tocnumber">2.3</span> <span class="toctext">Four variables</span></a></li> | |
| <li class="toclevel-2 tocsection-6"><a href="#Spare_registers"><span class="tocnumber">2.4</span> <span class="toctext">Spare registers</span></a></li> | |
| <li class="toclevel-2 tocsection-7"><a href="#Ais523's_Turing-completeness_proof"><span class="tocnumber">2.5</span> <span class="toctext">Ais523's Turing-completeness proof</span></a></li> | |
| <li class="toclevel-2 tocsection-8"><a href="#Compile_from_Minsky_machine"><span class="tocnumber">2.6</span> <span class="toctext">Compile from Minsky machine</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-9"><a href="#Babbage's_analytical_engine"><span class="tocnumber">3</span> <span class="toctext">Babbage's analytical engine</span></a></li> | |
| <li class="toclevel-1 tocsection-10"><a href="#See_also"><span class="tocnumber">4</span> <span class="toctext">See also</span></a></li> | |
| <li class="toclevel-1 tocsection-11"><a href="#External_links"><span class="tocnumber">5</span> <span class="toctext">External links</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Definition">Definition</span></h2> | |
| <p>Blindfolded Arithmetic operates on integers of unlimited size. The machine state has six registers each storing an integer, called <i>a, b, c, d, e, i</i>, plus a program counter. | |
| </p><p>Each instruction does a simple arithmetic operation, with two registers as input and one register as output (here, <code><i>v</i><sub>0</sub></code>, <code><i>v</i><sub>1</sub></code> and <code><i>v</i><sub>2</sub></code> are placeholders that could be any of <code>a</code>, <code>b</code>, <code>c</code>, <code>d</code>, <code>e</code>, or <code>i</code>): | |
| </p> | |
| <dl><dd><code><i>v</i><sub>0</sub> = <i>v</i><sub>1</sub> + <i>v</i><sub>2</sub></code> (addition)</dd> | |
| <dd><code><i>v</i><sub>0</sub> = <i>v</i><sub>1</sub> - <i>v</i><sub>2</sub></code> (subtraction)</dd> | |
| <dd><code><i>v</i><sub>0</sub> = <i>v</i><sub>1</sub> * <i>v</i><sub>2</sub></code> (multiplication)</dd> | |
| <dd><code><i>v</i><sub>0</sub> = <i>v</i><sub>1</sub> / <i>v</i><sub>2</sub></code> (truncated division, i.e. division rounding towards 0)</dd></dl> | |
| <p>Horizontal whitespace is allowed, but not required, where spaces appear in the above examples. The language was originally defined as a list of instructions, without specifying the syntax that would be used to represent the list in a file; in practice, people tend to use either newlines or semicolons as the separator, and implementations should support either method of separating instructions, including allowing both syntaxes to be mixed in the same file. (When using newlines, using multiple newlines are allowed, and horizontal whitespace may be mixed with them; when using semicolons, vertical and horizontal whitespace around the semicolon is allowed but not required.) | |
| </p><p>There are no flow control instructions. The machine executes the list of instructions cyclically forever, until it encounters a division instruction that tries to divide by zero. That instruction is not executed, and the content of the register <i>i</i> before that instruction is the output. | |
| </p><p>Execution takes one input argument, which must be a positive integer. At the start, the register <i>i</i> is initialized to the input, and the other five integer registers are initialized to 0. | |
| </p> | |
| <h2><span class="mw-headline" id="Proof_of_Turing-completeness">Proof of Turing-completeness</span></h2> | |
| <p>Blindfolded Arithmetic is Turing-complete and can handle arbitrary computable functions from positive integers to positive integers. | |
| </p><p>To write a program to Blindfolded Arithmetic, write the program to a state machine with two stacks with two symbols (0 and 1) each. You can use arbitrary control flow and as many states as you wish. (Note that a Turing-machine with one tape and two symbols can be easily transformed to a state machine with two stacks: the first stack stores the part of the tape to the left of the head, and the second one stores the part of the tape under and to the right of the head.) | |
| </p><p>The stacks are padded with infinitely many zeroes. The first stack starts empty, but the second stack starts with the input minus one stored in it in binary, with the least significant bit on the stack top. You must end with the output minus one in the second stack in the same format. You are allowed to test not for the stack top, but also whether the second stack is empty, i.e., contains all zeroes. This format is unusual, but it doesn't restrict the power of the program, because you can start the program by transfering the input from the second stack to the first stack, converting it to a format with multiple symbols per bit, and with special combinations of symbols marking its ends, and do the opposite conversion at the end of the program to produce output. | |
| </p> | |
| <h3><span class="mw-headline" id="General_structure_of_compilation">General structure of compilation</span></h3> | |
| <p>We will now show a simple way to compile the state machine program to an Blindfolded Arithmetic program, using five of the six registers. Assign an integer identifier to each state of the state machine, with the restriction that the starting state is numbered 0. The register usage of the Blindflolded arithmetic will be the following. | |
| </p> | |
| <dl><dd><i>e</i> is unused.</dd> | |
| <dd><i>d</i> stores the first stack in binary, least significant bit is the stack top</dd> | |
| <dd><i>i-1</i> stores the second stack in binary, least significant bit is the stack top. <i>i</i> must thus be positive.</dd> | |
| <dd><i>c</i> usually stores 4*<i>p</i>, where <i>p</i> is the current state of state machine.</dd> | |
| <dd><i>a</i> is a scratch register (accumulator) on which we do various arithmetic.</dd> | |
| <dd><i>b</i> is a constant scratch register that usually contains a positive powers of two known at compile time, used to get around the difficulty that Blindfolded Arithmetic doesn't allow literals as operands; but can occasionally be used as a second scratch register.</dd></dl> | |
| <p>We sometimes break these register conventions for short times within tight sequences of the program, but they must hold at the start of the program and between major steps. | |
| </p><p>An operation that we want to do very often in the Blindfolded Arithmetic program is to add an arbitrary constant integer <i>B</i> to a register <i>x</i> (one of <i>a</i>, <i>c</i>, <i>d</i> or <i>i</i>). We can do this easily any time when <i>i</i> is positive and we're allowed to clobber <i>b</i>. For this, write the magnitude of <i>B</i> in binary. Initialize <i>b</i> to 1 with the instruction <code>b = i / i</code>. Then iterate each power of two from 1 to the value of the highest bit set in <i>B</i>. In each iteration, add the instruction <code>x = x + b</code> if the bit is set in <i>B</i> and <i>B</i> is positive, <code>x = x - b</code> if the bit is set in -<i>B</i> and <i>B</i> is negative, or nothing if the bit is clear in <i>abs(B)</i>, then change to the next power of two with the instruction <code>b = b + b</code>. (It would be possible to only add 1 <i>B</i> times, but that would be inefficient.) | |
| </p><p>Another important operation is to decide if the program state counter <i>p</i> is equal to a particular state identifier <i>P</i> known at compile time. As precondition to this, we require that <i>a</i> is either 0 or 1, not necessarily known at compile time. Sometimes we always want to set <i>a</i>=1, which we do with the instruction <code>a = i / i</code>. Other times we leave another 0 or 1 condition code in <i>a</i>. The output of this operation shall go to <i>a</i>, which becomes 1 if <i>a</i> was 1 at the input and <i>P</i>==<i>p</i>, but 0 in any other case. For this, first add 1-4*<i>P</i> to <i>c</i>, thus after the sequence, <i>c</i>=1+4*<i>p</i>-4*<i>P</i>. Then <code>a = a / c</code>. This can't be a division by zero, because <i>c</i> is now congrument to 1 modulo 4, and it resets <i>a</i> to 0 if <i>P</i>!=<i>p</i>. Finally restore the original value of <i>c</i> by adding -1+4*<i>P</i> to it. | |
| </p> | |
| <h3><span class="mw-headline" id="Compiling_individual_steps">Compiling individual steps</span></h3> | |
| <p>Now for each possible state <i>P</i> of the state machine, we have to emit instructions that do the intended effect on the simulated state counter and stacks if <i>P</i>==<i>p</i>, but leave the state of the simulated machine unchanged if <i>P</i>!=<i>p</i>. The instruction listing of the Blindfolded Arithmetic program has instructions for handling each state, and the instructions for one state have to be emitted together contiguously, but the order the states appear doesn't matter. | |
| </p><p>Almost all states transfer control to one or two different states, so let's see how to do that first. | |
| </p><p>If state <i>P</i> goes to state <i>P</i>', then we need to emit instructions that change <i>c</i> accordingly, but only if the current state <i>p</i> is <i>P</i>. So first set <i>a</i> to a condition code that is 1 if <i>P</i>=p, but 0 otherwise, in the way explained above. We then want to add 4*(<i>P</i>'-<i>P</i>)*<i>a</i> to <i>c</i>. We can do this by iterating <i>a</i> through powers of two times the original condition code, doubling with <code>a = a + a</code>, and adding or subtracting it to <i>b</i> according to the bits of 4*abs(<i>P</i>'-<i>P</i>) with <code>c = c + a</code> or <code>c = c - a</code>. You have to emit these instructions for the control transfer immediately after any instructions that do the side effects. | |
| </p><p>Now consider a conditional branch. Suppose that the state <i>P</i> branches to <i>P</i>_0 if the condition is false, or to <i>P</i>_1 if the condition is true. To perform such a conditional branch, first check the condition in a way that it leaves 1 or 0 in <i>a</i> according to whether it is true or false. Then do the sequence that checks if the current state is <i>P</i>. Then add 4*(<i>P</i>_1-P)*<i>a</i> to <i>c</i>, which branches to the landing pad if the condition is true. Finally emit a jump from <i>P</i> to <i>P_0</i>. | |
| </p><p>Now let's see the code for testing specific conditions. | |
| </p> | |
| <ul><li>Checking if the second stack is empty is the simplest: <code>a = i / i; a = a / i</code>.</li> | |
| <li>To check if the top element of the first stack is 1, do <code>b = i / i; b = b + b; a = d / b; a = a + a; a = d - a</code>. (If you want to avoid instructions that don't work in Babbage, write <code>a = i / i; a = a + a; b = d / a; b = b + b; a = d - b</code> instead, even though that breaks our usual register usage conventions.)</li> | |
| <li>Similarly, to check if the top element of the second stack is 0, do <code>b = i / i; b = b + b; a = i / b; a = a + a; a = d - a</code>.</li></ul> | |
| <p>All these sequences leave 1 in <i>a</i> if the condition is true, and 0 if it's false. All of them execute regardless of the state counter <i>p</i>, but this is not a problem since they have no side effects on the simulated machine. | |
| </p><p>Now for the states that do actions with side effects. The instructions for these all start by checking if the machine is executing that specific state, setting <i>a</i> to 1 if it is, and to 0 otherwise. | |
| </p> | |
| <ul><li>To push 0 to the first stack, do <code>b = i / i; a = a + b; d = d * a</code>.</li> | |
| <li>To push 1 to the first stack, do <code>b = i / i; a = a + b; d = d * a; a = a - b; d = d + a</code>.</li> | |
| <li>To push 0 to the second stack, do <code>b = i / i; a = a + b; i = i * a</code>.</li> | |
| <li>To push 1 to the second stack, do <code>b = i / i; a = a + b; i = i * a; a = a - b; i = i - a</code>.</li> | |
| <li>To pop the first stack, do <code>b = i / i; a = a + b; d = d / a</code>.</li> | |
| <li>To pop the second stack, do <code>i = i + a; b = i / i; a = a + b; i = i / a</code>.</li> | |
| <li>To halt, assuming you've already put the correct output minus one to the second stack, <code>b = i / i; a = a - b; a = a / a</code>.</li></ul> | |
| <h3><span class="mw-headline" id="Four_variables">Four variables</span></h3> | |
| <p>It's probably possible to forego using one more variable if you accept somewhat more complicated Blindfolded Arithmetic code, but I haven't documented the details yet. TODO | |
| </p> | |
| <h3><span class="mw-headline" id="Spare_registers">Spare registers</span></h3> | |
| <p>When the above constructions leave registers unused, you can modify the constructions to use them to speed up the program. The easiest idea is to use a register as an extra stack. Three stacks let you efficiently copy, reverse, merge or sort vectors, any of which is slow with just two stacks. Alternately you can use a register as a pointer for an extra read head into existing stacks, which is still enough to speed up vector operations, but also easily lets you write an interpreter that reads code that is stored far away on a stack while the data is near the top of the stack. | |
| </p> | |
| <h3><span id="Ais523.27s_Turing-completeness_proof"></span><span class="mw-headline" id="Ais523's_Turing-completeness_proof">Ais523's Turing-completeness proof</span></h3> | |
| <p>We can prove this language Turing-complete by translating Minsky | |
| machines into it. We'll use a formalization of Minsky machines with | |
| three counters (of which counter C contains the initial input), and | |
| the following set of commands, each of which is formed from a | |
| condition and an action: | |
| </p> | |
| <ul><li><b>Conditions</b> | |
| <ul><li>run unconditionally</li> | |
| <li>run if <i>counter</i> is 1; do nothing if the value is 2 or greater; | |
| <dl><dd>undefined behaviour if the value is 0</dd></dl></li></ul></li> | |
| <li><b>Actions</b> | |
| <ul><li>increment <i>counter</i></li> | |
| <li>decrement <i>counter</i>; decrementing 0 or 1 is undefined behaviour</li> | |
| <li>goto location X</li> | |
| <li>halt, outputting the value in counter C minus the value in counter A</li></ul></li></ul> | |
| <p>It's fairly obvious that any Minsky machine can be written in this | |
| form (you need to start off by unconditionally incrementing counters A | |
| and B, then you simply treat a value of 1 as your "zero point" and | |
| never let the counters go lower). The limited conditionals can be | |
| made into arbitrary conditionals by conditionally running a goto | |
| command. Two counters is enough for Turing-completeness, but for | |
| noninteractive-IO-completeness (which is what the question wants), we | |
| need either three counters or a more complex I/O encoding. It's | |
| simplest to use three counters so that we don't have to pack and | |
| unpack the I/O encoding. | |
| </p><p><code>e</code> is used as the instruction pointer, pointing to the active command | |
| in the Minsky Machine program. This is initially 0, so we need to | |
| zero-index our commands (i.e. the first command is IP 0). We use only | |
| even numbers for instructions (with odd-numbered instruction pointers | |
| conceptually pointing to implicit "no-op" commands). Additionally, we | |
| make it undefined behaviour to run off the end of the program (this is | |
| not a problem as you could just put an unconditional goto there). | |
| </p><p>The counter values are stored in <code>a</code> (A), <code>b</code> (B), and <code>i</code> (C). | |
| Counter C is never allowed to reach zero (except temporarily for very | |
| brief periods). <code>c</code> is used as a flag to determine if the command | |
| should run. <code>d</code> is used as a temporary. | |
| </p><p>The basic idea is to write the implementation of each Minsky command | |
| in sequence, where each command is implemented such that if <code>e</code> has a | |
| particular value, it will mimic the effect of that command, and if <code>e</code> | |
| does not have that value, the implementation will do nothing. Each | |
| command starts off the same way, by setting <code>c</code> to 1 if <code>e</code> has a | |
| given value <i>N</i> and 0 otherwise: | |
| </p> | |
| <ul><li><code>d = i / i</code> (now <code>d</code> is 1)</li> | |
| <li>Do <code>e = e - d</code> <i>N</i> times (now <code>e</code> is 0 iff <code>e</code> = <i>N</i>)</li> | |
| <li><code>c = e + e</code> (now <code>c</code> is 0 iff <code>e</code> = <i>N</i> and even)</li> | |
| <li><code>c = c + c</code> (now <code>c</code> is 0 iff <code>e</code> = <i>N</i> and a multiple of 4)</li> | |
| <li><code>c = c + d</code> (now <code>c</code> is 1 iff <code>e</code> = <i>N</i>, else ≥5 or ≤-3)</li> | |
| <li><code>c = d / c</code> (now <code>c</code> is 1 iff <code>e</code> = <i>N</i>, else 0)</li> | |
| <li>Do <code>e = e + d</code> <i>N</i> times (restoring it to its original value)</li></ul> | |
| <p>Next, we determine if the condition matches. If the condition is "run | |
| unconditionally", we have nothing to do. Otherwise, we want to set | |
| <code>c</code> to 0 (regardless of its previous value) if the counter in question | |
| has a value greater than 1. The below is shown for counter A, but you | |
| can consistently replace <code>a</code> with <code>b</code> or <code>i</code> to get the implementation | |
| of the other two nontrivial conditions: | |
| </p> | |
| <ul><li><code>d = d / a</code> (now <code>d</code> is 1 if <code>a</code> = 1, otherwise 0)</li> | |
| <li><code>c = c * d</code> (now <code>c</code> is 1 if both <code>e</code> = <i>N</i> and <code>a</code> = 1, otherwise 0)</li></ul> | |
| <p>Most of the commands now have an obvious implementation. To increment | |
| a counter (if the right command is running and the condition if any is | |
| met), we add <code>c</code> to <code>a</code>, <code>b</code>, or <code>i</code> as appropriate. To decrement a | |
| counter, we subtract <code>c</code> from the relevant variable. To do a goto | |
| command, we repeatedly do <code>e = e - c</code> or <code>e = e + c</code> to adjust the | |
| instruction pointer by the required offset. None of these commands | |
| will do anything if <code>c</code> is 0, of course. (Note that for goto, we jump | |
| to the no-op just before the target command, so that we never end up | |
| with two commands running in the same program iteration; this isn't | |
| technically necessary but is the simplest implementation to prove | |
| correct.) | |
| </p><p>To implement the fairly complex conditional halt, we do this: | |
| </p> | |
| <ul><li><code>d = i / i</code> (now <code>d</code> is 1)</li> | |
| <li><code>d = d - c</code> (now <code>d</code> is 0 if a halt is required, 1 otherwise)</li> | |
| <li><code>i = i - a</code> (now <code>i</code> is the value we'd want to output)</li> | |
| <li><code>d = d / d</code> (division-by-0 if a halt is required, otherwise no-op)</li> | |
| <li><code>i = i + a</code> (restores the value of <code>i</code>)</li></ul> | |
| <p>Note that the complexity is required so that we can output the entire | |
| range of integers, not just the positive integers, as required by the | |
| problem specification and the choice of the integers as the output | |
| set. | |
| </p><p>At the end of the Blindfolded Arithmetic program, we need to move onto | |
| the next Minsky Machine command for the next iteration. That looks | |
| like this: | |
| </p> | |
| <ul><li><code>d = i / i</code> (now <code>d</code> is 1)</li> | |
| <li><code>e = e + d</code></li></ul> | |
| <p>Note that we're only adding 1 at a time to <code>e</code>, in case we just ran a | |
| goto instruction. This means that while we aren't doing gotos, only | |
| every second iteration will do anything interesting. That isn't a | |
| problem; the next command in the program will still run eventually, | |
| and Turing-completeness proofs don't care about performance. | |
| </p> | |
| <h3><span class="mw-headline" id="Compile_from_Minsky_machine">Compile from Minsky machine</span></h3> | |
| <p>This <a href="/wiki/Blindfolded_Arithmetic/compile_from_Minsky_machine" title="Blindfolded Arithmetic/compile from Minsky machine"> python program</a> from <a href="/wiki/User:Jan_jelo" title="User:Jan jelo">User:Jan jelo</a> compiles Minsky machine program into Blindfolded Arithmetic program.(state 0 means halt,and program starts from state 1). | |
| Basically,<code>a</code> encodes two counters in <code>2^A*3^B</code> form(It is initialized to 1 by the program),<code>c</code> is used as an instruction pointer(Also initialized to 1 by the program.),<code>i</code> is used to generate constants and store intermediate results(Non-zero input is required),other registers are used to store intermediate results. | |
| </p><p>Test if x and y are equal by <code>1/((x-y)*(x-y)+1)</code>(This is used to compare the instruction pointer with a constant). | |
| </p><p>Test if counter A is equal to 0 by <code>a-a/2*2</code>,test if counter B is equal to 0 by <code>(1+a-a/3*3)/2</code>. | |
| </p><p>Increase counter A by <code>a=a*2</code>,decrease counter A by <code>a=a/2</code>. | |
| </p><p>Increase counter B by <code>a=a*3</code>,decrease counter B by <code>a=a/3</code>. | |
| </p><p><code>x=[cond]?y:z</code> is equivalent to <code>x=y*[cond]+z*(1-[cond])</code>. | |
| </p><p>All nested expressions described here will be expanded into the form of intermediate results. | |
| </p> | |
| <h2><span id="Babbage.27s_analytical_engine"></span><span class="mw-headline" id="Babbage's_analytical_engine">Babbage's analytical engine</span></h2> | |
| <p><a class="external text" href="https://www.ioccc.org/years.html#1992_buzzard.1" rel="nofollow">Sean Barrett described</a> a computational model very similar to Blindfolded Arithmetic in 1992. I call this Babbage's analytic engine. He implemented a particular program in C to show off this computational model. His program uses machine integers instead of arbitrary size integers, the halting condition differs, and the second operand may be a literal. His program is also restricted to doing only instructions where the output operand is the same register as the first input operand. This restriction is significant only if you want to do instructions like <code><i>v</i><sub>0</sub> = <i>v</i><sub>1</sub> - <i>v</i><sub>0</sub></code> or <code><i>v</i><sub>0</sub> = <i>v</i><sub>1</sub> / <i>v</i><sub>0</sub></code> where the two registers differ, and even those can be simulated with a clobbered spare register. The hint file claims that Babbage's actual analytic machine wouldn't have this restriction, it would allow operations on three arbitrary registers. Finally, the program has assignment instructions like <code><i>v</i><sub>0</sub> = <i>v</i><sub>1</sub></code>, but these could be readily written as <code><i>v</i><sub>0</sub> = <i>v</i><sub>0</sub> - <i>v</i><sub>0</sub>; <i>v</i><sub>0</sub> = <i>v</i><sub>0</sub> + <i>v</i><sub>1</sub></code>. | |
| </p> | |
| <h2><span class="mw-headline" id="See_also">See also</span></h2> | |
| <ul><li><a href="/wiki/Z3" title="Z3">Z3</a>, another similar language.</li> | |
| <li><a href="/wiki/Analytical_Engine_Programming_Cards" title="Analytical Engine Programming Cards">Analytical Engine Programming Cards</a> (John Walker)</li> | |
| <li><a href="/wiki/Imprecision" title="Imprecision">Imprecision</a></li> | |
| <li><a href="/wiki/General_blindfolded_arithmetic" title="General blindfolded arithmetic">General blindfolded arithmetic</a></li></ul> | |
| <h2><span class="mw-headline" id="External_links">External links</span></h2> | |
| <ul><li><a class="external text" href="https://codegolf.stackexchange.com/a/162531/" rel="nofollow">ais523's description of the Blindfolded Arithmetic language</a> on Code Golf Stack Exchange | |
| <ul><li><a class="external text" href="https://codegolf.stackexchange.com/a/163229/6691" rel="nofollow">Code Golf SE user202729's Turing-completeness proof</a></li> | |
| <li><a class="external text" href="http://nethack4.org/esolangs/blindfolded-arithmetic.md" rel="nofollow">ais523's Turing-completeness + batch-I/O-completeness proof</a></li></ul></li> | |
| <li><a class="external text" href="http://nethack4.org/esolangs/blindfolded-arithmetic-2var.txt" rel="nofollow">ais523's proof for Turing-completeness (without I/O) using only two of the six variables</a></li> | |
| <li><a class="external text" href="http://www.ioccc.org/years.html#1992_buzzard.1" rel="nofollow">IOCCC entry 1992/buzzard.1, defining an esoteric language called Babbage's Analytical Engine</a></li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20251215000117 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.027 seconds | |
| Real time usage: 0.075 seconds | |
| Preprocessor visited node count: 40/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:12054-0!canonical and timestamp 20251215000117 and revision id 170630. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b>Bouncy Counters</b> is an <a href="/wiki/Esoteric_programming_language" title="Esoteric programming language">esoteric programming language</a> created by <a href="/wiki/User:Ais523" title="User:Ais523">User:ais523</a> in <a href="/wiki/Category:2024" title="Category:2024">2024</a>, as a <a class="mw-redirect" href="/wiki/Reversible" title="Reversible">reversible</a> <a class="mw-redirect" href="/wiki/Counter_machine" title="Counter machine">counter machine</a> that is a <a href="/wiki/Turing_tarpit" title="Turing tarpit">Turing tarpit</a>. | |
| </p><p>ais523 has been known to remark that it is hard to prove <a href="/wiki/Turing-complete" title="Turing-complete">Turing-completeness</a> of reversible counter machines, because they are bad at emulating anything other than other reversible counter machines; Bouncy Counters is intended for use in such proofs. The specific language that inspired its creation was <a href="/wiki/Turn_Left" title="Turn Left">Turn Left</a>, although it was intended to also be useful for other reversible counter machine proofs. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Storage_model"><span class="tocnumber">1</span> <span class="toctext">Storage model</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Syntax"><span class="tocnumber">2</span> <span class="toctext">Syntax</span></a></li> | |
| <li class="toclevel-1 tocsection-3"><a href="#Semantics"><span class="tocnumber">3</span> <span class="toctext">Semantics</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-4"><a href="#Starting_and_stopping_the_program"><span class="tocnumber">3.1</span> <span class="toctext">Starting and stopping the program</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-5"><a href="#Reversibility"><span class="tocnumber">4</span> <span class="toctext">Reversibility</span></a></li> | |
| <li class="toclevel-1 tocsection-6"><a href="#Computational_class"><span class="tocnumber">5</span> <span class="toctext">Computational class</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-7"><a href="#With_five_counters"><span class="tocnumber">5.1</span> <span class="toctext">With five counters</span></a></li> | |
| <li class="toclevel-2 tocsection-8"><a href="#With_two_counters"><span class="tocnumber">5.2</span> <span class="toctext">With two counters</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-9"><a href="#External_resources"><span class="tocnumber">6</span> <span class="toctext">External resources</span></a></li> | |
| <li class="toclevel-1 tocsection-10"><a href="#See_also"><span class="tocnumber">7</span> <span class="toctext">See also</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Storage_model">Storage model</span></h2> | |
| <p>Bouncy Counters is based around a number of counters that can hold unbounded nonnegative integers. If an attempt is made to decrement a counter below 0, it becomes -1 for a brief moment, but the value immediately bounces back up to 0. (In particular, if you attempt to decrement 0, the counter's value remains at 0, but the most recent operation on the counter is considered to have been an increment operation.) Counters have names, which are nonnegative integers; the name of a counter is relevant only in that it provides a way of referring to the counter, and has no effect on the program execution otherwise. | |
| </p><p>There is no limit on how many counters can exist in any given program, but the set of which counters exist for any given program is fixed by the program and does not change at run time. The program specifies which counters exist (by specifying their names), and what their initial values are. | |
| </p> | |
| <h2><span class="mw-headline" id="Syntax">Syntax</span></h2> | |
| <p>Bouncy Counters has a line-based syntax. Four sorts of line are acceptable in the program source code: | |
| </p> | |
| <ul><li>A <i>comment line</i>, on which the first non-whitespace character is <code>#</code>, which is ignored and does nothing.</li> | |
| <li>A <i>blank line</i>, consisting only of whitespace, which is treated the same way as a comment line.</li> | |
| <li>A <i>counter definition</i>, of the form <code><i>counter</i>=<i>value</i></code>, which specifies that a counter exists in the program, and specifies its initial value. Each counter that is used in the program must be mentioned in exactly one counter definition. Optional horizontal whitespace is allowed at the start and end, and adjacent to the <code>=</code>.</li> | |
| <li>A <i>side definition</i>, of the form <code><i>side</i> <i>side</i></code>. A <i>side</i> is an identifier (consisting of letters, digits and underscores), followed by <code>+</code> or <code>-</code>; additionally, the longest suffix of the identifier that consists entirely of digits must name a counter. (For example, <code>A1B23+</code> is a side that refers to counter 23.) The two sides in a side definition must be separated by a positive amount of horizontal whitespace, and horizontal whitespace is also allowed (but not required) at the start and end.</li></ul> | |
| <p>There is a restriction on the side definitions: if a side appears anywhere in the program, it must appear exactly once among the left-hand sides of side definitions, and exactly once among the right-hand side of side definitions. (It is not allowed to have a side that appears more than once, or not at all, on the left or on the right.) | |
| </p> | |
| <h2><span class="mw-headline" id="Semantics">Semantics</span></h2> | |
| <p>In Bouncy Counters, instead of being a pointer to a location in the source program, the "instruction pointer" is a side. Execution proceeds by alternating between the following two steps: | |
| </p> | |
| <dl><dt>Counter change</dt> | |
| <dd>Change the counter referred to by the current side, by subtracting 1 (if the side ends with <code>-</code>) or adding 1 (if the side ends with <code>+</code>). If the counter bounces, then the <code>-</code> in the instruction pointer becomes a <code>+</code>.</dd> | |
| <dt>Next side</dt> | |
| <dd>Find the side definition that has the current side on the left. The current side becomes the right-hand side of that definition.</dd></dl> | |
| <h3><span class="mw-headline" id="Starting_and_stopping_the_program">Starting and stopping the program</span></h3> | |
| <p>Two sides are called <i>counterparts</i> if they are identical apart from the <code>+</code>/<code>-</code> at the end. A <code>+</code> side that has no counterpart is called a <i>start side</i>. A <code>-</code> side that has no counterpart is called a <i>stop side</i>. | |
| </p><p>At the start of the program, and immediately after every time the program stops, the implementation looks at the list of start sides that refer to counters with value 0. If no such start sides exist, the program halts. If exactly one exists, execution starts from that side. If more than one exists, the implementation asks the user which one to start at. Execution starts with a "next side" action, not a "counter change" action (as though the non-existent counterpart of the start side had bounced). | |
| </p><p>Stop sides represent places where program execution could stop: if a stop side's counter change bounces, then program execution cannot continue (because no side definition refers to its counterpart). If this occurs, then the implementation tells the user which stop side the program stopped at. The implementation then makes another attempt to find a start side to start at, as described in the previous paragraph, and halts only if it can find nowhere to start. | |
| </p><p>This start/stop behaviour is not required for Turing-completeness, and rather exists as a method of modelling I/O and of easily testing programs. Implementations that do not want to implement it can take the start side as an argument, and halt after bouncing to a stop side's counterpart; this can be seen as a variation of Bouncy Counters that is still Turing-complete. | |
| </p> | |
| <h2><span class="mw-headline" id="Reversibility">Reversibility</span></h2> | |
| <p>Bouncy Counters is <a class="mw-redirect" href="/wiki/Reversible" title="Reversible">reversible</a>; given the current side and the value of the counters, it is possible to determine what the previous side was and how it changed the counters, meaning that a program can be run backwards until its start (at which point it observes a counter having bounced from a <code>-</code> side that does not exist in the program). | |
| </p><p>There is a simple way to change a program to its reverse version: swap all <code>+</code> and <code>-</code> in the program, and swap the LHS and RHS of every side definition. | |
| </p> | |
| <h2><span class="mw-headline" id="Computational_class">Computational class</span></h2> | |
| <h3><span class="mw-headline" id="With_five_counters">With five counters</span></h3> | |
| <p>Imagine a generalisation of Bouncy Counters in which the restriction on the side definitions were loosened to allow a side to appear on the RHS of multiple side definitions, and/or to appear on the RHS but not LHS. That generalisation is just an alternative syntax for a <a href="/wiki/Minsky_machine" title="Minsky machine">Minsky machine</a>, which is known to be <a href="/wiki/Turing-complete" title="Turing-complete">Turing-complete</a>. As such, to prove Bouncy Counters to also be Turing-complete, all that is needed is to prove that the restriction can be worked around. | |
| </p><p>In order to allow a side to appear on the RHS of two side definitions, what is needed is a "merger subroutine", that can be entered using two sides but always leaves through the same side, and can be used any number of times. That way, it would be possible to replace the two uses of the same side with the entry sides of the merger subroutine, and define the exit side of the merger subroutine to have the original side as its next side. | |
| </p><p>This can be proved by giving an explicit implementation of a merger subroutine: | |
| </p> | |
| <pre># Enter via: A1- or B1- | |
| # Exits via: C1+ | |
| # counter 1 must be 0, for the entry to work | |
| 1 = 0 | |
| # but counter 2 and 3 can have any value | |
| 2 = 0 | |
| 3 = 0 | |
| A1+ C2- | |
| C2- A1+ | |
| B1+ C3- | |
| C3- B1+ | |
| C2+ C3+ | |
| C3+ C1- | |
| C1- C2+ | |
| </pre> | |
| <p>This merger subroutine functions as follows: | |
| </p> | |
| <ul><li>If the subroutine is entered by bouncing <code>B1-</code>, it adds the value of counter 3 to counter 2, restoring counter 1 back to 0, then exits by bouncing <code>C1-</code>.</li> | |
| <li>If the subroutine is entered by bouncing <code>A1-</code>, it adds 1 plus the value of counter 2 to counter 3, restoring counter 1 back to 0, then exits by bouncing <code>C1-</code>.</li></ul> | |
| <p>The values of counters 2 and 3 thus act as a <a href="/wiki/Bit_bucket" title="Bit bucket">bit bucket</a> that remembers where the code came from, allowing an apparently irreversible merge of control flow via storing a full history of it in order to maintain reversibility. | |
| </p><p>The ability to use a merger subroutine to merge two sides makes it possible to merge arbitrarily many sides, simply by using the merger subroutine multiple times to repeatedly merge two sides into one, until there is only one of the equivalent sides left. Additionally, it is possible for all the mergers to share the same counters (Bouncy Counters is not concurrent, so there is no situation in which two different mergers would be running at once; and any possible state that one merger could leave the counters in is a valid starting state for any other merger), so the mergers collectively only increase the number of required counters by 3. | |
| </p><p>In order to complete the proof, there is an additional restriction that needs to be loosened: that every side that appears on the LHS of a side definition also appears on the RHS. This restriction would end up naturally being violated by programs compiled from Minsky machines. (For example, imagine creating an infinite loop via connecting the C1 output of a merger to its A1 input with code like <code>C1+ A1-</code>: <code>C1+</code> would never appear on the right of a rule, and <code>A1-</code> would never appear on the left.) The trick here is to notice that the right-hand sides refer to decrements that will bounce every time they occur (e.g. <code>A1-</code> will <i>always</i> bounce because it is only used to enter the merger, and counter 1 always has value 0 at that time). As such, it is possible to add dummy side definitions with those sides on the left, in the knowledge that those side definitions will never be used and thus their right-hand sides don't matter. The number of "unmatched" sides on the RHS must, mathematically, match the number of unmatched sides on the LHS, so they can be paired up arbitrarily into dummy side definitions in order to create a legal program. | |
| </p> | |
| <h3><span class="mw-headline" id="With_two_counters">With two counters</span></h3> | |
| <p>It is possible to compile any Bouncy Counters program into one that uses only two counters; because Bouncy Counters is Turing-complete given sufficiently many counters, this proves that it is also Turing-complete even if only two counters are available. | |
| </p><p>This program demonstrates the general technique used by the compiler: | |
| </p> | |
| <pre># counter 1 stores the values of all the emulated counters | |
| 1 = 1 | |
| # counter 2 is a temporary that is usually 0 | |
| 2 = 0 | |
| # Divide counter 1 by 2 | |
| 2D2+ 2D1- | |
| 2D1- 1P2_1- | |
| 1P2_1- 2D2+ | |
| 2D1+ A2D2- | |
| A2D2- 2D1+ | |
| # Multiply counter 1 by 2 | |
| 2M2+ 2M1- | |
| 2M1- 2M2+ | |
| A2M2- 1P2_1+ | |
| 1P2_1+ 2M1+ | |
| 2M1+ A2M2- | |
| # Divide counter 1 by 3 | |
| 3D2+ 3D1- | |
| 3D1- 1P3_1- | |
| 1P3_1- 2P3_1- | |
| 2P3_1- 3D2+ | |
| 3D1+ A3D2- | |
| A3D2- 3D1+ | |
| # Multiply counter 1 by 3 | |
| 3M2+ 3M1- | |
| 3M1- 3M2+ | |
| A3M2- 2P3_1+ | |
| 2P3_1+ 1P3_1+ | |
| 1P3_1+ 3M1+ | |
| 3M1+ A3M2- | |
| </pre> | |
| <p>When starting at 2M2, it will multiply counter 1 by 2, stopping at A2M2 – likewise, starting at 3M2 will multiply counter 1 by 3, stopping at A3M2. When starting at 2D2, it will divide counter 1 by 2 (if it divides exactly), stopping at A2D2, and likewise for 3D2 dividing by 3 and stopping at A3D2. If a division fails because the input isn't divisible, the division will "bounce", leaving the counters the same but stopping as though it had just multiplied; for example, if counter 1 is not divisible by 3, starting at 3D2 will leave the counters the same and end at A3M2. This is accomplished by sharing some of the sides between the division and multiplication routines, so that a bounce during division (at a point that implies the division was not exact) will bounce into the corresponding part of the multiplication routine which will then reverse the division. | |
| </p><p>This program can be extended to primes other than 2 and 3, and arbitrarily many multiplication/division routines for each of the counters (including generating multiple distinct routines for the same prime). That makes it possible for it to represent a multiple-counter Bouncy Counters program directly: each counter of the emulated program becomes the exponent of a particular prime number within counter 1 of the emulating program, and each side compiles into a multiplication or division routine (a <code>-</code> side divides by the prime corresponding to the counter being decremented, a <code>+</code> side multiplies). A side definition can be implemented via renaming an output of one multiplication/division routine to match the input of another, e.g. <code>A3M2</code> could be connected to <code>2D2</code> by writing replacing all copies of <code>A3M2</code> with <code>2D2</code>. The start/stop behaviour otherwise is entirely metacircular (a start side in the emulated program becomes a start side in the emulating program, and likewise for stop sides) – this emulation is not quite perfect because it could provide starting points as options that would not have been choosable as options in the original program, but getting the I/O exactly right is not required for Turing-completeness. | |
| </p> | |
| <h2><span class="mw-headline" id="External_resources">External resources</span></h2> | |
| <ul><li><a class="external text" href="http://ais523.me.uk/esolangs/bouncy-counters/bouncy.pl" rel="nofollow">A non-optimizing Bouncy Counters implementation, written in Perl</a></li></ul> | |
| <h2><span class="mw-headline" id="See_also">See also</span></h2> | |
| <ul><li><a href="/wiki/Flow_of_Holes" title="Flow of Holes">Flow of Holes</a></li> | |
| <li><a href="/wiki/Reversible_Brainfuck#Unbounded_cells,_bounded_tape" title="Reversible Brainfuck">Reversible Brainfuck#Unbounded cells, bounded tape</a></li> | |
| <li><a href="/wiki/Delta_Relay" title="Delta Relay">Delta Relay</a></li> | |
| <li><a href="/wiki/Turn_Left" title="Turn Left">Turn Left</a></li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20250724012130 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.014 seconds | |
| Real time usage: 0.024 seconds | |
| Preprocessor visited node count: 42/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:20391-0!canonical and timestamp 20250724012130 and revision id 151415. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><dl><dd><span class="dablink"><i>Not to be confused with <a href="/wiki/BRaInFUCK" title="BRaInFUCK">BRaInFUCK</a>, <a href="/wiki/Brianfuck" title="Brianfuck">Brianfuck</a>, nor <a href="/wiki/Bra%E3%8F%8Cfuck" title="Bra㏌fuck">Bra㏌fuck</a>.</i></span></dd> | |
| <dd><i><b>BF</b> redirects here. For the category-theoretic object, see <a href="/wiki/BF_(category)" title="BF (category)">BF (category)</a>; for the language, see <a href="/wiki/BF_(BestCoder)" title="BF (BestCoder)">BF (BestCoder)</a>.</i></dd></dl> | |
| <p><a href="/wiki/Esolang:Featured_languages" title="Esolang:Featured languages"><span class="featured-icon" title="This is a featured language; *click* for more information."></span></a></p><div class="featured-text"> | |
| <dl><dd><i>This is a <a href="/wiki/Esolang:Featured_languages" title="Esolang:Featured languages">featured language</a>.</i></dd></dl> | |
| </div> | |
| <table style="float:right;border:1px solid silver;background-color:rgb(249, 249, 249);max-width:256px;padding:5px;"> | |
| <caption><b>brainfuck</b></caption> | |
| <tbody><tr> | |
| <th style="text-align: left;vertical-align: top;"><a href="/wiki/Esolang:Categorization#Paradigm" title="Esolang:Categorization">Paradigm(s)</a></th> | |
| <td>imperative</td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;">Designed by</th> | |
| <td><a href="/wiki/Urban_M%C3%BCller" title="Urban Müller">Urban Müller</a></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;"><a href="/wiki/Category:Years" title="Category:Years">Appeared in</a></th> | |
| <td><a href="/wiki/Category:1993" title="Category:1993">1993</a></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;"><a href="/wiki/Esolang:Categorization#Memory" title="Esolang:Categorization">Memory system</a></th> | |
| <td><a href="/wiki/Category:Cell-based" title="Category:Cell-based">Cell-based</a></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;"><a href="/wiki/Esolang:Categorization#Dimensions" title="Esolang:Categorization">Dimensions</a></th> | |
| <td>one-dimensional</td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;"><a href="/wiki/Computational_class" title="Computational class">Computational class</a></th> | |
| <td><a href="/wiki/Category:Turing_complete" title="Category:Turing complete">Turing complete</a></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;">Major implementations</th> | |
| <td><a class="external text" href="http://main.aminet.net/dev/lang/brainfuck-2.lha" rel="nofollow">Original</a>, <a class="external text" href="https://github.com/matslina/awib" rel="nofollow">Awib</a>, <a class="external text" href="https://web.archive.org/web/20230719142919/http://mazonka.com/brainf/" rel="nofollow">Optimizing BF interpreter</a> <i>(from the <a class="extiw" href="https://en.wikipedia.org/wiki/Wayback_Machine" title="wikipedia:Wayback Machine">Wayback Machine</a>; retrieved on 19 July 2023)</i></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;">Influenced by</th> | |
| <td><a href="/wiki/FALSE" title="FALSE">FALSE</a> <br/><a class="mw-redirect" href="/wiki/P%27%27" title="P''">P''</a></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;">Influenced</th> | |
| <td><a href="/wiki/Category:Brainfuck_derivatives" title="Category:Brainfuck derivatives">List of derivatives</a></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;">File extension(s)</th> | |
| <td><code>.b</code>, <code>.bf</code></td> | |
| </tr> | |
| </tbody></table> | |
| <dl><dd><i>Note that <b>brainfuck</b> is typically lowercased except, often, at the start of a sentence.</i></dd></dl> | |
| <p><b>Brainfuck</b> is one of the most famous <a href="/wiki/Esoteric_programming_language" title="Esoteric programming language">esoteric programming languages</a>, and has inspired the creation of a host of other languages. Due to the fact that the last half of its name is often considered an extremely offensive word in the English language, it is sometimes referred to as "brainf***", "brainf*ck", "brainfsck", "b****fuck" , "brainf**k", "branflakes", "brainoof", "brainfrick", "bf", etc. This can make it a bit difficult to search for information regarding brainfuck on the web, as the proper name might not be used at all in some articles. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Language_overview"><span class="tocnumber">1</span> <span class="toctext">Language overview</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#History"><span class="tocnumber">2</span> <span class="toctext">History</span></a></li> | |
| <li class="toclevel-1 tocsection-3"><a href="#Examples"><span class="tocnumber">3</span> <span class="toctext">Examples</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-4"><a href="#Hello,_World!"><span class="tocnumber">3.1</span> <span class="toctext">Hello, World!</span></a></li> | |
| <li class="toclevel-2 tocsection-5"><a href="#Move_value"><span class="tocnumber">3.2</span> <span class="toctext">Move value</span></a></li> | |
| <li class="toclevel-2 tocsection-6"><a href="#Cat"><span class="tocnumber">3.3</span> <span class="toctext">Cat</span></a></li> | |
| <li class="toclevel-2 tocsection-7"><a href="#Cell_size"><span class="tocnumber">3.4</span> <span class="toctext">Cell size</span></a></li> | |
| <li class="toclevel-2 tocsection-8"><a href="#Looping_counter"><span class="tocnumber">3.5</span> <span class="toctext">Looping counter</span></a></li> | |
| <li class="toclevel-2 tocsection-9"><a href="#Truth-machine"><span class="tocnumber">3.6</span> <span class="toctext">Truth-machine</span></a></li> | |
| <li class="toclevel-2 tocsection-10"><a href="#XKCD_Random_Number"><span class="tocnumber">3.7</span> <span class="toctext">XKCD Random Number</span></a></li> | |
| <li class="toclevel-2 tocsection-11"><a href="#Quine"><span class="tocnumber">3.8</span> <span class="toctext">Quine</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-12"><a href="#Self-interpreters"><span class="tocnumber">4</span> <span class="toctext">Self-interpreters</span></a></li> | |
| <li class="toclevel-1 tocsection-13"><a href="#Computational_class"><span class="tocnumber">5</span> <span class="toctext">Computational class</span></a></li> | |
| <li class="toclevel-1 tocsection-14"><a href="#Algorithms"><span class="tocnumber">6</span> <span class="toctext">Algorithms</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-15"><a href="#Simple_instruction_examples"><span class="tocnumber">6.1</span> <span class="toctext">Simple instruction examples</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-16"><a href="#Extensions"><span class="tocnumber">7</span> <span class="toctext">Extensions</span></a></li> | |
| <li class="toclevel-1 tocsection-17"><a href="#Conventions"><span class="tocnumber">8</span> <span class="toctext">Conventions</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-18"><a href="#Memory"><span class="tocnumber">8.1</span> <span class="toctext">Memory</span></a></li> | |
| <li class="toclevel-2 tocsection-19"><a href="#Input_and_Output"><span class="tocnumber">8.2</span> <span class="toctext">Input and Output</span></a> | |
| <ul> | |
| <li class="toclevel-3 tocsection-20"><a href="#Newlines"><span class="tocnumber">8.2.1</span> <span class="toctext">Newlines</span></a></li> | |
| <li class="toclevel-3 tocsection-21"><a href="#EOF"><span class="tocnumber">8.2.2</span> <span class="toctext">EOF</span></a></li> | |
| <li class="toclevel-3 tocsection-22"><a href="#Character_set"><span class="tocnumber">8.2.3</span> <span class="toctext">Character set</span></a></li> | |
| <li class="toclevel-3 tocsection-23"><a href="#GUI_and_Other_I/O"><span class="tocnumber">8.2.4</span> <span class="toctext">GUI and Other I/O</span></a> | |
| <ul> | |
| <li class="toclevel-4 tocsection-24"><a href="#GUI_Pong_/_Simple_UNIX_Shell"><span class="tocnumber">8.2.4.1</span> <span class="toctext">GUI Pong / Simple UNIX Shell</span></a></li> | |
| <li class="toclevel-4 tocsection-25"><a href="#PPM_file_output"><span class="tocnumber">8.2.4.2</span> <span class="toctext">PPM file output</span></a></li> | |
| </ul> | |
| </li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-2 tocsection-26"><a href="#Implementation_issues"><span class="tocnumber">8.3</span> <span class="toctext">Implementation issues</span></a> | |
| <ul> | |
| <li class="toclevel-3 tocsection-27"><a href="#Memory_and_wrapping"><span class="tocnumber">8.3.1</span> <span class="toctext">Memory and wrapping</span></a></li> | |
| <li class="toclevel-3 tocsection-28"><a href="#Newlines_2"><span class="tocnumber">8.3.2</span> <span class="toctext">Newlines</span></a></li> | |
| <li class="toclevel-3 tocsection-29"><a href="#EOF_2"><span class="tocnumber">8.3.3</span> <span class="toctext">EOF</span></a></li> | |
| </ul> | |
| </li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-30"><a href="#Related_languages"><span class="tocnumber">9</span> <span class="toctext">Related languages</span></a></li> | |
| <li class="toclevel-1 tocsection-31"><a href="#See_also"><span class="tocnumber">10</span> <span class="toctext">See also</span></a></li> | |
| <li class="toclevel-1 tocsection-32"><a href="#External_resources"><span class="tocnumber">11</span> <span class="toctext">External resources</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-33"><a href="#Notable_implementations"><span class="tocnumber">11.1</span> <span class="toctext">Notable implementations</span></a> | |
| <ul> | |
| <li class="toclevel-3 tocsection-34"><a href="#Compilers"><span class="tocnumber">11.1.1</span> <span class="toctext">Compilers</span></a></li> | |
| <li class="toclevel-3 tocsection-35"><a href="#Interpreters_in_plain_C"><span class="tocnumber">11.1.2</span> <span class="toctext">Interpreters in plain C</span></a></li> | |
| <li class="toclevel-3 tocsection-36"><a href="#Interpreters_in_C++"><span class="tocnumber">11.1.3</span> <span class="toctext">Interpreters in C++</span></a></li> | |
| <li class="toclevel-3 tocsection-37"><a href="#JIT_Interpreters"><span class="tocnumber">11.1.4</span> <span class="toctext">JIT Interpreters</span></a></li> | |
| <li class="toclevel-3 tocsection-38"><a href="#Hardware_implementations"><span class="tocnumber">11.1.5</span> <span class="toctext">Hardware implementations</span></a></li> | |
| <li class="toclevel-3 tocsection-39"><a href="#Libraries"><span class="tocnumber">11.1.6</span> <span class="toctext">Libraries</span></a></li> | |
| <li class="toclevel-3 tocsection-40"><a href="#JavaScript_interpreters"><span class="tocnumber">11.1.7</span> <span class="toctext">JavaScript interpreters</span></a></li> | |
| <li class="toclevel-3 tocsection-41"><a href="#Rust_interpreter"><span class="tocnumber">11.1.8</span> <span class="toctext">Rust interpreter</span></a></li> | |
| <li class="toclevel-3 tocsection-42"><a href="#Docker_runtime"><span class="tocnumber">11.1.9</span> <span class="toctext">Docker runtime</span></a></li> | |
| <li class="toclevel-3 tocsection-43"><a href="#Python_interpreters"><span class="tocnumber">11.1.10</span> <span class="toctext">Python interpreters</span></a></li> | |
| <li class="toclevel-3 tocsection-44"><a href="#Dart_interpreters"><span class="tocnumber">11.1.11</span> <span class="toctext">Dart interpreters</span></a></li> | |
| <li class="toclevel-3 tocsection-45"><a href="#Batchfile_interpreters"><span class="tocnumber">11.1.12</span> <span class="toctext">Batchfile interpreters</span></a></li> | |
| <li class="toclevel-3 tocsection-46"><a href="#Powershell_interpreters"><span class="tocnumber">11.1.13</span> <span class="toctext">Powershell interpreters</span></a></li> | |
| <li class="toclevel-3 tocsection-47"><a href="#Haskell_interpreters"><span class="tocnumber">11.1.14</span> <span class="toctext">Haskell interpreters</span></a></li> | |
| <li class="toclevel-3 tocsection-48"><a href="#Interpreters_in_other_esolangs"><span class="tocnumber">11.1.15</span> <span class="toctext">Interpreters in other esolangs</span></a></li> | |
| </ul> | |
| </li> | |
| </ul> | |
| </li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Language_overview">Language overview</span></h2> | |
| <p>Brainfuck operates on an array of memory cells, each initially set to zero. (In the original implementation, the array was 30,000 cells long, but this may not be part of the language specification; different sizes for the array length and cell size give different variants of the language). There is a <a href="/wiki/Pointer" title="Pointer">pointer</a>, initially pointing to the first memory cell. The commands are: | |
| </p> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <th>Command | |
| </th> | |
| <th>Description | |
| </th></tr> | |
| <tr> | |
| <td style="text-align:center"><code>></code> | |
| </td> | |
| <td>Move the pointer to the right | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center"><code><</code> | |
| </td> | |
| <td>Move the pointer to the left | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center"><code>+</code> | |
| </td> | |
| <td>Increment the memory cell at the pointer | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center"><code>-</code> | |
| </td> | |
| <td>Decrement the memory cell at the pointer | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center"><code>.</code> | |
| </td> | |
| <td>Output the character signified by the cell at the pointer | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center"><code>,</code> | |
| </td> | |
| <td>Input a character and store it in the cell at the pointer | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center"><code>[</code> | |
| </td> | |
| <td>Jump past the matching <code>]</code> if the cell at the pointer is 0 | |
| </td></tr> | |
| <tr> | |
| <td style="text-align:center"><code>]</code> | |
| </td> | |
| <td>Jump back to the matching <code>[</code> if the cell at the pointer is nonzero | |
| </td></tr></tbody></table> | |
| <p>All characters other than <code>><+-.,[]</code> should be considered comments and ignored. But, see extensions below. | |
| </p> | |
| <h2><span class="mw-headline" id="History">History</span></h2> | |
| <p>Brainfuck was invented by <a href="/wiki/Urban_M%C3%BCller" title="Urban Müller">Urban Müller</a> in <a href="/wiki/Category:1993" title="Category:1993">1993</a>, in an attempt to make a language for which he could write the smallest possible <a href="/wiki/Compiler" title="Compiler">compiler</a> for the Amiga OS, version 2.0. He managed to write a 240-byte compiler. The language was inspired by <a href="/wiki/FALSE" title="FALSE">FALSE</a>, which had a 1024-byte compiler. Müller chose to name the language <i>brainfuck</i> (with the initial letter in lower case, although it is now often capitalised). | |
| </p><p>It is not known to what extent Müller was aware of or influenced by Böhm's language <a href="/wiki/P%E2%80%B2%E2%80%B2" title="P′′">P′′</a> published in 1964, of which brainfuck can be considered a minor variation. | |
| </p> | |
| <h2><span class="mw-headline" id="Examples">Examples</span></h2> | |
| <h3><span id="Hello.2C_World.21"></span><span class="mw-headline" id="Hello,_World!"><a class="mw-redirect" href="/wiki/Hello,_World!" title="Hello, World!">Hello, World!</a></span></h3> | |
| <p>This program prints out the words <i>Hello World!</i>: | |
| </p> | |
| <div style="border: 1px solid #ddd;padding:1em;background-color:#f9f9f9;font-family: monospace,Courier;"> | |
| <p><font color="#a52a2a"> 1 </font><font color="#ff00ff">+++++</font> <font color="#ff00ff">+++</font> <font color="#0000ff">Set Cell #0 to 8</font><br/> | |
| <font color="#a52a2a"> 2 </font><font color="#a52a2a"><b>[</b></font><br/> | |
| <font color="#a52a2a"> 3 </font> <font color="#2e8b57"><b>></b></font><font color="#ff00ff">++++</font> <font color="#0000ff">Add 4 to Cell #1; this will always set Cell #1 to 4</font><br/> | |
| <font color="#a52a2a"> 4 </font> <font color="#a52a2a"><b>[</b></font> <font color="#0000ff">as the cell will be cleared by the loop</font><br/> | |
| <font color="#a52a2a"> 5 </font> <font color="#2e8b57"><b>></b></font><font color="#ff00ff">++</font> <font color="#0000ff">Add 4*2 to Cell #2</font><br/> | |
| <font color="#a52a2a"> 6 </font> <font color="#2e8b57"><b>></b></font><font color="#ff00ff">+++</font> <font color="#0000ff">Add 4*3 to Cell #3</font><br/> | |
| <font color="#a52a2a"> 7 </font> <font color="#2e8b57"><b>></b></font><font color="#ff00ff">+++</font> <font color="#0000ff">Add 4*3 to Cell #4</font><br/> | |
| <font color="#a52a2a"> 8 </font> <font color="#2e8b57"><b>></b></font><font color="#ff00ff">+</font> <font color="#0000ff">Add 4 to Cell #5</font><br/> | |
| <font color="#a52a2a"> 9 </font> <font color="#2e8b57"><b><<<<</b></font><font color="#ff00ff">-</font> <font color="#0000ff">Decrement the loop counter in Cell #1</font><br/> | |
| <font color="#a52a2a">10 </font> <font color="#a52a2a"><b>]</b></font> <font color="#0000ff">Loop till Cell #1 is zero</font><br/> | |
| <font color="#a52a2a">11 </font> <font color="#2e8b57"><b>></b></font><font color="#ff00ff">+</font> <font color="#0000ff">Add 1 to Cell #2</font><br/> | |
| <font color="#a52a2a">12 </font> <font color="#2e8b57"><b>></b></font><font color="#ff00ff">+</font> <font color="#0000ff">Add 1 to Cell #3</font><br/> | |
| <font color="#a52a2a">13 </font> <font color="#2e8b57"><b>></b></font><font color="#ff00ff">-</font> <font color="#0000ff">Subtract 1 from Cell #4</font><br/> | |
| <font color="#a52a2a">14 </font> <font color="#2e8b57"><b>>></b></font><font color="#ff00ff">+</font> <font color="#0000ff">Add 1 to Cell #6</font><br/> | |
| <font color="#a52a2a">15 </font> <font color="#a52a2a"><b>[</b></font><font color="#2e8b57"><b><</b></font><font color="#a52a2a"><b>]</b></font> <font color="#0000ff">Move back to the first zero cell you find; this will</font><br/> | |
| <font color="#a52a2a">16 </font> <font color="#0000ff">be Cell #1 which was cleared by the previous loop</font><br/> | |
| <font color="#a52a2a">17 </font> <font color="#2e8b57"><b><</b></font><font color="#ff00ff">-</font> <font color="#0000ff">Decrement the loop Counter in Cell #0</font><br/> | |
| <font color="#a52a2a">18 </font><font color="#a52a2a"><b>]</b></font> <font color="#0000ff">Loop till Cell #0 is zero</font><br/> | |
| <font color="#a52a2a">19 </font><br/> | |
| <font color="#a52a2a">20 </font><font color="#0000ff">The result of this is:</font><br/> | |
| <font color="#a52a2a">21 </font><font color="#0000ff">Cell No : 0 1 2 3 4 5 6</font><br/> | |
| <font color="#a52a2a">22 </font><font color="#0000ff">Contents: 0 0 72 104 88 32 8</font><br/> | |
| <font color="#a52a2a">23 </font><font color="#0000ff">Pointer : ^</font><br/> | |
| <font color="#a52a2a">24 </font><br/> | |
| <font color="#a52a2a">25 </font><font color="#2e8b57"><b>>></b></font><font color="#6a5acd">.</font> <font color="#0000ff">Cell #2 has value 72 which is 'H'</font><br/> | |
| <font color="#a52a2a">26 </font><font color="#2e8b57"><b>></b></font><font color="#ff00ff">---</font><font color="#6a5acd">.</font> <font color="#0000ff">Subtract 3 from Cell #3 to get 101 which is 'e'</font><br/> | |
| <font color="#a52a2a">27 </font><font color="#ff00ff">+++++</font> <font color="#ff00ff">++</font><font color="#6a5acd">..</font><font color="#ff00ff">+++</font><font color="#6a5acd">.</font> <font color="#0000ff">Likewise for 'llo' from Cell #3</font><br/> | |
| <font color="#a52a2a">28 </font><font color="#2e8b57"><b>>></b></font><font color="#6a5acd">.</font> <font color="#0000ff">Cell #5 is 32 for the space</font><br/> | |
| <font color="#a52a2a">29 </font><font color="#2e8b57"><b><</b></font><font color="#ff00ff">-</font><font color="#6a5acd">.</font> <font color="#0000ff">Subtract 1 from Cell #4 for 87 to give a 'W'</font><br/> | |
| <font color="#a52a2a">30 </font><font color="#2e8b57"><b><</b></font><font color="#6a5acd">.</font> <font color="#0000ff">Cell #3 was set to 'o' from the end of 'Hello'</font><br/> | |
| <font color="#a52a2a">31 </font><font color="#ff00ff">+++</font><font color="#6a5acd">.</font><font color="#ff00ff">-----</font> <font color="#ff00ff">-</font><font color="#6a5acd">.</font><font color="#ff00ff">-----</font> <font color="#ff00ff">---</font><font color="#6a5acd">.</font> <font color="#0000ff">Cell #3 for 'rl' and 'd'</font><br/> | |
| <font color="#a52a2a">32 </font><font color="#2e8b57"><b>>></b></font><font color="#ff00ff">+</font><font color="#6a5acd">.</font> <font color="#0000ff">Add 1 to Cell #5 gives us an exclamation point</font><br/> | |
| <font color="#a52a2a">33 </font><font color="#2e8b57"><b>></b></font><font color="#ff00ff">++</font><font color="#6a5acd">.</font> <font color="#0000ff">And finally a newline from Cell #6</font><br/> | |
| </p> | |
| </div> | |
| <p>The same program in minimised form: | |
| </p> | |
| <pre>++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++. | |
| </pre> | |
| <p>This is another program that prints out <code>Hello, World!</code> with correct spacing, case and punctuation: | |
| </p> | |
| <pre>+++++++++++[>++++++>+++++++++>++++++++>++++>+++>+<<<<<<-]>+++ | |
| +++.>++.+++++++..+++.>>.>-.<<-.<.+++.------.--------.>>>+.>-. | |
| </pre> | |
| <p>This is a slightly more complex variant that often triggers interpreter bugs. This uses cell values below zero and so doesn't work on <a class="external text" href="https://brainfuck.org/" rel="nofollow">unreasonably restrictive, score-computing interpreters</a>. | |
| </p> | |
| <pre>>++++++++[-<+++++++++>]<.>>+>-[+]++>++>+++[>[->+++<<+++>]<<]>-----.>-> | |
| +++..+++.>-.<<+[>[+>+]>>]<--------------.>>.+++.------.--------.>+.>+. | |
| </pre> | |
| <p>Short program printing Hello, World! by primo from <a class="external free" href="https://codegolf.stackexchange.com/a/68494/6691" rel="nofollow">https://codegolf.stackexchange.com/a/68494/6691</a>. This program needs four cells to the left of the starting point (so standard scoring would give it an adjustment of four instructions and four ticks) and requires wrapping byte sized cells. | |
| </p> | |
| <pre>--<-<<+[+[<+>--->->->-<<<]>]<<--.<++++++.<<-..<<.<+.>>.>>.<<<.+++.>>.>>-.<<<+. | |
| </pre> | |
| <p>Currently, the shortest known program printing Hello, World! is written by KSab from <a class="external free" href="https://codegolf.stackexchange.com/a/163590/59487" rel="nofollow">https://codegolf.stackexchange.com/a/163590/59487</a> (this program needs 5 cells to the left of the starting point): | |
| </p> | |
| <pre>+[-->-[>>+>-----<<]<--<---]>-.>>>+.>>..+++[.>]<<<<.+++.------.<<-.>>>>+. | |
| </pre> | |
| <p>Big Hello World program | |
| </p> | |
| <pre><+>+>+>+>+>+>+>+>+>+>+ <<<<<<<<<<>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.>+++++++++++++++++++++++++++++++++++++++++++.>-.>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++. | |
| </pre> | |
| <h3><span class="mw-headline" id="Move_value">Move value</span></h3> | |
| <p>This code piece moves the value of the current cell (<i>cell0</i>) two cells to the right (<i>cell2</i>): | |
| </p> | |
| <pre>>>[-]<<[->>+<<] | |
| </pre> | |
| <p>With indentation and comments the same code looks like this: | |
| </p> | |
| <pre>Code: Pseudo code: | |
| >> Move the pointer to cell2 | |
| [-] Set cell2 to 0 | |
| << Move the pointer back to cell0 | |
| [ While cell0 is not 0 | |
| - Subtract 1 from cell0 | |
| >> Move the pointer to cell2 | |
| + Add 1 to cell2 | |
| << Move the pointer back to cell0 | |
| ] End while | |
| </pre> | |
| <h3><span class="mw-headline" id="Cat">Cat</span></h3> | |
| <p>A <a href="/wiki/Cat_program" title="Cat program">cat program</a> writes its input directly to its output. As there is not a standard way to handle EOF in brainfuck, there are four versions of the program below and a non-terminating one, labelled by how they match common implementations of the interpreter. (see <a href="#Implementation_issues"> Implementation issues</a>). | |
| </p><p><b>EOF returns 0:</b> | |
| </p> | |
| <pre>,[.,] | |
| </pre> | |
| <p><b>EOF returns -1:</b> | |
| </p> | |
| <pre>,+[-.,+] | |
| </pre> | |
| <p><b>No change on EOF, or EOF returns 0:</b> | |
| </p> | |
| <pre>,[.[-],] | |
| </pre> | |
| <p><b>No change on EOF, or EOF returns -1:</b> | |
| </p> | |
| <pre>,+[-.[-]-,+] | |
| </pre> | |
| <p><b>Never terminates:</b> | |
| </p> | |
| <pre>+[>,.<] | |
| </pre> | |
| <h3><span class="mw-headline" id="Cell_size">Cell size</span></h3> | |
| <p>This program outputs the cell width of the interpreter: | |
| </p> | |
| <pre>Calculate the value 256 and test if it's zero | |
| If the interpreter errors on overflow this is where it'll happen | |
| ++++++++[>++++++++<-]>[<++++>-] | |
| +<[>-< | |
| Not zero so multiply by 256 again to get 65536 | |
| [>++++<-]>[<++++++++>-]<[>++++++++<-] | |
| +>[> | |
| # Print "32" | |
| ++++++++++[>+++++<-]>+.-.[-]< | |
| <[-]<->] <[>> | |
| # Print "16" | |
| +++++++[>+++++++<-]>.+++++.[-]< | |
| <<-]] >[> | |
| # Print "8" | |
| ++++++++[>+++++++<-]>.[-]< | |
| <-]< | |
| # Print " bit cells\n" | |
| +++++++++++[>+++>+++++++++>+++++++++>+<<<<-]>-.>-.+++++++.+++++++++++.<. | |
| >>.++.+++++++..<-.>>-. | |
| Clean up used cells | |
| [[-]<] | |
| </pre> | |
| <h3><span class="mw-headline" id="Looping_counter"><a href="/wiki/Looping_counter" title="Looping counter">Looping counter</a></span></h3> | |
| <pre>>>++++++++++[[->+<<++++>]<++[<]>[.>]>.] | |
| </pre> | |
| <h3><span class="mw-headline" id="Truth-machine"><a href="/wiki/Truth-machine" title="Truth-machine">Truth-machine</a></span></h3> | |
| <p><b>Without explanation</b> | |
| </p> | |
| <pre>+++++++++>>,<<[->+++++<]>+++[>-<-]>>+++++[>++++++++++<-]>-<<[>>.<<]>>-. | |
| </pre> | |
| <p><b>With explanation</b> | |
| </p> | |
| <pre>+++++++++ Add 9 to the first cell | |
| >>, Set the input to the third cell | |
| <<[->+++++<] Multiply the first cell (9) by 5 in the second cell | |
| >+++ Add 3 to the second cell | |
| [>-<-] Subtract the second cell from the third cell | |
| >>+++++[>++++++++++<-]>- Get the ASCII code for '1' | |
| <<[>>.<<]>>-. If the input is ASCII '1': Print ASCII '1' forever | |
| Else: Print ASCII '0' once | |
| </pre> | |
| <p><b>Alternate version</b> | |
| </p><p>This version prints out whatever character the user did input, even if it isn't the digit "1". | |
| </p> | |
| <pre>>,>>>+++[-<++>]<[-<++++[-<-->]>]<<[-<+>>+<]>[-<+>]<[[-]>>+++[-<++>]<[-<++++[ | |
| -<++>]>]<<[.]]>>+++[-<++>]<[-<++++[-<++>]>]<<. | |
| </pre> | |
| <p>Made by: <a href="/wiki/User:RixTheTyrunt" title="User:RixTheTyrunt">User:RixTheTyrunt</a> | |
| </p><p><b>Optimisations:</b> | |
| </p><p><b>Without explanation</b> | |
| </p> | |
| <pre>+++++++[>+++++++<-],>[>+<<->-]<[>-<[-]]>+[>[.]]>-. | |
| </pre> | |
| <p><b>With explanation</b> | |
| </p> | |
| <pre>+++++++[>+++++++<-] Set second cell to 49 (1) | |
| , Take input to first cell | |
| >[>+<<->-]< Delete first cell by second cell and copy second cell to third cell | |
| [>-<[-]]>+ Set second cell to not first cell and clear first cell | |
| [>[.]] If second cell is 1: recursively print '1' | |
| >-. Else: print '0' | |
| </pre> | |
| <p><b>Alternate version without explanation</b> | |
| </p><p>This version prints whatever character the user inputs, even if it isn't "1". | |
| </p> | |
| <pre>++++++++[>------<-],[>+>+<<-]>[>[.]]>. | |
| </pre> | |
| <p><b>Alternate version with explanation</b> | |
| </p> | |
| <pre>++++++++[>------<-] Set second cell to -48 (0) (208) | |
| , Take input to first cell | |
| [>+>+<<-] Add first cell to second and third cell | |
| >[>[.]] If second cell is not 0: recursively print input | |
| >. Else: print 0 | |
| </pre> | |
| <p>Made by: <a href="/wiki/User:Eating-dinner" title="User:Eating-dinner">User:Eating-dinner</a> | |
| </p> | |
| <h3><span class="mw-headline" id="XKCD_Random_Number"><a class="mw-redirect" href="/wiki/XKCD_Random_Number" title="XKCD Random Number">XKCD Random Number</a></span></h3> | |
| <pre>++++[->+++<]>+[->++++<]>. | |
| </pre> | |
| <p>With comments: | |
| </p> | |
| <pre>+c+h+o+s[e-n> +b+y+ <f]a>i+r[ -d>i+c+e+ +r<o]l-l+>; | |
| Guaranteed to be random. | |
| </pre> | |
| <h3><span class="mw-headline" id="Quine"><a href="/wiki/Quine" title="Quine">Quine </a></span></h3> | |
| <p>A quine is a program that prints itself. This one was written by Erik Bosman, also available at <a class="external free" href="https://copy.sh/brainfuck/prog/quine505.b" rel="nofollow">https://copy.sh/brainfuck/prog/quine505.b</a>. | |
| </p> | |
| <pre>-->+++>+>+>+>+++++>++>++>->+++>++>+>>>>>>>>>>>>>>>>->++++>>>>->+++>+++>+++>+++>+ | |
| ++>+++>+>+>>>->->>++++>+>>>>->>++++>+>+>>->->++>++>++>++++>+>++>->++>++++>+>+>++ | |
| >++>->->++>++>++++>+>+>>>>>->>->>++++>++>++>++++>>>>>->>>>>+++>->++++>->->->+++> | |
| >>+>+>+++>+>++++>>+++>->>>>>->>>++++>++>++>+>+++>->++++>>->->+++>+>+++>+>++++>>> | |
| +++>->++++>>->->++>++++>++>++++>>++[-[->>+[>]++[<]<]>>+[>]<--[++>++++>]+[<]<<++] | |
| >>>[>]++++>++++[--[+>+>++++<<[-->>--<<[->-<[--->>+<<[+>+++<[+>>++<<]]]]]]>+++[>+ | |
| ++++++++++++++<-]>--.<<<] | |
| </pre> | |
| <h2><span class="mw-headline" id="Self-interpreters">Self-interpreters</span></h2> | |
| <p>Writing a self-interpreter in brainfuck is not a simple task, yet, several self-interpreters have been written throughout the years. | |
| </p> | |
| <ul><li><a class="external text" href="http://www.iwriteiam.nl/Ha_bf_inter.html" rel="nofollow">by Frans Faase</a> - Perhaps the first one.</li> | |
| <li><a class="external text" href="http://www.iwriteiam.nl/Ha_vs_bf_inter.html" rel="nofollow">by NYYRIKKI</a></li> | |
| <li><a class="external text" href="https://web.archive.org/web/20170517143215/http://www.brain------------------------------------------------------fuck.com/programs/kbfi.b" rel="nofollow">by Keymaker</a> <i>(from the <a class="extiw" href="https://en.wikipedia.org/wiki/Wayback_Machine" title="wikipedia:Wayback Machine">Wayback Machine</a>; retrieved on 17 May 2017)</i> - Designed in the strictest 8-bit, non-wrapping, EOF = no change (EOF 0 works too) environment. The program emulates unbound cell size for cells (the program +[+] is valid and never ends) -- not really a brainfuck feature but it's there anyway -- and of course all the brainfuck programs written for the 8-bit non-wrapping environment work as supposed to. Supports infinite/unbound number of cells and nested loops.</li> | |
| <li><a class="external text" href="https://brainfuck.org/dbfi.b" rel="nofollow">by Daniel B Cristofani</a> - The shortest; see also <a href="/wiki/Dbfi" title="Dbfi">dbfi</a> | |
| <ul><li><a class="external text" href="https://github.com/bf-enterprise-solutions/meta.bf" rel="nofollow">meta.bf by Brainfuck Enterprise Solutions</a> - designed as a drop-in embeddable meta-interpeter to add DBFI scripting to any BF program.</li></ul></li> | |
| <li><a class="external text" href="https://web.archive.org/web/20210225021709/homepages.xnet.co.nz/~clive/eigenratios/cgbfi2.b" rel="nofollow">by Clive Gifford</a> <i>(from the <a class="extiw" href="https://en.wikipedia.org/wiki/Wayback_Machine" title="wikipedia:Wayback Machine">Wayback Machine</a>; retrieved on 25 February 2021)</i> - The fastest</li> | |
| <li><a class="external text" href="https://github.com/ludamad/bf-self-interpreter" rel="nofollow">by Adam Domurad</a> - Interprets Brainfuck code from the input until a %, then reads remaining input as input for the interpreted program. Comments are allowed, and up to 256-depth nested loops</li> | |
| <li><a class="external text" href="https://github.com/VilgotanL/Bf-Transpilers/blob/master/bf_self_interpreter.bf" rel="nofollow">by VilgotanL</a> - Originally written in <a href="/wiki/VBF" title="VBF">VBF</a> and transpiled to brainfuck, designed in 8-bit wrapping brainfuck, supports infinite nested loop depth, errors, assumes zero or no-change on eof, uses an optional ! in the input to separate the program and the input.</li> | |
| <li><a href="/wiki/Mbfi" title="Mbfi">by Ørjan Johansen</a> - Designed for achieving a calculable <a href="/wiki/Eigenratio" title="Eigenratio">eigenratio</a>.</li></ul> | |
| <h2><span class="mw-headline" id="Computational_class">Computational class</span></h2> | |
| <p>When the array is <a class="mw-redirect" href="/wiki/Unbounded" title="Unbounded">unbounded</a>, or when the array is at least three cells long and can store unbounded values, brainfuck is <a href="/wiki/Turing-complete" title="Turing-complete">Turing-complete</a>, meaning that it is in the same <a href="/wiki/Computational_class" title="Computational class">computational class</a> as <a class="mw-redirect" href="/wiki/Universal_Turing_machine" title="Universal Turing machine">universal Turing machines</a>. This, plus its dearth of commands, makes it a canonical example of a <a href="/wiki/Turing_tarpit" title="Turing tarpit">Turing tarpit</a>. | |
| </p><p>This can be shown in a number of ways and with various restrictions on the brainfuck program and/or interpreter. The following formulations require the array to be unbounded, but allow the value in each cell to be bounded: | |
| </p> | |
| <ul><li>Daniel B Cristofani's <a class="external text" href="https://brainfuck.org/utm.b" rel="nofollow">implementation of a universal Turing machine in brainfuck</a> provides a proof by <a href="/wiki/Computational_class#Simulation" title="Computational class">simulation</a>.</li> | |
| <li>Fairly trivial <a href="/wiki/Computational_class#Reduction" title="Computational class">reductions</a> can also be drawn between brainfuck and <a class="mw-redirect" href="/wiki/P%27%27" title="P''">P''</a>, which has been formally shown to be Turing-complete.</li> | |
| <li><a href="/wiki/User:Keymaker" title="User:Keymaker">User:Keymaker</a> <a href="/wiki/Brainfuck_minus_-" title="Brainfuck minus -">has shown that</a> brainfuck is Turing-complete even if you can only adjust cells by incrementing 0s to 1s. | |
| <ul><li><a href="/wiki/%C3%98rjan_Johansen" title="Ørjan Johansen">Ørjan Johansen</a> <a href="/wiki/Brainfuck_minus_-#Depth_two_nesting" title="Brainfuck minus -">has added</a> the further restriction that loops can only be nested two levels deep.</li></ul></li></ul> | |
| <p>Other formulations allow the array to be bounded, but require that the value in each cell be unbounded: | |
| </p> | |
| <ul><li>Frans Faase gives a procedure for translating 5-register Universal Register Machines into brainfuck programs using five cells <a class="external autonumber" href="http://www.iwriteiam.nl/Ha_bf_Turing.html" rel="nofollow">[1]</a>.</li> | |
| <li><a href="/wiki/%C3%98rjan_Johansen" title="Ørjan Johansen">Ørjan Johansen</a> has made a conversion from iterated <a href="/wiki/Collatz_function" title="Collatz function">Collatz functions</a> to 3-cell brainfuck <a href="/wiki/Collatz_function#Reduction_to_3-cell_brainfuck" title="Collatz function">(see that page for details)</a>.</li> | |
| <li><a href="/wiki/User:Ais523" title="User:Ais523">User:ais523</a> <a class="external text" href="https://cs.stackexchange.com/questions/102363/how-many-pairs-of-brackets-in-bf-be-sufficient-enough-to-make-it-turing-complete/102369#102369" rel="nofollow">has proved</a> that <a href="/wiki/The_Waterfall_Model" title="The Waterfall Model">The Waterfall Model</a> can be transformed into brainfuck with only three pairs of loop brackets in the whole program. The number of cells needed to make this Turing-complete is theoretically bounded (based on the number of waterclocks needed for TWM), but is not precisely known. | |
| <ul><li>Ørjan Johansen <a class="external text" href="https://cs.stackexchange.com/questions/102363/how-many-pairs-of-brackets-in-bf-be-sufficient-enough-to-make-it-turing-complete/102500#102500" rel="nofollow">improved</a> this construction to use only two pairs of loop brackets in the whole program. User:ais523 implemented the resulting construction, giving <a class="external text" href="http://nethack4.org/esolangs/2bbf.pl" rel="nofollow">a compiler from The Waterfall Model (without output, and with only one halt counter) to two-loop brainfuck</a>. The algorithm used always uses less than 48<i>n</i>² cells (where <i>n</i> is the number of counters), and less than 24<i>n</i>² cells if the number of counters is 1 less than half a prime number.</li></ul></li></ul> | |
| <p>And still others require both the array and the value in each cell to be unbounded: | |
| </p> | |
| <ul><li>Frans Faase gives <a class="external text" href="http://www.iwriteiam.nl/Ha_bf_Turing.html" rel="nofollow">a procedure for transforming Turing machines into brainfuck programs</a> which constitutes a proof by translation.</li></ul> | |
| <h2><span class="mw-headline" id="Algorithms">Algorithms</span></h2> | |
| <p>See <a href="/wiki/Brainfuck_algorithms" title="Brainfuck algorithms">Brainfuck algorithms</a>, <a href="/wiki/Brainfuck_constants" title="Brainfuck constants">Brainfuck constants</a>. | |
| </p> | |
| <h3><span class="mw-headline" id="Simple_instruction_examples">Simple instruction examples</span></h3> | |
| <ul><li><code>[+]</code> or <code>[-]</code> can be used to set the value to 0</li> | |
| <li>After having set it to 0 you can use repetions of <code>+</code> or <code>-</code> to get to any number you want</li> | |
| <li>We can check if the value in the pointers location is not a specific constant, by subtracting that amount or adding 255-that amount and than using the execute if not 0 loop</li> | |
| <li>We can execute a forever executing loop by making sure the value at the pointer won't be 0 when <code>]</code> is reached.</li> | |
| <li>If a cell only holds the values 0 and 255 (which will be interpreted as FALSE and TRUE in conditionals), we can use <code>+</code> which makes it become 1 and 0 (TRUE and FALSE in conditionals), so <code>+</code> can negate the truth values, and than to negate that code you can use <code>-</code></li></ul> | |
| <h2><span class="mw-headline" id="Extensions">Extensions</span></h2> | |
| <p>Some implementations also recognize the following symbols as meaningful: | |
| </p> | |
| <pre># Start debugger (e.g. Print contents of first few memory cells) | |
| ! Separate code from input | |
| </pre> | |
| <p>The debug command # comes from brainfuck's original interpreter, written by Urban Müller. Because brainfuck programs have only one input source, brainfuck interpreters written in brainfuck (or other languages without file I/O) require ! to be able to distinguish a program's code from the input it is intended to process. | |
| </p><p>As all characters other than <code>><+-.,[]</code> should be considered comments and ignored, it is normal for an interpreter to have a method of disabling these extensions if required. This disabling may be automatic for '!' based on such things as if there is currently an open loop and/or if the program is being read from the 'standard input'. | |
| </p><p>As these commands are non-standard some interpreters use different codes for these functions. | |
| </p><p>Probably the next most frequently implemented extension is a command to comment out the rest of the line, however, experienced brainfuck programmers generally consider this useless mostly due to the existence of the <a href="/wiki/Brainfuck_algorithms#Header_comment" title="Brainfuck algorithms">header comments technique</a>. | |
| </p> | |
| <h2><span class="mw-headline" id="Conventions">Conventions</span></h2> | |
| <p>The following summarizes the common conventions for making a brainfuck interpreter or compiler. It can be seen as a general specification for brainfuck, commonly accepted amongst the brainfuck community as a minimal base. | |
| It attempts to solve implementation issues by standardizing them. | |
| </p> | |
| <h3><span class="mw-headline" id="Memory">Memory</span></h3> | |
| <ul><li>Memory should normally consist of 8 bit cells, a very fast compiler may use 32bit or larger cells. Floating point cells are strongly discouraged as are cells that are not a power of two in size. "Bignum" cells are allowed but should be an option.</li> | |
| <li>Memory should wrap on overflow and underflow. (This also includes the <code>[-]</code> function with "bignum" cells).</li> | |
| <li>Negative memory addresses should NOT be assumed to exist, however, an interpreter may provide some. (An optimising interpreter may be forced to)</li> | |
| <li>Memory should consist of at least 30000 cells, some existing brainfuck programs do need more so this should be configurable or unbounded.</li></ul> | |
| <h3><span class="mw-headline" id="Input_and_Output">Input and Output</span></h3> | |
| <h4><span class="mw-headline" id="Newlines">Newlines</span></h4> | |
| <p>The input should be "line buffered" until the user enters a newline at which point the program receives the edited line. | |
| </p> | |
| <ul><li>OS newlines should be converted to 10 for input.</li> | |
| <li>10s should be converted to OS newlines for output.</li></ul> | |
| <p>Note that most programming platforms and programming languages already do this for you, which might make converting 10s to OS newlines redundant. | |
| </p> | |
| <h4><span class="mw-headline" id="EOF">EOF</span></h4> | |
| <p>An interpreter should normally either return Zero or leave the cell unchanged on EOF. | |
| </p><p>The Zero option matches the brainfuck language in that the only conditional in brainfuck is a comparison with zero. Using this form, in theory, allows slightly shorter code. For eight bit cells the "leave the cell untouched" matches the C/Unix read(2) system call in that the character memory will be left unchanged on EOF. For Unix the EOF (or error) condition is signalled by the return value, which is lost with BF. If the interpreter's cells are more than eight bits the "unchanged cell" can safely handle binary data. If the cells are eight bit or the interpreter sets the cells to zero on EOF binary data cannot be handled. | |
| </p><p>For a brainfuck program this means that ASCII data+EOF should be read using a <code>[-],</code> construct (or similar). Binary input should, probably, be read using a construct of the form <code>[-]-,</code>. This requires that input bytes are in the range 0..255 when the cell size exceeds eight bits. | |
| </p><p>Note: It is strongly recommended that an interpreter be configurable to all three normal form of EOF (Zero, minus one and unchanged). | |
| </p> | |
| <h4><span class="mw-headline" id="Character_set">Character set</span></h4> | |
| <p>The original brainfuck interpreter used the native character set of the host, ISO8859-1. Most modern brainfuck interpreters do the same, so this means that many current implementations will used UTF-8 as the character set and have access to ANSI control sequences. The majority of brainfuck programs only use ASCII with newlines, but the few that use extended sets follow the UTF-8+Ansi pattern. | |
| </p> | |
| <h4><span id="GUI_and_Other_I.2FO"></span><span class="mw-headline" id="GUI_and_Other_I/O">GUI and Other I/O</span></h4> | |
| <h5><span id="GUI_Pong_.2F_Simple_UNIX_Shell"></span><span class="mw-headline" id="GUI_Pong_/_Simple_UNIX_Shell">GUI Pong / Simple UNIX Shell</span></h5> | |
| <p>Using a <a class="external text" href="https://github.com/lestrozi/pipevm" rel="nofollow">Virtual Machine controlled via stdin/out</a>, here's a <a class="external text" href="https://github.com/lestrozi/pipevm/blob/main/tests/bfponggen.py" rel="nofollow">Pong implementation</a> and <a class="external text" href="https://github.com/lestrozi/pipevm/blob/main/tests/sh.bf" rel="nofollow">a simple UNIX shell implementation (that actually controls a real filesystem)</a> | |
| </p><p><span class="mw-default-size" typeof="mw:File"><a class="mw-file-description" href="/wiki/File:Pong.gif"><img class="mw-file-element" decoding="async" height="238" src="/w/images/a/af/Pong.gif" width="318"/></a></span> | |
| <span class="mw-default-size" typeof="mw:File"><a class="mw-file-description" href="/wiki/File:Shell.gif"><img class="mw-file-element" decoding="async" height="500" src="/w/images/thumb/6/63/Shell.gif/952px-Shell.gif" srcset="/w/images/6/63/Shell.gif 1.5x" width="952"/></a></span> | |
| </p> | |
| <h5><span class="mw-headline" id="PPM_file_output">PPM file output</span></h5> | |
| <p>For a more trivial output the <a class="external text" href="https://en.wikipedia.org/wiki/Netpbm" rel="nofollow">PPM, PGM and PPM formats or Netpbm</a> can be generated in a simple format as plain (ASCII) text. | |
| </p><p><span class="mw-default-size" typeof="mw:File"><a class="mw-file-description" href="/wiki/File:Mandelbrot-mono-bf.png"><img class="mw-file-element" decoding="async" height="238" src="/w/images/thumb/a/a3/Mandelbrot-mono-bf.png/317px-Mandelbrot-mono-bf.png" srcset="/w/images/thumb/a/a3/Mandelbrot-mono-bf.png/476px-Mandelbrot-mono-bf.png 1.5x, /w/images/thumb/a/a3/Mandelbrot-mono-bf.png/635px-Mandelbrot-mono-bf.png 2x" width="317"/></a></span> | |
| </p> | |
| <h3><span class="mw-headline" id="Implementation_issues">Implementation issues</span></h3> | |
| <p>Brainfuck leaves a lot of things up to the implementation to decide, such as array and cell size, what is output's regulation, and what happens when EOF is read. | |
| </p> | |
| <h4><span class="mw-headline" id="Memory_and_wrapping">Memory and wrapping</span></h4> | |
| <p>The size of the cells and the cell array varies a lot in different implementations. A usual implementation will have either 8bit or 32bit cells with 30000 cells (in the positive direction). For Turing completeness either the number of cells must be unbounded or (at least) three unbounded cells are required, the former is usually assumed. | |
| </p><p>Urban Müller's compiler used an array of 30000 cells 8bit cells, while the interpreter only allowed 100 (of 5000) to be used. As the compiler was written in assembler there is no indication as to whether the cells are to be assumed to be signed or unsigned and the overflow semantics are of the usual twos complement (or unsigned byte) wrapping form. The interpreter uses signed 8bit characters (-128 to 127 range). | |
| </p><p>Other interpreters normally use a similar layout, however, some allow cells to the left of the start position or use different allowed ranges of cell values. Some limit the cells to only positive values or other reduced ranges, others allow a larger range including 'floating point' (which would usually be in effect a 53bit integer without wrapping) or even completely unbounded integers. | |
| </p><p>Note, that it's not possible for a brainfuck program to determine if its integers are officially signed or unsigned unless they are also non-wrapping. If the cells don't wrap then the loops [-] and [+] used after an number in the opposite direction will cause a crash (ie: an exception or a hang). Most optimisers will therefore assume these sequences set a zero even with unbounded integers. | |
| </p><p>Even with wrapping cells code can be written that depends on the cell size for example <a href="/wiki/Brainfuck_bitwidth_conversions#Multiple_conversions" title="Brainfuck bitwidth conversions">Brainfuck bitwidth conversions</a> or the code below (which only works correctly with 8bits). | |
| </p> | |
| <pre><font color="#c000c0">+</font><font color="#804000">[[</font><font color="#c000c0">-</font><font color="#008000">></font><font color="#804000">]</font><font color="#c000c0">-</font><font color="#804000">[</font><font color="#c000c0">-</font><font color="#008000"><</font><font color="#804000">]</font><font color="#008000">></font><font color="#c000c0">-</font><font color="#804000">]</font><font color="#008000">></font><font color="#c00000">.</font><font color="#008000">>>>></font><font color="#c00000">.</font><font color="#008000"><<<<</font><font color="#c000c0">-</font><font color="#c00000">.</font><font color="#008000">>></font><font color="#c000c0">-</font><font color="#c00000">.</font><font color="#008000">></font><font color="#c00000">.</font><font color="#008000"><<</font><font color="#c00000">.</font><font color="#008000">>>>></font><font color="#c000c0">-</font><font color="#c00000">.</font><font color="#008000"><<<<<</font><font color="#c000c0">++</font><font color="#c00000">.</font><font color="#008000">>></font><font color="#c000c0">++</font><font color="#c00000">.</font> | |
| </pre> | |
| <h4><span class="mw-headline" id="Newlines_2">Newlines</span></h4> | |
| <p>The vast majority of brainfuck programs, following Urban Müller's original example programs, use 10 as newline on both input and output; this is also the convention used by Unix-based operating systems, including Linux and Mac OS X. Some other operating systems use different conventions for newline, and may use different conventions on input and on output, and different conventions in different programming environments (e.g. C versus assembly language). Several solutions to the problem are possible: | |
| </p> | |
| <ul><li>Write brainfuck programs to accept multiple linefeed conventions. (Possible, though clunky, on input; not generally possible on output.)</li> | |
| <li>Write many versions of each brainfuck program, one for each programming environment. (Possible, but very unpleasant.)</li> | |
| <li>Forget portability and write programs for whatever implementation you are using. (A fairly common approach. May make it hard to share programs if your interpreter doesn't use 10 as newline.)</li> | |
| <li>Write brainfuck interpreters and compilers to translate newline to 10 on input, and 10 to newline on output, in environments where that is not already the case. (Easy and helpful, but often overlooked. Also, may break the few brainfuck programs that do binary i/o; so newline translation should ideally be able to be turned off with a switch.)</li> | |
| <li>Instead of having the user hit the "Enter" key, expect the user to do something else to give a 10 to the interpreter; e.g., the user can feed the input from a file which uses 10s to end the lines, rather than from the keyboard. Send the output to a file too. (Possible but clunky.)</li></ul> | |
| <p>A few implementations allow the input to be "raw" and sometimes non-blocking. If the input is in "raw" mode it is not line buffered and key presses are passed to the program immediately. Non-blocking means that if there isn't a character available either immediately or after a short delay (for example 1/10 of a second) the input command will return an EOF indication. | |
| </p> | |
| <h4><span class="mw-headline" id="EOF_2">EOF</span></h4> | |
| <p>EOF is a controversial issue. Many implementations return 0, some return -1, and several notable brainfuck programmers suggest that on EOF the memory cell should be left as-is, without modification. In the original distribution the compiler left the cell unchanged, while the interpreter used the EOF from C which, strictly speaking, could be any negative integer, but which usually is -1 (which, in the case of byte-sized cells, ends up as 255). | |
| </p> | |
| <h2><span class="mw-headline" id="Related_languages">Related languages</span></h2> | |
| <p>See also <a href="/wiki/Brainfuck_extensions" title="Brainfuck extensions">Brainfuck extensions</a>. | |
| </p><p>In publishing the formal programming language <a class="mw-redirect" href="/wiki/P%27%27" title="P''">P''</a> in 1964, Corrado Böhm used six symbols <i>precisely</i> equivalent to the brainfuck commands <code>+</code>, <code>-</code>, <code><</code>, <code>></code>, <code>[</code>, and <code>]</code>, and provided an explicit program for each of the basic functions that together serve to compute any partial recursive function. (So in a very real sense, the first "brainfuck" programs appear in Bohm's 1964 paper.) | |
| </p><p>Many people at various times have tried to extend brainfuck to make it easier to program in, but such efforts have been compared to trying to make a luxury car by gluing parts onto a skateboard. Other people have been interested in variations of the language for theoretical purposes, pedagogical applications, etc. The sheer proliferation of languages equivalent to and derived from brainfuck led Chris Pressey to dub it "the <a class="extiw" href="https://en.wikipedia.org/wiki/twelve-bar_blues" title="wikipedia:twelve-bar blues">twelve-bar blues</a> of esolang". Some of the more interesting variants: | |
| </p> | |
| <ul><li><a href="/wiki/Pbrain" title="Pbrain">pbrain</a> is a brainfuck extension that supports procedures.</li> | |
| <li><a href="/wiki/Cbrain" title="Cbrain">cbrain</a> is a derivative of pbrain as implemented in pbrain.c, adding integers and operators.</li> | |
| <li><a href="/wiki/RUM" title="RUM">RUM</a> stands for "bRainfUck iMproved." and adds procedures, strings and repetition.</li> | |
| <li><a href="/wiki/Toadskin" title="Toadskin">Toadskin</a> is a brainfuck variant that supports procedures, but uses a stack instead of an array.</li> | |
| <li><a href="/wiki/Brainfork" title="Brainfork">Brainfork</a> adds a Y command to fork the current thread.</li> | |
| <li><a href="/wiki/Fm" title="Fm">Fm</a> edits a string on alphabet {0,1,...,m-1} (m >= 2).</li> | |
| <li><a href="/wiki/FRAK" title="FRAK">FRAK</a> assembles instructions to brainfuck code.</li> | |
| <li><a href="/wiki/BF_Joust" title="BF Joust">BF Joust</a> and <a class="mw-redirect" href="/wiki/FYB" title="FYB">FYB</a> pit two Brainfuck-like programs against each other, as in Core War (see <a href="/wiki/Redcode" title="Redcode">Redcode</a>).</li> | |
| <li><a href="/wiki/Smallfuck" title="Smallfuck">Smallfuck</a> operates only on bits and has no input- or output-commands.</li> | |
| <li><a href="/wiki/Bitter" title="Bitter">Bitter</a> one-bit memory cells, four commands, equivalent to <a href="/wiki/Smallfuck" title="Smallfuck">Smallfuck</a> under certain circumstances</li> | |
| <li><a href="/wiki/Spoon" title="Spoon">Spoon</a> uses a Huffman coded set of instructions corresponding to Brainfuck's commands.</li> | |
| <li><a href="/wiki/BrainDuino" title="BrainDuino">BrainDuino</a> BF port on <a class="external text" href="https://en.wikipedia.org/wiki/Arduino" rel="nofollow">Arduino</a> HW platform (based on Atmel's ATMega). Extended by two special I/O operations and special overflow protection.</li> | |
| <li><a href="/wiki/Puzzlang" title="Puzzlang">Puzzlang</a> turns every program into an exercise in patience and logic puzzle skills. The lone X operator becomes any of brainfuck's instructions, depending on the surrounding characters.</li> | |
| <li><a href="/wiki/Alarm_Clock_Radio" title="Alarm Clock Radio">Alarm Clock Radio</a> throws away the instructions to decrement the memory pointer or memory value.</li> | |
| <li><a href="/wiki/Portal" title="Portal">Portal</a> and <a href="/wiki/Portal_2" title="Portal 2">Portal 2</a> allows code-level pointer manipulation and theoretically implements the Wang-B Machine.</li> | |
| <li><a href="/wiki/Tbf" title="Tbf">tbf</a> is a language that can be compiled to Brainfuck. It includes variables, strings, macros and improved loops.</li> | |
| <li><a href="/wiki/Grin" title="Grin">Grin</a> adds more efficient arithmetic functions to Brainfuck.</li> | |
| <li><a href="/wiki/TinyBF" title="TinyBF">tinyBF</a> and its variant <a href="/wiki/RISBF" title="RISBF">RISBF</a> are brainfuck equivalents with only 4 opcodes.</li> | |
| <li><a href="/wiki/Grawlix" title="Grawlix">Grawlix</a> adds stack operations, decimal I/O, another loop structure, functions and multiply/divide by two.</li> | |
| <li><a href="/wiki/Brainfuckconsole74" title="Brainfuckconsole74">brainfuckconsole74</a> extends brainfuck to a fantasy console like pico8. it renders first 256 cells as 16x16 pixels, reads keyboard&mouse-input and plays sound.</li> | |
| <li><a href="/wiki/Motherf" title="Motherf">Motherf</a> adds a variety of useful commands and principles like macros, stack, functions, convenient I/O, booleans and simulation of other types.</li> | |
| <li><a href="/wiki/BFFuck" title="BFFuck">BFFuck</a> and <a href="/wiki/Headache" title="Headache">Headache</a> are high-level languages that compile to brainfuck.</li> | |
| <li><a href="/wiki/Brainbits" title="Brainbits">brainbits</a> is a brainfuck derivative that uses bit cells.</li> | |
| <li><a href="/wiki/Hyperinotoidion" title="Hyperinotoidion">Hyperinotoidion</a> is a joke.</li></ul> | |
| <p>Some other funny variants: | |
| </p> | |
| <ul><li><a href="/wiki/Ook!" title="Ook!">Ook!</a> works exactly like brainfuck, except the syntax is in Orangutan.</li> | |
| <li><a href="/wiki/Blub" title="Blub">Blub</a> is the same for fish.</li> | |
| <li><a href="/wiki/Brainloller" title="Brainloller">Brainloller</a> has the same commands as brainfuck, except they're read from a png image.</li> | |
| <li><a href="/wiki/COW" title="COW">COW</a> is the bovine version of "Ook!", except cows are slow to react so the loops are different.</li> | |
| <li><a href="/wiki/Microwave" title="Microwave">Microwave</a> is inspired by COW and Ook!, except it uses only microwave sounds.</li> | |
| <li><a href="/wiki/Pi" title="Pi">Pi</a> obfuscates Brainfuck instructions in random errors in pi digits.</li></ul> | |
| <p>Some languages inspired by brainfuck, but with more major differences: | |
| </p> | |
| <ul><li><a href="/wiki/Aura" title="Aura">Aura</a> requires data to be stored in the code space.</li> | |
| <li><a href="/wiki/PATH" title="PATH">PATH</a> and <a href="/wiki/SNUSP" title="SNUSP">SNUSP</a> attempt to combine brainfuck with <a href="/wiki/Befunge" title="Befunge">Befunge</a>.</li> | |
| <li><a href="/wiki/Wierd" title="Wierd">Wierd</a> arose out of an earlier attempt to combine brainfuck with Befunge.</li></ul> | |
| <h2><span class="mw-headline" id="See_also">See also</span></h2> | |
| <ul><li><a href="/wiki/Brainfuck_implementations" title="Brainfuck implementations">Brainfuck implementations</a></li> | |
| <li><a href="/wiki/Brainfuck_algorithms" title="Brainfuck algorithms">Brainfuck algorithms</a></li> | |
| <li><a href="/wiki/Brainfuck_constants" title="Brainfuck constants">Brainfuck constants</a></li> | |
| <li><a href="/wiki/Brainfuck_code_generation" title="Brainfuck code generation">Brainfuck code generation</a></li> | |
| <li><a href="/wiki/Asm2bf" title="Asm2bf">asm2bf</a> - the only true brainfuck assembler.</li> | |
| <li><a href="/wiki/BFBASIC" title="BFBASIC">BFBASIC</a>, a Basic to brainfuck compiler</li> | |
| <li><a href="/wiki/FBP" title="FBP">FBP</a>, a high level language to brainfuck compiler</li> | |
| <li><a href="/wiki/Binary_lambda_calculus" title="Binary lambda calculus">Binary lambda calculus</a>, featuring an 829 bit (under 104 bytes) Brainfuck interpreter</li> | |
| <li><a href="/wiki/Brainfuck_bitwidth_conversions" title="Brainfuck bitwidth conversions">Brainfuck bitwidth conversions</a></li> | |
| <li><a href="/wiki/BF_instruction_minimalization" title="BF instruction minimalization">BF instruction minimalization</a></li> | |
| <li><a href="/wiki/Trivial_brainfuck_substitution" title="Trivial brainfuck substitution">Trivial brainfuck substitution</a> and the <a class="external text" href="https://esolangs.org/wiki/Special:WhatLinksHere/Trivial_brainfuck_substitution" rel="nofollow">list of them</a>.</li> | |
| <li><a href="/wiki/BFO" title="BFO">BFO</a>, the first known brainfuck to brainfuck optimizer and compressor</li> | |
| <li><a href="/wiki/Category:Brainfuck" title="Category:Brainfuck">Category:Brainfuck</a>, a collection of brainfuck related articles on this wiki</li> | |
| <li><a href="/wiki/Brainfuck_minus_-" title="Brainfuck minus -">Brainfuck minus -</a>, showing that ordinary brainfuck without the '-' instruction and cell range of 0-1 (without cell-wrapping!) is still Turing-complete</li> | |
| <li><a href="/wiki/Category:Brainfuck_derivatives" title="Category:Brainfuck derivatives">Category:Brainfuck derivatives</a>, languages based on brainfuck</li> | |
| <li><a href="/wiki/Shorten_your_Brainfuck_code" title="Shorten your Brainfuck code">Shorten your Brainfuck code</a></li> | |
| <li><a href="/wiki/BF_busy_beaver" title="BF busy beaver">BF busy beaver</a></li> | |
| <li><a href="/wiki/EsoInterpreters" title="EsoInterpreters">EsoInterpreters</a>, featuring several brainfuck interpreters written in other esoteric languages</li> | |
| <li>(is this project alive?) <a href="/wiki/C2BF" title="C2BF">C2BF</a>, a partially implemented C to brainfuck compiler</li></ul> | |
| <h2><span class="mw-headline" id="External_resources">External resources</span></h2> | |
| <ul><li><a class="external text" href="https://www.muppetlabs.com/~breadbox/bf/" rel="nofollow">Brian Raiter's site</a> contains a summary, an informal standards guide, and a couple of interesting programs.</li> | |
| <li><a class="external text" href="http://www.iwriteiam.nl/Ha_BF.html" rel="nofollow">Frans Faase's site</a> includes a proof that brainfuck is Turing-complete.</li> | |
| <li><a class="external text" href="https://brainfuck.org/" rel="nofollow">some brainfuck fluff</a> contains many interesting programs, a solid interpreter, and suggestions for programmers and implementors, among other things.</li> | |
| <li><a class="external text" href="https://sange.fi/esoteric/brainfuck/" rel="nofollow">The Brainfuck Archive</a> has a large selection of programs, implementations and utilities.</li> | |
| <li><a class="external text" href="https://sourceforge.net/p/brainfuck/discussion/201037/" rel="nofollow">Brainfuck Golf</a> is a contest with the goal of writing a shortest program to do a certain task; see <a href="/wiki/Golf" title="Golf">golf</a>.</li> | |
| <li><a class="external text" href="https://web.archive.org/web/20170913173425/http://www.brain------------------------------------------------------fuck.com/" rel="nofollow">brain------------------------------------------------------fuck.com</a> <i>(from the <a class="extiw" href="https://en.wikipedia.org/wiki/Wayback_Machine" title="wikipedia:Wayback Machine">Wayback Machine</a>; retrieved on 13 September 2017)</i> features some interesting brainfuck programs.</li> | |
| <li><a class="external text" href="http://alx2002.free.fr/esoterism/brainfuck/brainfuck_en.html" rel="nofollow">brainfuck tutorial</a></li> | |
| <li><a class="external text" href="https://jonripley.com/brainfuck/executable" rel="nofollow">Making executable BF programs</a> contains information on how to make executable brainfuck programs.</li> | |
| <li><a class="external text" href="https://web.archive.org/web/20111031121638/http://jonripley.com/i-fiction/games/LostKingdomBF.html" rel="nofollow">The Lost Kingdom</a> <i>(from the <a class="extiw" href="https://en.wikipedia.org/wiki/Wayback_Machine" title="wikipedia:Wayback Machine">Wayback Machine</a>; retrieved on 31 October 2011)</i>, an adventure game in 2 megabytes of BF code generated with <a href="/wiki/BFBASIC" title="BFBASIC">BFBASIC</a>. | |
| <ul><li>The above <a class="external text" href="https://rdebath.github.io/LostKingdom/" rel="nofollow">converted to Javascript</a>.</li></ul></li> | |
| <li><a class="external text" href="https://www.cs.cmu.edu/~dst/DeCSS/Gallery/css-brainfuck.txt" rel="nofollow">Brainfuck CSS descrambler</a> (with comments), from the <a class="external text" href="https://www.cs.cmu.edu/~dst/DeCSS/Gallery/" rel="nofollow">Gallery of CSS Descramblers</a>.</li> | |
| <li><a class="external text" href="https://github.com/graue/esofiles/tree/master/brainfuck/" rel="nofollow">Brainfuck</a> in <a href="/wiki/The_Esoteric_File_Archive" title="The Esoteric File Archive">the Esoteric File Archive</a>, including <a class="external text" href="https://github.com/graue/esofiles/tree/master/brainfuck/impl/" rel="nofollow">implementations</a>, <a class="external text" href="https://github.com/graue/esofiles/tree/master/brainfuck/src/" rel="nofollow">programs</a> and <a class="external text" href="https://github.com/graue/esofiles/tree/master/brainfuck/util/" rel="nofollow">utilities</a>.</li> | |
| <li><a class="external text" href="http://www.49-6-dev.net/takingovertheworlden.htm" rel="nofollow">Taking-</a> and <a class="external text" href="http://www.49-6-dev.net/ftotwen.htm" rel="nofollow">Finally Taking Over The World</a> are games written by hand in brainfuck.</li> | |
| <li><a class="external text" href="https://sange.fi/esoteric/ENSI/bf-implementors-epistle.html" rel="nofollow">The Epistle to the Implementors</a></li> | |
| <li><a class="external text" href="https://esosc.mroman.ch/ESOSC-2014-A2.TXT" rel="nofollow">ESOSC-2014-A2: Normalized Brainfuck</a></li> | |
| <li><a class="external text" href="https://github.com/syncsynchalt/mutato" rel="nofollow">Mutato</a> is a mashup of Core War, brainfuck, and genetic algorithms.</li> | |
| <li><a class="external text" href="https://www.luogu.com/article/kktpcrrc" rel="nofollow">Introduction of this language in Chinese</a></li> | |
| <li><i>(<a href="/wiki/Template:Deadlink" title="Template:Deadlink">dead link</a>)</i> Urban Müller's talk about Brainfuck at Tamedia TX 2017 <a class="external text" href="https://youtu.be/gjm9irBs96U?t=8722" rel="nofollow">YouTube (video)</a></li> | |
| <li><a class="external text" href="https://github.com/mitxela/bf-tic-tac-toe" rel="nofollow">Tic Tac Toe AI in Brainfuck by mitxela</a>, with <a class="external text" href="https://www.youtube.com/watch?v=qK0vmuQib8Y" rel="nofollow">explanation video</a></li> | |
| <li><a class="external text" href="https://www.linusakesson.net/programming/brainfuck/index.php" rel="nofollow">Conway's Game of Life implemented in Brainfuck by Linus Åkesson</a></li></ul> | |
| <h3><span class="mw-headline" id="Notable_implementations">Notable implementations</span></h3> | |
| <p>For a longer list, see <a href="/wiki/Brainfuck_implementations" title="Brainfuck implementations">brainfuck implementations</a>. | |
| </p> | |
| <ul><li><a class="external text" href="https://aminet.net/package/dev/lang/brainfuck-2" rel="nofollow">Original distribution by Urban Müller</a> from the <a class="external text" href="https://aminet.net/" rel="nofollow">Aminet</a> archive. Includes interpreter and compiler for the Amiga. The interpreter can be compiled with <a class="external text" href="https://gcc.gnu.org/" rel="nofollow">gcc</a> by removing line 43, which says <i>chkabort();</i>. The associated readme file might also have some historical interest.</li> | |
| <li><a class="external text" href="https://github.com/matslina/awib" rel="nofollow">Also Written In Brainfuck (Awib)</a> is an optimizing brainfuck compiler written in brainfuck, generates various conversions including i386 executable code for Linux.</li> | |
| <li><a class="external text" href="https://github.com/lifthrasiir/esotope-bfc" rel="nofollow">Esotope Brainfuck compiler</a> is an optimizing Brainfuck-to-C compiler written in Python, with well optimised code.</li> | |
| <li><a class="external text" href="https://vanheusden.com/compilers/brainfuck/" rel="nofollow">Brainfuck</a> compiler/translator to COBOL, C, x86, mips, arm, 6502, ada, bash, c#, go, hlasm, lua, java, js, pascal, PDP-11 asm, perl 5/6, pl/1, php, python, ruby, rust, scala, z80</li></ul> | |
| <h4><span class="mw-headline" id="Compilers">Compilers</span></h4> | |
| <ul><li><a class="external text" href="https://github.com/tomhea/flip-jump" rel="nofollow">bf2fj</a> a compiler from brainfuck to <a href="/wiki/FlipJump" title="FlipJump">FlipJump</a>.</li> | |
| <li><a class="external text" href="https://github.com/none-None1/BrainFExec" rel="nofollow">BrainFExec</a> a compiler from brainfuck to Windows executable in C#</li> | |
| <li><a class="external text" href="https://github.com/aartaka/sade" rel="nofollow">Sade</a> a compiler from brainfuck to Lisp and to native executables.</li> | |
| <li><a class="external text" href="https://github.com/Wilfred/bfc" rel="nofollow">Wilfred bfc</a> is a compiler written in <a class="new" href="/w/index.php?title=Rust&action=edit&redlink=1" title="Rust (page does not exist)">Rust</a> using LLVM</li> | |
| <li><a class="external text" href="https://github.com/Muxutruk2/bfc" rel="nofollow">Muxutruk2 bfc</a> is a worse compiler written in Rust to x86_64</li></ul> | |
| <h4><span class="mw-headline" id="Interpreters_in_plain_C">Interpreters in plain C</span></h4> | |
| <ul><li><a class="external text" href="http://sree.kotay.com/2013/02/implementing-brainfuck.html" rel="nofollow">bffsree</a> is a optimizing interpreter that claims to be fastest in class. (No source code)</li> | |
| <li><a href="/wiki/Brainfucker%2B%2B" title="Brainfucker++">Brainfucker++</a> A great project!</li> | |
| <li><a class="external text" href="https://gist.github.com/lifthrasiir/596667" rel="nofollow">160-byte implementation for x86 Linux</a></li> | |
| <li><a class="external text" href="https://github.com/aartaka/reb" rel="nofollow">Reb</a>, a Brainfuck toolkit and interpreter with the goal of using regex as much as possible.</li> | |
| <li>Optimizing BF interpreter, a fast C interpreter. <a class="external text" href="https://web.archive.org/web/20230719142919/https://mazonka.com/brainf/" rel="nofollow">Archived</a> (archive.org). Last updated: 2011.</li></ul> | |
| <h4><span id="Interpreters_in_C.2B.2B"></span><span class="mw-headline" id="Interpreters_in_C++">Interpreters in C++</span></h4> | |
| <ul><li><a class="external text" href="https://github.com/JohnCGriffin/BrainForked/" rel="nofollow">BrainForked</a> is a fast non-JIT interpreter in C++.</li> | |
| <li><a class="external text" href="http://www.luogu.com.cn/blog/tiger2005/bf-bian-yi-qi" rel="nofollow">An interpreter</a> written by Chinese users. It can visualize code, but unfortunately it can't handle undefined characters.</li> | |
| <li><a href="/wiki/Brainfuck_C%2B%2B_interpreter" title="Brainfuck C++ interpreter">A simple, optimizing interpreter</a> in C++ by <a href="/wiki/User:None1" title="User:None1">User:None1</a>.</li></ul> | |
| <h4><span class="mw-headline" id="JIT_Interpreters">JIT Interpreters</span></h4> | |
| <p>These interpreters are primarily characterized by their underlying JIT toolkits; if the toolkit is good, then it will tend to produce good JITs. The fastest interpreters use <a class="new" href="/w/index.php?title=RPython&action=edit&redlink=1" title="RPython (page does not exist)">RPython</a> or <a class="extiw" href="https://en.wikipedia.org/wiki/GNU_lightning" title="wikipedia:GNU lightning">GNU Lightning</a>, which are designed for throughput when interpreting dynamic languages, followed by interpreters using <a class="external text" href="https://llvm.org/" rel="nofollow">LLVM</a> or <a class="external text" href="https://gcc.gnu.org/onlinedocs/jit/" rel="nofollow">libgccjit</a>, which take advantage of their large libraries of idioms. There are also interpreters with hand-written JIT backends, which often can outperform LLVM or libgccjit but have trouble matching . In rough order of performance, maintained JIT interpreters include: | |
| </p> | |
| <ul><li><a class="external text" href="http://lvogel.free.fr/bf.html" rel="nofollow">bf-li</a> uses GNU Lightning</li> | |
| <li><a class="external text" href="https://github.com/rpypkgs/rpypkgs" rel="nofollow">rpypkgs</a> includes <a class="external text" href="https://github.com/rpypkgs/rpypkgs/blob/main/bf/bf.py" rel="nofollow">an interpreter</a> written in RPython</li> | |
| <li><a class="external text" href="https://github.com/rdebath/Brainfuck/tree/master/tritium" rel="nofollow">Tritium</a> has several backends, including GNU Lightning</li> | |
| <li><a class="external text" href="https://savannah.nongnu.org/projects/libbf" rel="nofollow">libbf</a> has hand-written JIT</li> | |
| <li><a class="external text" href="https://github.com/none-None1/jitbf" rel="nofollow">jitbf</a> is a JIT interpreter in Python using LLVM</li></ul> | |
| <h4><span class="mw-headline" id="Hardware_implementations">Hardware implementations</span></h4> | |
| <ul><li><a class="external text" href="http://grapsus.net/74/" rel="nofollow">Brainfuck on 74 series logic IC's </a></li> | |
| <li><a class="external text" href="https://hackaday.io/project/18599-brainfuckpc-relay-computer" rel="nofollow">BrainfuckPC Relay Computer</a></li> | |
| <li><a class="external text" href="https://people.csail.mit.edu/wjun/papers/sigtbd16.pdf" rel="nofollow">50,000,000,000 Instructions Per Second: Design and Implementation of a 256-Core BrainFuck Computer</a></li> | |
| <li>The Brainf*ck CPU Project is a VHDL implementation of a brainfuck CPU: <a class="external text" href="https://web.archive.org/web/20211002125602/http://www.clifford.at/bfcpu/" rel="nofollow">www.clifford.at: The Brainf*ck CPU</a> <i>(from the <a class="extiw" href="https://en.wikipedia.org/wiki/Wayback_Machine" title="wikipedia:Wayback Machine">Wayback Machine</a>; retrieved on 2 October 2021)</i></li></ul> | |
| <h4><span class="mw-headline" id="Libraries">Libraries</span></h4> | |
| <ul><li><a class="external text" href="https://github.com/erwijet/BrainF.Net" rel="nofollow">BrainF.Net</a> is a .NET wrapper by <a class="new" href="/w/index.php?title=Erwijet&action=edit&redlink=1" title="Erwijet (page does not exist)">Erwijet</a> for executing brainfuck code.</li></ul> | |
| <h4><span class="mw-headline" id="JavaScript_interpreters">JavaScript interpreters</span></h4> | |
| <ul><li><a class="external text" href="https://zedlx.com/OokBF/ookbf-interpreter" rel="nofollow">OokBF</a>, an online interpreter with a debugger, also includes a cross-platform Runtime Environment for brainf**k.</li> | |
| <li><a class="external text" href="https://infinitedonuts.github.io/esolang-playground/" rel="nofollow">A brainf**k interpreter in JavaScript</a> <i>(<a href="/wiki/Template:Deadlink" title="Template:Deadlink">dead link</a>)</i></li> | |
| <li><a href="/wiki/Brainfuck_JavaScript_interpreter" title="Brainfuck JavaScript interpreter">An interpreter</a> in JavaScript by <a href="/wiki/User:None1" title="User:None1">User:None1</a>.</li> | |
| <li>The very golfed 250 bytes 3-cell BF interpreter by <a href="/wiki/User:Cleverxia" title="User:Cleverxia">User:Cleverxia</a>: | |
| <ul><li>This returns a lambda function, argument is the code.</li></ul></li></ul> | |
| <pre class="rectwrap">r=>{s=f=u=t=[];for(i of x){++u;if(i=='[')s.push(t);else if(i==']')f[f[u]=s.pop()]=u;}N=[0n,0n,0n];for(a=0;t<u;++t)switch(r[t]){case'+':N[a]+=2n;case'-':N[a--]--;case'>':a+=2;case'<':a=(a+2)%3;break;case'[':t=N[a]?t:f[t];break;case']':t=N[a]?f[t]:t;}}</pre> | |
| <h4><span class="mw-headline" id="Rust_interpreter">Rust interpreter</span></h4> | |
| <ul><li><a class="external text" href="https://github.com/Jomy10/Brainfuck-rs/" rel="nofollow">Brainfuck-rs</a></li></ul> | |
| <h4><span class="mw-headline" id="Docker_runtime">Docker runtime</span></h4> | |
| <ul><li><a class="external text" href="https://github.com/MarcinKonowalczyk/runbf" rel="nofollow">runbf</a>: <a class="external text" href="https://github.com/containerd/containerd/blob/main/core/runtime/v2/README.md" rel="nofollow">Containerd v2 runtime shim</a> for running bare brainfuck containers in docker/kubernates. Also includes a golang interpreter.</li></ul> | |
| <h4><span class="mw-headline" id="Python_interpreters">Python interpreters</span></h4> | |
| <ul><li><a class="external text" href="https://github.com/itruffat/ONABOBFE4P_BrainFck_Emulators" rel="nofollow">Oh No, Another Bunch of BrainF*ck Emulators</a>: a library to specify your own brainf*ck interpeter in Python. (customize rollback, max integer, etc.) <a href="/wiki/ONABOBFE4P" title="ONABOBFE4P">[esolang page]</a></li> | |
| <li><a class="external text" href="https://github.com/none-None1/bf-vis" rel="nofollow">A brainfuck visualizer</a> in Python created by <a href="/wiki/User:None1" title="User:None1">User:None1</a>. <a class="external text" href="https://github.com/none-None1/bf-vis/releases/download/1.1.0/brainfuck-visualizer.exe" rel="nofollow">as Windows executable (64bit)</a></li> | |
| <li><a href="/wiki/Brainfuck_Python_interpreter" title="Brainfuck Python interpreter">brainfuck Python interpreter</a> by <a href="/wiki/User:None1" title="User:None1">User:None1</a></li></ul> | |
| <ul><li><a href="/wiki/Pyline#Brainfuck_interpreter" title="Pyline">Pyline#Brainfuck interpreter</a> Some Brainfuck interpreters,the shortest one is only 277 characters.</li></ul> | |
| <h4><span class="mw-headline" id="Dart_interpreters">Dart interpreters</span></h4> | |
| <ul><li><a class="external text" href="https://github.com/gus-caribe/bfck" rel="nofollow">bfck</a>: A Dart command-line interpreter for brainfuck esolang (by <a href="/wiki/User:Gus-caribe" title="User:Gus-caribe">User:Gus-caribe</a>).</li> | |
| <li><a class="external text" href="https://github.com/ernestoittig/dartfuck" rel="nofollow">dartfuck</a>: A Dart implementation of Brainfuck.</li> | |
| <li><a class="external text" href="https://github.com/renatoathaydes/dart-bf" rel="nofollow">dart-bf</a>: brainfuck implementation in Dart.</li></ul> | |
| <h4><span class="mw-headline" id="Batchfile_interpreters">Batchfile interpreters</span></h4> | |
| <ul><li><a class="external text" href="https://github.com/yyny/Brainfuck-In-Batch/blob/master/interpreter.bat" rel="nofollow">ynyy's interpreter</a></li> | |
| <li><a class="external text" href="https://gist.github.com/tnhung2011/f3ab20154b21c36fe878a47c13d68dab" rel="nofollow">Another interpreter</a> by <a href="/wiki/User:HungKhanh0106" title="User:HungKhanh0106">User:HungKhanh0106</a> (faster than yyny's)</li></ul> | |
| <h4><span class="mw-headline" id="Powershell_interpreters">Powershell interpreters</span></h4> | |
| <ul><li><a href="/wiki/Brainfuck_Powershell_interpreter" title="Brainfuck Powershell interpreter">An interpreter</a> by <a href="/wiki/User:None1" title="User:None1">User:None1</a>.</li></ul> | |
| <h4><span class="mw-headline" id="Haskell_interpreters">Haskell interpreters</span></h4> | |
| <ul><li><a class="external text" href="https://gitlab.com/Hakerh400/haskell-projects/-/blob/master/bf/Main.hs?ref_type=heads" rel="nofollow">Interpreter</a> written by <a href="/wiki/User:Hakerh400" title="User:Hakerh400">User:Hakerh400</a></li></ul> | |
| <h4><span class="mw-headline" id="Interpreters_in_other_esolangs">Interpreters in other esolangs</span></h4> | |
| <p>See <a href="/wiki/Brainfuck/Esointerpreters" title="Brainfuck/Esointerpreters">Brainfuck/Esointerpreters</a>. | |
| </p> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20260117015227 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.099 seconds | |
| Real time usage: 0.249 seconds | |
| Preprocessor visited node count: 583/1000000 | |
| Post‐expand include size: 5330/2097152 bytes | |
| Template argument size: 2023/2097152 bytes | |
| Highest expansion depth: 7/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 292/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 7.659 1 -total | |
| 24.82% 1.901 1 Template:Infobox_proglang | |
| 24.64% 1.887 6 Template:Wayback | |
| 18.58% 1.423 1 Template:Lowercase | |
| 14.19% 1.087 1 Template:Distinguish/Confusion | |
| 6.49% 0.497 1 Template:Featured_language | |
| 5.52% 0.423 2 Template:Deadlink | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:961-0!canonical and timestamp 20260117015231 and revision id 173481. Rendering was triggered because: edit-page | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p>The article <a href="/wiki/Brainfuck_derivatives_with_nontrivial_computational_class_proofs" title="Brainfuck derivatives with nontrivial computational class proofs">Brainfuck derivatives with nontrivial computational class proofs</a> mentioned <i>Permanent Brainfuck</i>, a variation of <a href="/wiki/Brainfuck" title="Brainfuck">brainfuck</a> without the '-' instruction (and with unbounded cells). I (<a href="/wiki/User:Keymaker" title="User:Keymaker">Keymaker</a>) thought that ordinary brainfuck ought to be Turing-complete without '-' even with the ordinary cells -- and this is what I will show here, with the addition of making the system <i>only</i> use memory values 0 and 1: '+' never happens twice in the same cell. | |
| </p><p>So, this is not a brainfuck derivative, this is merely a way for programming brainfuck without using '-'. | |
| </p><p>Here is a translator in Python for translating <a href="/wiki/Sequential_tag_system" title="Sequential tag system">Sequential tag system</a> (and <a href="/wiki/Cyclic_tag_system" title="Cyclic tag system">Cyclic tag system</a>, this works for both) to brainfuck code that obeys the restrictions mentioned above. Use only programs that do not halt. | |
| </p> | |
| <pre>m = "1" # initial memory string | |
| p = "011;10;101;" # program string | |
| s = ">>> " | |
| for x in m: | |
| s = s + "+>>" | |
| if x == "1": | |
| s = s + "+" | |
| s = s + "> " | |
| s = s + "<<<[<<<]>>>" | |
| print(s) | |
| print("[") | |
| for x in p: | |
| if x == ";": | |
| print(" >[>>>]+<[<<<]>>>") | |
| elif x == "0": | |
| print(" >[>>>]>[>[>>>]+>>]<<[<<<]>>>") | |
| elif x == "1": | |
| print(" >[>>>]>[>[>>>]+>>+>>>]<<<<<[<<<]>>>") | |
| print("]") | |
| </pre> | |
| <p>Running the program above, loaded with the initial memory string "1" and the program string "011;10;101;", produces the following brainfuck program: | |
| </p> | |
| <pre>>>> +>>+> <<<[<<<]>>> | |
| [ | |
| >[>>>]>[>[>>>]+>>]<<[<<<]>>> | |
| >[>>>]>[>[>>>]+>>+>>>]<<<<<[<<<]>>> | |
| >[>>>]>[>[>>>]+>>+>>>]<<<<<[<<<]>>> | |
| >[>>>]+<[<<<]>>> | |
| >[>>>]>[>[>>>]+>>+>>>]<<<<<[<<<]>>> | |
| >[>>>]>[>[>>>]+>>]<<[<<<]>>> | |
| >[>>>]+<[<<<]>>> | |
| >[>>>]>[>[>>>]+>>+>>>]<<<<<[<<<]>>> | |
| >[>>>]>[>[>>>]+>>]<<[<<<]>>> | |
| >[>>>]>[>[>>>]+>>+>>>]<<<<<[<<<]>>> | |
| >[>>>]+<[<<<]>>> | |
| ] | |
| </pre> | |
| <p>By adding a debug character (assuming the brainfuck implementation has one) at the end of each instruction's simulation, one can observe the simulated memory string. For example like this: | |
| </p> | |
| <pre> >[>>>]>[>[>>>]+>>]<<[<<<]>>> ? | |
| </pre> | |
| <p>The '?' was placed at the end of the first instruction ('0'). It makes sense to add it to them all (or modify the translator to do the work automatically). | |
| </p><p>So, how to interpret state of the brainfuck memory? Running the above program, this state happens eventually: | |
| </p> | |
| <pre>000111110111111101100101100101101101000... | |
| </pre> | |
| <p>Split it in groups of three digits, like this: | |
| </p> | |
| <pre>000 111 110 111 111 101 100 101 100 101 101 101 000 ... | |
| </pre> | |
| <p>The simulated memory string uses three brainfuck cells per one digit. | |
| </p> | |
| <pre>000 xuv xuv xuv 000 ... | |
| </pre> | |
| <p>The first three cells are kept zero. Then follows the simulated string: | |
| </p> | |
| <ul><li>x - marks the existence of a digit, always 1 (in case there is a digit)</li> | |
| <li>u - marks whether the digit is in use/exists as part of the memory string. 0 means it is there, 1 means it has been erased by the ';' instruction</li> | |
| <li>v - marks the value of the digit - 0 or 1</li></ul> | |
| <p>After the string the memory continues as nothing but zeroes -- as it does in brainfuck. | |
| </p><p>Reading the string of our example: | |
| </p> | |
| <ul><li>000 - zeroes before the actual string</li> | |
| <li>111 - the first piece of actual string data. Since the 'u' cell is 1, it means this 1-digit has been removed from the simulation by the ';' instruction</li> | |
| <li>110 - likewise, this 0-digit has been removed from the string by ';'</li> | |
| <li>111 - removed 1-digit</li> | |
| <li>111 - removed 1-digit</li> | |
| <li><b>101</b> - notice the 'u' cell is 0. This is the first actual digit (1, the 'v' being 1) in the simulated memory string.</li> | |
| <li>100 - second digit. 'u' will be 0 till the end of the string from its first occurrence. This digit is 0</li> | |
| <li>101 - 1</li> | |
| <li>100 - 0</li> | |
| <li>101 - 1</li> | |
| <li>101 - 1</li> | |
| <li>101 - the last digit in the string</li> | |
| <li>000 - the string has ended. The 'x' cell is 0; there is no more string data.</li></ul> | |
| <p>That's it. This shows that brainfuck is Turing-complete without '-', even with the cell range of 0-1. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#What_about_Hao_Wang's_B-machine?"><span class="tocnumber">1</span> <span class="toctext">What about Hao Wang's B-machine?</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Depth_two_nesting"><span class="tocnumber">2</span> <span class="toctext">Depth two nesting</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-3"><a href="#Command_substitutions"><span class="tocnumber">2.1</span> <span class="toctext">Command substitutions</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-4"><a href="#See_also"><span class="tocnumber">3</span> <span class="toctext">See also</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span id="What_about_Hao_Wang.27s_B-machine.3F"></span><span class="mw-headline" id="What_about_Hao_Wang's_B-machine?">What about Hao Wang's B-machine?</span></h2> | |
| <p>Seeing the above, one might think that it might be easy to translate to Hao Wang's B-machine (see <a href="/wiki/Wang_program" title="Wang program">Wang program</a>). After all, B-machine has a tape, instructions for left and right, instruction to mark the tape, and a conditional jump if the current cell/tape-square is marked. Below is a translator in Python that one may use to translate brainfuck programs that use cell range 0-1 and no '-' and '+' only once per cell, to B-machine, the output represented as a collection of ordered pairs. | |
| </p> | |
| <pre>import sys | |
| if len(sys.argv) < 2: | |
| print("Error, need an input file.") | |
| sys.exit() | |
| try: | |
| f = open(sys.argv[1]) | |
| except IOError: | |
| print("Error in reading the file.") | |
| sys.exit() | |
| a = f.read() | |
| f.close() | |
| p = "" | |
| for x in a: | |
| if x == "+" or x == "<" or x == ">" or x == "[" or x == "]": | |
| p = p + x | |
| s = [] | |
| i = [] | |
| x = 0 | |
| while x < len(p): | |
| if p[x] == "+": | |
| i.append("*") | |
| elif p[x] == ">": | |
| i.append("->") | |
| i.append("->") | |
| elif p[x] == "<": | |
| i.append("<-") | |
| i.append("<-") | |
| elif p[x] == "[": | |
| s.append(len(i) - 1) | |
| i.append("N" + str(len(i) + 6)) | |
| i.append("->"); | |
| i.append("?") | |
| i.append("*") | |
| i.append("?") | |
| elif p[x] == "]": | |
| q = s.pop() | |
| n = len(i) - 1 | |
| i.append("N" + str(q + 7)) | |
| i.append("->") | |
| i.append("<-") | |
| i[q + 3] = "N" + str(n + 4) | |
| i[q + 5] = "N" + str(n + 4) | |
| x = x + 1 | |
| o = "{" | |
| x = 0 | |
| while x < len(i): | |
| o = o + "(" + str(x + 1) + "," + i[x]+ ")" | |
| x = x + 1 | |
| print(o + "}") | |
| </pre> | |
| <p>Since I was unable to find out whether B-machine allows 'over-writing' an already marked cell, my translation might have unnecessary complexity because when it needs to mark the tape it first checks if the tape is already marked and does a jump over the operation if it is. | |
| </p><p>All the STS/CTS-to-brainfuck translations made with the method above can be translated to B-machine with the above program. Here is the example program in B-machine: | |
| </p> | |
| <pre>{(1,->)(2,->)(3,->)(4,->)(5,->)(6,->)(7,*)(8,->)(9,->)(10,->)(11,->)(12,*)(13,->)(14,->)(15,<-)(16,<-)(17,<-)(18,<-)(19,<-)(20,<-)(21,N26)(22,->)(23,N34)(24,*)(25,N34)(26,<-)(27,<-)(28,<-)(29,<-)(30,<-)(31,<-)(32,N26)(33,->)(34,<-)(35,->)(36,->)(37,->)(38,->)(39,->)(40,->)(41,N46)(42,->)(43,N798)(44,*)(45,N798)(46,->)(47,->)(48,N53)(49,->)(50,N61)(51,*)(52,N61)(53,->)(54,->)(55,->)(56,->)(57,->)(58,->)(59,N53)(60,->)(61,<-)(62,->)(63,->)(64,N69)(65,->)(66,N92)(67,*)(68,N92)(69,->)(70,->)(71,N76)(72,->)(73,N84)(74,*)(75,N84)(76,->)(77,->)(78,->)(79,->)(80,->)(81,->)(82,N76)(83,->)(84,<-)(85,*)(86,->)(87,->)(88,->)(89,->)(90,N69)(91,->)(92,<-)(93,<-)(94,<-)(95,<-)(96,<-)(97,N102)(98,->)(99,N110)(100,*)(101,N110)(102,<-)(103,<-)(104,<-)(105,<-)(106,<-)(107,<-)(108,N102)(109,->)(110,<-)(111,->)(112,->)(113,->)(114,->)(115,->)(116,->)(117,->)(118,->)(119,N124)(120,->)(121,N132)(122,*)(123,N132)(124,->)(125,->)(126,->)(127,->)(128,->)(129,->)(130,N124)(131,->)(132,<-)(133,->)(134,->)(135,N140)(136,->)(137,N170)(138,*)(139,N170)(140,->)(141,->)(142,N147)(143,->)(144,N155)(145,*)(146,N155)(147,->)(148,->)(149,->)(150,->)(151,->)(152,->)(153,N147)(154,->)(155,<-)(156,*)(157,->)(158,->)(159,->)(160,->)(161,*)(162,->)(163,->)(164,->)(165,->)(166,->)(167,->)(168,N140)(169,->)(170,<-)(171,<-)(172,<-)(173,<-)(174,<-)(175,<-)(176,<-)(177,<-)(178,<-)(179,<-)(180,<-)(181,N186)(182,->)(183,N194)(184,*)(185,N194)(186,<-)(187,<-)(188,<-)(189,<-)(190,<-)(191,<-)(192,N186)(193,->)(194,<-)(195,->)(196,->)(197,->)(198,->)(199,->)(200,->)(201,->)(202,->)(203,N208)(204,->)(205,N216)(206,*)(207,N216)(208,->)(209,->)(210,->)(211,->)(212,->)(213,->)(214,N208)(215,->)(216,<-)(217,->)(218,->)(219,N224)(220,->)(221,N254)(222,*)(223,N254)(224,->)(225,->)(226,N231)(227,->)(228,N239)(229,*)(230,N239)(231,->)(232,->)(233,->)(234,->)(235,->)(236,->)(237,N231)(238,->)(239,<-)(240,*)(241,->)(242,->)(243,->)(244,->)(245,*)(246,->)(247,->)(248,->)(249,->)(250,->)(251,->)(252,N224)(253,->)(254,<-)(255,<-)(256,<-)(257,<-)(258,<-)(259,<-)(260,<-)(261,<-)(262,<-)(263,<-)(264,<-)(265,N270)(266,->)(267,N278)(268,*)(269,N278)(270,<-)(271,<-)(272,<-)(273,<-)(274,<-)(275,<-)(276,N270)(277,->)(278,<-)(279,->)(280,->)(281,->)(282,->)(283,->)(284,->)(285,->)(286,->)(287,N292)(288,->)(289,N300)(290,*)(291,N300)(292,->)(293,->)(294,->)(295,->)(296,->)(297,->)(298,N292)(299,->)(300,<-)(301,*)(302,<-)(303,<-)(304,N309)(305,->)(306,N317)(307,*)(308,N317)(309,<-)(310,<-)(311,<-)(312,<-)(313,<-)(314,<-)(315,N309)(316,->)(317,<-)(318,->)(319,->)(320,->)(321,->)(322,->)(323,->)(324,->)(325,->)(326,N331)(327,->)(328,N339)(329,*)(330,N339)(331,->)(332,->)(333,->)(334,->)(335,->)(336,->)(337,N331)(338,->)(339,<-)(340,->)(341,->)(342,N347)(343,->)(344,N377)(345,*)(346,N377)(347,->)(348,->)(349,N354)(350,->)(351,N362)(352,*)(353,N362)(354,->)(355,->)(356,->)(357,->)(358,->)(359,->)(360,N354)(361,->)(362,<-)(363,*)(364,->)(365,->)(366,->)(367,->)(368,*)(369,->)(370,->)(371,->)(372,->)(373,->)(374,->)(375,N347)(376,->)(377,<-)(378,<-)(379,<-)(380,<-)(381,<-)(382,<-)(383,<-)(384,<-)(385,<-)(386,<-)(387,<-)(388,N393)(389,->)(390,N401)(391,*)(392,N401)(393,<-)(394,<-)(395,<-)(396,<-)(397,<-)(398,<-)(399,N393)(400,->)(401,<-)(402,->)(403,->)(404,->)(405,->)(406,->)(407,->)(408,->)(409,->)(410,N415)(411,->)(412,N423)(413,*)(414,N423)(415,->)(416,->)(417,->)(418,->)(419,->)(420,->)(421,N415)(422,->)(423,<-)(424,->)(425,->)(426,N431)(427,->)(428,N454)(429,*)(430,N454)(431,->)(432,->)(433,N438)(434,->)(435,N446)(436,*)(437,N446)(438,->)(439,->)(440,->)(441,->)(442,->)(443,->)(444,N438)(445,->)(446,<-)(447,*)(448,->)(449,->)(450,->)(451,->)(452,N431)(453,->)(454,<-)(455,<-)(456,<-)(457,<-)(458,<-)(459,N464)(460,->)(461,N472)(462,*)(463,N472)(464,<-)(465,<-)(466,<-)(467,<-)(468,<-)(469,<-)(470,N464)(471,->)(472,<-)(473,->)(474,->)(475,->)(476,->)(477,->)(478,->)(479,->)(480,->)(481,N486)(482,->)(483,N494)(484,*)(485,N494)(486,->)(487,->)(488,->)(489,->)(490,->)(491,->)(492,N486)(493,->)(494,<-)(495,*)(496,<-)(497,<-)(498,N503)(499,->)(500,N511)(501,*)(502,N511)(503,<-)(504,<-)(505,<-)(506,<-)(507,<-)(508,<-)(509,N503)(510,->)(511,<-)(512,->)(513,->)(514,->)(515,->)(516,->)(517,->)(518,->)(519,->)(520,N525)(521,->)(522,N533)(523,*)(524,N533)(525,->)(526,->)(527,->)(528,->)(529,->)(530,->)(531,N525)(532,->)(533,<-)(534,->)(535,->)(536,N541)(537,->)(538,N571)(539,*)(540,N571)(541,->)(542,->)(543,N548)(544,->)(545,N556)(546,*)(547,N556)(548,->)(549,->)(550,->)(551,->)(552,->)(553,->)(554,N548)(555,->)(556,<-)(557,*)(558,->)(559,->)(560,->)(561,->)(562,*)(563,->)(564,->)(565,->)(566,->)(567,->)(568,->)(569,N541)(570,->)(571,<-)(572,<-)(573,<-)(574,<-)(575,<-)(576,<-)(577,<-)(578,<-)(579,<-)(580,<-)(581,<-)(582,N587)(583,->)(584,N595)(585,*)(586,N595)(587,<-)(588,<-)(589,<-)(590,<-)(591,<-)(592,<-)(593,N587)(594,->)(595,<-)(596,->)(597,->)(598,->)(599,->)(600,->)(601,->)(602,->)(603,->)(604,N609)(605,->)(606,N617)(607,*)(608,N617)(609,->)(610,->)(611,->)(612,->)(613,->)(614,->)(615,N609)(616,->)(617,<-)(618,->)(619,->)(620,N625)(621,->)(622,N648)(623,*)(624,N648)(625,->)(626,->)(627,N632)(628,->)(629,N640)(630,*)(631,N640)(632,->)(633,->)(634,->)(635,->)(636,->)(637,->)(638,N632)(639,->)(640,<-)(641,*)(642,->)(643,->)(644,->)(645,->)(646,N625)(647,->)(648,<-)(649,<-)(650,<-)(651,<-)(652,<-)(653,N658)(654,->)(655,N666)(656,*)(657,N666)(658,<-)(659,<-)(660,<-)(661,<-)(662,<-)(663,<-)(664,N658)(665,->)(666,<-)(667,->)(668,->)(669,->)(670,->)(671,->)(672,->)(673,->)(674,->)(675,N680)(676,->)(677,N688)(678,*)(679,N688)(680,->)(681,->)(682,->)(683,->)(684,->)(685,->)(686,N680)(687,->)(688,<-)(689,->)(690,->)(691,N696)(692,->)(693,N726)(694,*)(695,N726)(696,->)(697,->)(698,N703)(699,->)(700,N711)(701,*)(702,N711)(703,->)(704,->)(705,->)(706,->)(707,->)(708,->)(709,N703)(710,->)(711,<-)(712,*)(713,->)(714,->)(715,->)(716,->)(717,*)(718,->)(719,->)(720,->)(721,->)(722,->)(723,->)(724,N696)(725,->)(726,<-)(727,<-)(728,<-)(729,<-)(730,<-)(731,<-)(732,<-)(733,<-)(734,<-)(735,<-)(736,<-)(737,N742)(738,->)(739,N750)(740,*)(741,N750)(742,<-)(743,<-)(744,<-)(745,<-)(746,<-)(747,<-)(748,N742)(749,->)(750,<-)(751,->)(752,->)(753,->)(754,->)(755,->)(756,->)(757,->)(758,->)(759,N764)(760,->)(761,N772)(762,*)(763,N772)(764,->)(765,->)(766,->)(767,->)(768,->)(769,->)(770,N764)(771,->)(772,<-)(773,*)(774,<-)(775,<-)(776,N781)(777,->)(778,N789)(779,*)(780,N789)(781,<-)(782,<-)(783,<-)(784,<-)(785,<-)(786,<-)(787,N781)(788,->)(789,<-)(790,->)(791,->)(792,->)(793,->)(794,->)(795,->)(796,N46)(797,->)(798,<-)} | |
| </pre> | |
| <h2><span class="mw-headline" id="Depth_two_nesting">Depth two nesting</span></h2> | |
| <p>The following substitutions implement a Turing complete <a href="/wiki/Home_Row#One-dimensional_construction" title="Home Row">one-dimensional subset of Home Row</a>. This shows that brainfuck is Turing complete with the above restrictions as well as only two levels of loop nesting. | |
| </p><p>The five registers ("spots") of the Home Row grid row are represented as values in unary, interleaved on the tape. Each unary digit is represented in a way adapted from the above tag system representation. | |
| </p><p>The brainfuck tape splits into groups of three digits, which themselves are parts of groups of fifteen. Each group of fifteen contains one group of three for each encoded spot. | |
| </p> | |
| <pre>000 000 000 000 000 xuv xuv xuv xuv xuv ... | |
| </pre> | |
| <ul><li>x - marks whether the current spot has reached this far on the tape.</li> | |
| <li>u - marks whether the current digit has been erased (decrementing the spot).</li> | |
| <li>v - always zero, used to help navigating the tape.</li></ul> | |
| <p>Each spot's cross section of the tape (every fifth group of three) is thus of the form: | |
| </p> | |
| <pre>000 - initial zeros at left of tape | |
| (110)* - deleted unary digits | |
| (100)* - live digits | |
| (000)* - unending zeros to the right of tape | |
| </pre> | |
| <p>The number of 100 groups give the current value of the spot. | |
| To avoid corner cases in the code, all spots are initialized with one 110 group representing a pre-deleted digit. | |
| </p> | |
| <h3><span class="mw-headline" id="Command_substitutions">Command substitutions</span></h3> | |
| <p>Commands start executing at the first nonzero x (in 110) of the current spot. | |
| </p> | |
| <pre>Initialization | |
| >>> >>> >>> >>> >>> +>+>> +>+>> +>+>> +>+>> +>+< | |
| s (decrement spot, decrementing zero is undefined behavior) | |
| > [>>> >>> >>> >>> >>>] + [<<< <<< <<< <<< <<<] >>> >>> >>> >>> >> | |
| a (increment spot) | |
| [>>> >>> >>> >>> >>>] + [<<< <<< <<< <<< <<<] >>> >>> >>> >>> >>> | |
| f (move to next spot (using previous on tape)) | |
| <<< [<<< <<< <<< <<< <<<] >>> >>> >>> >>> >>> | |
| jf (move to next spot if current spot is non-zero) | |
| [>>> >>> >>> >>> >>>] <<< <<< <<< <<< << [>] < [<<< <<< <<< <<< <<<] | |
| >>> >>> >>> >>> >>> > [<] < [<<< <<< <<< <<< <<<] >>> >>> >>> >>> >> | |
| l (loop when non-zero, * is [ for odd-numbered l and ] for even-numbered l) | |
| [>>> >>> >>> >>> >>>] <<< <<< <<< <<< << [>] < [<<< <<< <<< <<< <<<] | |
| >>> >>> >>> >>> >>> > | |
| * | |
| [>] << | |
| </pre> | |
| <h2><span class="mw-headline" id="See_also">See also</span></h2> | |
| <ul><li><a href="/wiki/Brainfuck--" title="Brainfuck--">Brainfuck--</a></li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20260119170111 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.011 seconds | |
| Real time usage: 0.039 seconds | |
| Preprocessor visited node count: 19/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:10253-0!canonical and timestamp 20260119170111 and revision id 138331. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b><a class="mw-selflink selflink">Brainpocalypse</a></b> is an <a href="/wiki/Esoteric_programming_language" title="Esoteric programming language">esoteric programming language</a> created by <a href="/wiki/User:Ais523" title="User:Ais523">User:ais523</a> in <a href="/wiki/Category:2018" title="Category:2018">2018</a>, as a cross between <a href="/wiki/Brainfuck" title="Brainfuck">brainfuck</a> and <a href="/wiki/Subtractpocalypse" title="Subtractpocalypse">Subtractpocalypse</a>. The idea is to produce a language that's simpler than each of the original languages in terms of the complexity of its command set. It can also be fairly easily <a href="/wiki/BF_instruction_minimalization" title="BF instruction minimalization">minimalized</a> down to two instructions; unlike some other languages with the same property, it does not require an implicit loop around the program (i.e. the commands of the program itself handle both data manipulation and control flow). | |
| </p><p>The name "brainfuck" is written mid-sentence every time it appears in the specification (thus making it unclear how its name is capitalised at the start of a sentence, although it's lowercase if it appears mid-sentence). Brainpocalypse has the opposite issue; in its specification, the name <i>only</i> appears at the start of a sentence, thus making it unclear how it would be capitalised mid-sentence. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Data_storage"><span class="tocnumber">1</span> <span class="toctext">Data storage</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Commands_and_syntax"><span class="tocnumber">2</span> <span class="toctext">Commands and syntax</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-3"><a href="#Standard_version"><span class="tocnumber">2.1</span> <span class="toctext">Standard version</span></a></li> | |
| <li class="toclevel-2 tocsection-4"><a href="#Minimized_version"><span class="tocnumber">2.2</span> <span class="toctext">Minimized version</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-5"><a href="#Computational_class"><span class="tocnumber">3</span> <span class="toctext">Computational class</span></a></li> | |
| <li class="toclevel-1 tocsection-6"><a href="#See_also"><span class="tocnumber">4</span> <span class="toctext">See also</span></a></li> | |
| <li class="toclevel-1 tocsection-7"><a href="#External_Resources"><span class="tocnumber">5</span> <span class="toctext">External Resources</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Data_storage">Data storage</span></h2> | |
| <p>Like brainfuck, data is stored in a tape of cells, each of which holds an integer that's initially 0. Brainpocalypse, however, uses only nonnegative integers in its cells (like Subtractpocalypse does with its counters); by default, the cells are unbounded (although a version of the language with bounded cells might be interesting). Because the cells are unbounded, the tape length can be bounded; the default is for the tape to be 256 cells wide and to wrap from the start to the end (just like the default for brainfuck's cells is for them to wrap between 255 and 0); again, a version of the language with a tape that's unbounded in both directions might be interesting. There is also a tape pointer, just like in brainfuck, which can point to a cell, and initially points to the "first" cell (although because the tape is either unbounded or wrapping, the decision of where to start the pointer is invisible and entirely arbitrary). | |
| </p> | |
| <h2><span class="mw-headline" id="Commands_and_syntax">Commands and syntax</span></h2> | |
| <p>Brainpocalypse's syntax is like brainfuck: each command is a single character long, and every character other than those that name commands is ignored and can be used to write comments. The commands likewise work in a similar way to brainfuck; the program starts with the first command and by default runs commands in order, halting if an attempt to execute "beyond the last command" is made, with flow control commands able to change this basic behaviour. | |
| </p> | |
| <h3><span class="mw-headline" id="Standard_version">Standard version</span></h3> | |
| <p>Brainpocalypse has four commands in its standard version: | |
| </p> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <th>Command</th> | |
| <th>Meaning | |
| </th></tr> | |
| <tr> | |
| <td><code><</code></td> | |
| <td>Move the tape pointer to the left | |
| </td></tr> | |
| <tr> | |
| <td><code>></code></td> | |
| <td>Move the tape pointer to the right | |
| </td></tr> | |
| <tr> | |
| <td><code>+</code></td> | |
| <td>Add 1 to the tape cell that the pointer is pointing to | |
| </td></tr> | |
| <tr> | |
| <td><code>-</code></td> | |
| <td>Subtract 1 from the tape cell that the pointer is pointing to, <i>if</i> it's nonzero.<br/>If the subtraction fails because the cell was zero, instead goto the start of the program (i.e. rewind the IP address to the first command in the program). | |
| </td></tr></tbody></table> | |
| <h3><span class="mw-headline" id="Minimized_version">Minimized version</span></h3> | |
| <p>When the tape is bounded, <code><</code> is unnecessary, as you can replace it with enough <code>></code> commands to wrap around to the other end of the tape. | |
| </p><p>It's also possible to merge <code>></code> and <code>+</code> into a single instruction, <code>}</code> (with the same semantics as <code>>+</code>). This command allows you to simulate <code>></code> as <code>}-</code>. Once you have <code>></code>, you can use it to implement <code><</code>, and then <code>+</code> can be written as <code><}</code>. This brings the language down to just two commands, <code>}</code> and <code>-</code>, at the expense of a rather large explosion in the code size. | |
| </p> | |
| <h2><span class="mw-headline" id="Computational_class">Computational class</span></h2> | |
| <p>Brainpocalypse is <a href="/wiki/Turing-complete" title="Turing-complete">Turing-complete</a>, given a sufficiently long tape (and it is likely but not proven that 256 cells is sufficient). This can be proven via compiling into it a version of <a href="/wiki/The_Waterfall_Model" title="The Waterfall Model">The Waterfall Model</a> in which every cell adds 5 to itself upon zeroing. (There's a Turing-completeness construction on <a href="/wiki/Talk:The_Waterfall_Model" title="Talk:The Waterfall Model">Talk:The Waterfall Model</a> which can trivially be adapted to have this property.) | |
| </p><p>The first step of the compiled program is to initialise the tape appropriately via adding the elements of the initial state to those on the tape, which can be done with <code>+</code> and <code><</code> instructions. The first, third, fifth, etc. tape elements are each initialised to 1; the second is initialised to 0, with others being initialised as explained below. Then the program moves to the second tape element (i.e. the element to the right of where it started) and does <code>-+</code>, followed by undoing the tape initialisation by subtracting the same amount from each tape element as was initially added, and moving the pointer back to its original location. The first time this sequence runs, the subtraction in this <code>-+</code> will fail and reset the program, thus initialising the tape appropriately (with the pointer on the second element). For the rest of the program, the pointer is always moved two elements at a time (i.e. we use <code><<</code> and <code>>></code> for movement and treat all the 1-valued cells as nonexistent); this means that the <code>-+</code> will always succeed (the pointer would start on an element in between the 1s, so the cell to its right – the cell where <code>-+</code> is run – would be 1-valued), so the entire initialisation sequence cancels itself out. | |
| </p><p>From now on we only focus on the tape elements in between the repeated 1s. Whenever the instruction pointer returns to the start of the program (and thus immediately after the tape is initialised), these follow a repeating pattern: | |
| </p> | |
| <ul><li>0 (usually; this is a 1 for one specific cell, the cell after the unused "waterclock" cell, which mustn't be the original second cell on the tape); or 6 if it's one of the two cells immediately before the tape pointer</li> | |
| <li>0; or 6 if it's one of the two cells immediately before the tape pointer</li> | |
| <li>an arbitrary positive number</li> | |
| <li>a cell that holds the same value as a waterclock in the original The Waterfall Model program (except that one such cell is unused)</li></ul> | |
| <p>This gives us a number of waterclocks equal to ⅛ the total number of cells on the tape minus 1 (¼ minus 1 after ignoring the 1s that appear everywhere). | |
| </p><p>The next piece of code to appear in the compiled program is <code>++++++ >> -+ << ------ << ------ >> >> >> >> -+</code>. This code effectively starts by looking for the next nonzero cell after the point at which it started running (which is probably a waterclock that's just been zeroed); this will be the positive number just before the next waterclock (or unused waterclock). Each zero cell we find when we're looking will be set to 6. When we find the arbitrary positive number, the code subtracts 6 from the two cells before the pointer (thus maintaining our invariant that whether the first two cells in the sequence of four are 0 or 6 depends on their position relative to the pointer, as the pointer's about to move away). Note that, however, that when this sequence starts with a zeroed waterclock cell, it will be set to 6 while we're looking for a nonzero cell, and (unlike the two 0-or-6 cells) not set back to 0 when we find it. | |
| </p><p>The code then jumps the tape pointer past the waterclock after the arbitrary positive cell we found, and checks to see if the cell where it ends up (the cell after the waterclock/unused waterclock we found) is nonzero. If it isn't, it'll restart, effectively repeating these steps to check the cell after each waterclock in turn (setting the maintained zeroes to 6 and back to 0 in the process). Eventually, it'll find the cell after the unused waterclock. And thus, the purpose of the code in question is that when it runs after at this point in the code, we've made no changes to the tape (except for setting a waterclock from 0 to 6 if the instruction pointer started there), but the tape pointer is now in a known position (specifically, on the 1 just after the unused waterclock). | |
| </p><p>Now that the tape pointer is in a known position, we can start talking about moving the pointer to specific cells (as for the rest of the program we always know where the pointer is) and performing specific adjustments to them (or more colloquially, adjusting specific cells). The basic idea is to apply the expected cell value adjustments for the first waterclock zeroing, then decrement it and undo the decrement, then undo those adjustments and apply the expected cell value adjustments for the second waterclock zeroing, then decrement it and undo the decrement, and so on. If any waterclock is at 0 (and thus "decreased to -1"), it'll end up getting reset to 6, and every other cell being set to 1 more than its expected value (because it should have been decremented, but with this algorithm, none of the cells are other than the waterclock that zeroed). The result thus leaves every waterclock 1 higher than in the The Waterfall Model program that's being simulated, which is a correct result (as adding 1 to the value of every waterclock in a The Waterfall Model program is a no-op). Similarly, zeroing triggers run on waterclocks being decreased <i>from</i> 0, rather than decreased <i>to</i> 0, but this likewise has no effect on the semantics of the program. | |
| </p><p>If the program hasn't restarted yet, it must be because all the waterclocks have positive values. As such, we can subtract 1 from every waterclock (thus maintaining The Waterfall Model semantics), via moving the tape pointer there and decrementing it. Finally, we just have to restart the program, which can be done by going to the original second cell (which should be 0 at this point) and attempting to decrement it. (It's possible to slightly modify this construction to add a halt state; if the unused waterclock is the second-last on the tape, but the last is also unused, then the code won't be able to observe an increment of the second cell except when the "subtract 1 from everything" effect happens. Thus, this cell can be incremented by a waterclock zeroing trigger, even though it isn't a waterclock, to serve as a signal that the program should halt.) | |
| </p> | |
| <h2><span class="mw-headline" id="See_also">See also</span></h2> | |
| <ul><li><a href="/wiki/Brainpocalypse_II" title="Brainpocalypse II">Brainpocalypse II</a></li> | |
| <li><a href="/wiki/Subtractpocalypse" title="Subtractpocalypse">Subtractpocalypse</a> and <a href="/wiki/Brainfuck" title="Brainfuck">brainfuck</a></li> | |
| <li><a href="/wiki/The_Waterfall_Model" title="The Waterfall Model">The Waterfall Model</a></li> | |
| <li><a href="/wiki/OISCalypse" title="OISCalypse">OISCalypse</a>, an <a href="/wiki/OISC" title="OISC">OISC</a> inspired by this language</li></ul> | |
| <h2><span class="mw-headline" id="External_Resources">External Resources</span></h2> | |
| <ul><li><a class="external text" href="https://tio.run/##bY/NCsIwEITveYoVA7HEVPvjqSbgRT17FQ8tjbZg06Ko@PR1kxas0kPY5JudYXJ7ZO@21c/0CoxWcp/eC9/o14w2cuklQM0A1RYxvjnstv5Np7l/uT@y2cJfzAlTDKTCiJrLwNqOtD7hjaG0HpNCJ/ExKXKSGJPihHkEewTkVZRX3WO1JABgG0N5xqnC1cqS4Y6UMaQmB1odaYMvZ7EuG4ZTm7wPQXMXs@5jsYADfU7QUfFLQ0dd@N9@9FX@PMNGk66R@669TBsUCLZqW865wiOE@AA" rel="nofollow">Interpreter (Written in Ruby)</a></li> | |
| <li><a class="external text" href="https://tio.run/##bU/RCsIwDHzvV0RE9lA3pqAvOsHvGEPKlmlh60pbGfrzM23dfLHQprm7JJfavKwT3TQ5oREKuBojXpnCEfaH4xZy1mtCc1YPjafv6GymBndTslsxGTk2PmSHQNkZvC6z8o0MwOAoVUOSVnTWA7WwGBSl1BXl4wMVJJfkBL3mxc6HTUFzF@ocqPQfxYnynsteV1S74GlCXwDZLiysvEkIZ8bSUAGA0VioiMvEZLHuzDMKUDVsfqn5LPgt5ztEI1G01k9nw0BGwDRxzi/f@wE" rel="nofollow">Alternate implementation (Written in Crystal)</a></li> | |
| <li><a class="external text" href="https://tio.run/##bZDBDoIwDIbve4olHgCXmaHxQhgn34JwQDexCYyFzRifHjdAQeVPmmzt1@5f9dPeWnXoe2h021lsngZdWiG5O@yMFaB2nSxFGCHQnCEfttSS56zYxmwQetyglhh0WksV@uYoQdgJrtjfctAF5wEJxqyXH5HrgvB4BcwWoF5H0iVCVxERJHhzkud7VYGqXKVpSiXmrg6UDQcfScyKaGUCXTziKpPnObf4yNuCl6yN/Ibc5ujH4tSRsr9t8P3x@ENlLvXPsZHyu@l7QkjmglL6Ag" rel="nofollow">Another implementation (written in Python) with a debugging command</a></li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20250724015110 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.025 seconds | |
| Real time usage: 0.026 seconds | |
| Preprocessor visited node count: 37/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:11719-0!canonical and timestamp 20250724015110 and revision id 138534. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b>Brainpocalypse II</b> is a modified version of <a href="/wiki/Brainpocalypse" title="Brainpocalypse">Brainpocalypse</a>, created by <a href="/wiki/User:Ais523" title="User:Ais523">User:ais523</a> in <a href="/wiki/Category:2023" title="Category:2023">2023</a>. Unlike Brainpocalypse, in Brainpocalypse II the position of the tape pointer is statically known at every point in the program (i.e. for every command, it is known which tape element it will act on); the intention is that this should make it easier to write compilers from Brainpocalypse II into other programming languages, in order to prove those languages <a class="mw-redirect" href="/wiki/Turing_complete" title="Turing complete">Turing complete</a>. Brainpocalypse II is otherwise very similar to its predecessor (although the "decrement" instruction needed to be tweaked slightly in order to allow the program to zero-test cells without completely forgetting what it was doing at the time). | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Data_storage"><span class="tocnumber">1</span> <span class="toctext">Data storage</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Commands_and_syntax"><span class="tocnumber">2</span> <span class="toctext">Commands and syntax</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-3"><a href="#Standard_version"><span class="tocnumber">2.1</span> <span class="toctext">Standard version</span></a></li> | |
| <li class="toclevel-2 tocsection-4"><a href="#Minimized_version"><span class="tocnumber">2.2</span> <span class="toctext">Minimized version</span></a></li> | |
| <li class="toclevel-2 tocsection-5"><a href="#Numerical_version"><span class="tocnumber">2.3</span> <span class="toctext">Numerical version</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-6"><a href="#Computational_class"><span class="tocnumber">3</span> <span class="toctext">Computational class</span></a></li> | |
| <li class="toclevel-1 tocsection-7"><a href="#See_also"><span class="tocnumber">4</span> <span class="toctext">See also</span></a></li> | |
| <li class="toclevel-1 tocsection-8"><a href="#External_resources"><span class="tocnumber">5</span> <span class="toctext">External resources</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Data_storage">Data storage</span></h2> | |
| <p>Like in brainfuck and Brainpocalypse, Brainpocalypse II stores data on a tape of cells, each of which holds an unbounded non-negative integer, initially 0. Although the tape is conceptually infinite (like in brainfuck), only a finite number of cells on the tape can ever be read or written by any given program (because for any given location in the program, it is possible to statically calculate which cell it is referring to). | |
| </p> | |
| <h2><span class="mw-headline" id="Commands_and_syntax">Commands and syntax</span></h2> | |
| <p>There are three different syntaxes available for Brainpocalypse II. These are equivalent to each other, and effectively different ways of viewing the same language. | |
| </p> | |
| <h3><span class="mw-headline" id="Standard_version">Standard version</span></h3> | |
| <p>The standard version of the language uses a pointer that points to a cell on the tape, and has the following commands: | |
| </p> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <td><code><</code></td> | |
| <td>Move the tape pointer one cell to the left. | |
| </td></tr> | |
| <tr> | |
| <td><code>></code></td> | |
| <td>Move the tape pointer one cell to the right. | |
| </td></tr> | |
| <tr> | |
| <td><code>+</code></td> | |
| <td>Add 1 to the cell that the tape pointer is pointing to. | |
| </td></tr> | |
| <tr> | |
| <td><code>-</code></td> | |
| <td>Subtract 1 from the cell that the tape pointer is pointing to, <i>if</i> it's nonzero.<br/>If the cell was 0 (and thus the subtraction was not performed), instead set the cell to 1, reset the tape pointer to its initial location, and goto to the start of the program. | |
| </td></tr></tbody></table> | |
| <p>The commands generally run in sequence, from the start to the end of the program. The <code>-</code> command can be an exception, if it attempts to decrement zero; in this case, the program runs again from the start (and with the tape pointer reset to its initial location, and the cell that was to be decremented being incremented instead). | |
| </p><p>When execution falls off the end of the program, execution halts. If there are any nonzero values on the tape at the time, this is a "standard halt"; if all the tape values are zero, this is a "perfect halt". | |
| </p><p>It is possible to statically determine the position of the tape pointer, at any given point in the program, by counting the number of <code><</code> and <code>></code> commands up to that point; because a jump to the start of the program also resets the tape pointer to its initial location, the tape pointer will be in the same place any time a given command runs. | |
| </p> | |
| <h3><span class="mw-headline" id="Minimized_version">Minimized version</span></h3> | |
| <p>Just as with its predecessor Brainpocalypse, it is possible to minimize Brainpocalypse II down to two commands: | |
| </p> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <td><code>(</code></td> | |
| <td>Add 1 to the cell that the tape pointer is pointing to. Reset the tape pointer to its original location. | |
| </td></tr> | |
| <tr> | |
| <td><code>)</code></td> | |
| <td>If the cell that the tape pointer is pointing to is nonzero, subtract 1 from it, then move the tape pointer one cell to the right.<br/>Otherwise add 1 to that cell, reset the tape pointer to its initial location, and goto the start of the program. | |
| </td></tr></tbody></table> | |
| <p>By treating every second cell as a <a href="/wiki/Bit_bucket" title="Bit bucket">bit bucket</a> whose value is never relevant (and instead just used to reset the tape pointer location by incrementing it), it is possible to compile the standard version of the language into this minimized version; after a pointer location reset, it is possible to move to a known cell (without changing any cell values) that's <i>n</i> spaces to the right of the reset position by doing 2<sup><i>n</i>-1</sup> <code>(</code>, then 2<sup><i>n</i>-2</sup> <code>)(</code>, then 2<sup><i>n</i>-3</sup> <code>))(</code>, and so on, finishing with <i>n</i> copies of <code>)</code>. For example, to reach cell 3, you can do <code>(((()()())()))</code>: | |
| </p> | |
| <pre>initial [0] 0 0 0 | |
| (((( [4] 0 0 0 | |
| ) 3 [0] 0 0 | |
| ( [3] 1 0 0 | |
| )( [2] 2 0 0 | |
| ) 1 [2] 0 0 | |
| ) 1 1 [0] 0 | |
| ( [1] 1 1 0 | |
| ) 0 [1] 1 0 | |
| ) 0 0 [1] 0 | |
| ) 0 0 0 [0] | |
| </pre> | |
| <p>The ability to move the tape pointer to a known cell from its starting location, and to reset it to its starting location, make it possible to move it anywhere. Then, <code>(</code> and <code>)</code> can be used to implement the <code>+</code> and <code>-</code> instructions by moving the tape pointer to the appropriate cell, running <code>(</code> or <code>)</code> as appropriate, and moving the tape pointer back to a known location (in the case of <code>)</code>; <code>(</code> does this automatically). | |
| </p> | |
| <h3><span class="mw-headline" id="Numerical_version">Numerical version</span></h3> | |
| <p>In the numerical version of Brainpocalypse II, instead of having a tape pointer, commands instead specify which tape cell they are working on directly. There are two commands, each of which takes a numerical argument: | |
| </p> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <td><code>+<i>n</i></code></td> | |
| <td>Add 1 to the cell <i>n</i>. | |
| </td></tr> | |
| <tr> | |
| <td><code>-<i>n</i></code></td> | |
| <td>Subtract 1 from cell <i>n</i>, <i>if</i> it's nonzero.<br/>If the cell was 0 (and thus the subtraction was not performed), instead set the cell to 1 and goto to the start of the program. | |
| </td></tr></tbody></table> | |
| <p>This version of the program is harder to parse, but a little easier to read because the affected cells are explicitly stated (so there's no need to count instructions to work out which cell is affected by any given command). It is up to the implementation whether cell numbers are 0-based or 1-based (programs can be written to work regardless of which convention the implementation uses simply by choosing not to use the cell <i>n</i>=0 regardless of whether or not it exists). | |
| </p><p>Because for all three versions of the syntax, any given command always operates on a statically known cell, it is possible to compile the other versions of the syntax into this one via changing a <code>+</code> or <code>(</code> into <code>+<i>n</i></code> (where <i>n</i> is the cell it operates on), and a <code>-</code> or <code>)</code> into <code>-<i>n</i></code> in the same way. | |
| </p> | |
| <h2><span class="mw-headline" id="Computational_class">Computational class</span></h2> | |
| <p>Although Brainpocalypse II starts out with a tape of all-zeroes, it is trivial to compile "Brainpocalypse II but programs specify initial values for the tape cells they use" into the official version of the language. The idea is to reserve one additional cell as a marker that specifies whether or not the tape has been initialised (0 for uninitialised, 1 for initialised). The compilation adds additional code at the start of the program, which increases every tape element by its initial value, then decrements the "tape initialised" marker, increments the "tape initialised" marker again, and decreases every tape element by its initial value again. If the tape has been initialised, this entire block of code cancels itself out and is a no-op. However, if the tape has not been initialised, the attempt to decrement the "tape initialised" marker will restart the program, whilst setting the "tape initialised" marker to 1, and every tape element will be left with the correct initial value when this occurs. | |
| </p><p>Given the ability to initialise cells as desired, it is fairly simple to compile <a href="/wiki/The_Waterfall_Model" title="The Waterfall Model">The Waterfall Model</a> into Brainpocalypse II. The idea is to use two cells for each waterclock. The first of these cells, <i>z</i>, is used to control the zeroing trigger; it usually has the value 1, but instead has the value 0 if the waterclock has zeroed but its zeroing trigger has not been run yet. The second of these cells, <i>v</i>, stores the waterclock's value. | |
| </p><p>The basic structure of the program (after initialisation) is to start by testing all the <i>z</i> cells, in a very similar way to the initialisation: for each cell <i>n</i>, each cell's <i>v</i> (including <i>n</i>'s) is increased by the appropriate value from the zeroing trigger, then <i>n</i>'s <i>z</i> is decremented and incremented, then all the adjustments to the <i>v</i> cells are undone. If any cells had become zero, but their zeroing trigger had not run yet, then this will implement the effects of the zeroing trigger, whilst setting the <i>z</i> cell in question back to 1. (One slight tweak: the adjustment to <i>n</i>'s <i>v</i> will be 1 smaller than the zeroing trigger value, because <i>n</i> will have incremented itself to 1 when it was successfully tested for zeroness.) | |
| </p><p>After the tests of the <i>z</i> cells comes the steady decrement (implemented simply by decrementing all the <i>v</i> cells – they should all be at least 1 at this point, so the program's control flow does not reset), and then tests of all the <i>v</i> cells. These are done by decrementing the corresponding <i>z</i> cell, decrementing and incrementing the <i>n</i> cell, and incrementing the <i>z</i> cell again. | |
| </p><p>At the end of the program, the "tape initialised" marker is decremented twice. This sets its value from 1 to 0 back to 1 and restarts the program. | |
| </p><p>Halting can also be implemented easily in this construction: a halt counter's zeroing trigger can be defined to add 2 to every counter (including itself), and also to increment the "tape initialised" marker. The change to the "tape initialised" marker will have no immediate effect on the initialisation code, and will not change the behaviour of the bulk of the program (nor will any waterclock zero, because they all had 2 added to them). At the end of the program, the double-decrement of the "tape initialised" marker will not restart the program, and so the program will run off the end and do a standard halt. (If the values of every waterclock are known at this point – which is possible if the Waterfall Model program was originally compiled from a state-machine-plus-counters model such as a <a href="/wiki/Minsky_machine" title="Minsky machine">Minsky machine</a>, and the state machine zeroed its counters before halting – every cell will have a known value at this point, so it is possible to decrease every cell by its known value and do a perfect halt.) | |
| </p> | |
| <h2><span class="mw-headline" id="See_also">See also</span></h2> | |
| <ul><li><a href="/wiki/Brainpocalypse" title="Brainpocalypse">Brainpocalypse</a></li> | |
| <li><a href="/wiki/UT19" title="UT19">UT19</a></li> | |
| <li><a href="/wiki/The_Waterfall_Model" title="The Waterfall Model">The Waterfall Model</a></li> | |
| <li><a href="/wiki/Primepocalypse" title="Primepocalypse">Primepocalypse</a></li> | |
| <li><a href="/wiki/GotoStart" title="GotoStart">GotoStart</a></li></ul> | |
| <h2><span class="mw-headline" id="External_resources">External resources</span></h2> | |
| <ul><li><a class="external text" href="https://tio.run/##AaIAXf9qZWxsef//4buLwq7DkSvhuo7igbgswrnhuYThuIrFu8aKQcaRP0HigJgxwqYKQeG5rMOX4bmgCuKBvistCsKzZsKiO8OYRMKkwrXComnisa7Fk@G5l8K54biKVsKp4bmbWzEsWzAsMF1dw7EvMeG7iyQ8wq5M4oCYwqTGisK/////Iis2IC0xICs3IC0yICs4IC0zICs5IC00ICsxMCAtNSI" rel="nofollow">An implementation</a> in <a href="/wiki/Jelly" title="Jelly">Jelly</a>, runnable online at Try It Online; implements only the 1-based numerical syntax</li></ul> | |
| <ul><li><a class="external text" href="https://scratch.mit.edu/projects/1074222495/" rel="nofollow">Short Scratch implememtation</a>, with numerical syntax</li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20260108135454 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.022 seconds | |
| Real time usage: 0.043 seconds | |
| Preprocessor visited node count: 36/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:17626-0!canonical and timestamp 20260108135454 and revision id 172507. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b>But Is It Art?</b> is an <a href="/wiki/Esoteric_programming_language" title="Esoteric programming language">esoteric programming language</a> created by <a href="/wiki/User:Ais523" title="User:Ais523">User:ais523</a> in <a href="/wiki/Category:2017" title="Category:2017">2017</a>, as a constraint-solving tarpit. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Syntax"><span class="tocnumber">1</span> <span class="toctext">Syntax</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#I/O_encoding"><span class="tocnumber">2</span> <span class="toctext">I/O encoding</span></a></li> | |
| <li class="toclevel-1 tocsection-3"><a href="#Semantics"><span class="tocnumber">3</span> <span class="toctext">Semantics</span></a></li> | |
| <li class="toclevel-1 tocsection-4"><a href="#Example"><span class="tocnumber">4</span> <span class="toctext">Example</span></a></li> | |
| <li class="toclevel-1 tocsection-5"><a href="#Computational_class"><span class="tocnumber">5</span> <span class="toctext">Computational class</span></a></li> | |
| <li class="toclevel-1 tocsection-6"><a href="#External_resources"><span class="tocnumber">6</span> <span class="toctext">External resources</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Syntax">Syntax</span></h2> | |
| <p>But Is It Art? uses a typical source code design for 2-dimensional languages; each character of input other than newlines is placed in sequence onto a 2-dimensional canvas, with each character typically being placed to the right of the previous character, or at the start of the next line down after a newline is read. The "space" character (32 if the program is encoded in ASCII) is treated as nonexistent after this step, and only serves to adjust the location of the rest of the source code on the canvas. | |
| </p><p>After this, the source code is split into orthogonally connected regions, each of which is called a <i>tile</i>. For example, there are three tiles in the following program (each of which happens to consist entirely of a single character, but replacing any of the non-space non-newline characters with other non-space non-newline characters would lead to the same division into tiles): | |
| </p> | |
| <pre>A BBBB | |
| A B B | |
| AA CC | |
| A CC | |
| </pre> | |
| <p>The actual position of the tiles on the canvas is irrelevant (although their orientation is relevant), so the above program is equivalent to this one: | |
| </p> | |
| <pre> CC A | |
| CC A | |
| BBBB AA | |
| B B A | |
| </pre> | |
| <h2><span id="I.2FO_encoding"></span><span class="mw-headline" id="I/O_encoding">I/O encoding</span></h2> | |
| <p>For most characters that appear inside a tile, their actual identity is irrelevant; almost all non-space non-newline characters are interchangeable. However, if a letter appears on a tile, that's a request to do I/O. I/O is done a nybble at a time, with the more significant nybble first. There are, of course, 16 possible nybbles; when doing input, these are encoded as <code>a</code> for 0, <code>b</code> for 1, <code>c</code> for 2, and so on, up to <code>p</code> for 15; and when doing output the same encoding is used but in capital letters (so <code>A</code> is 0, <code>B</code> is 1, and <code>P</code> is 15). | |
| </p> | |
| <h2><span class="mw-headline" id="Semantics">Semantics</span></h2> | |
| <p>A given But Is It Art? program, with given user input, is <i>successful</i> if and only if the following condition is true: | |
| </p> | |
| <blockquote><p>It is possible to dissect some (non-degenerate, i.e. at least 1 character long in each dimension) rectangle of non-space characters into tiles, such that each tile appears in the program in the same orientation, and the sequence of lowercase letters in the rectangle (when read in normal English reading order, top-to-bottom and left-to-right) is the encoding of the entire contents of standard input. This rectangle is called a <i>witness rectangle</i> for the program and input.</p></blockquote> | |
| <p>Note that it's possible to use a tile more than once, or less than once, when forming the witness rectangle. | |
| </p><p>If the program is successful for the given input (i.e. at least one witness rectangle exists), an implementation must produce the output encoded by the sequence of capital letters that appears on some witness rectangle (again in normal English reading order), and then exit, indicating that no error occurred. This means that programs can be nondeterministic, in the sense that more than one output is reasonable for a given program. In the case when more than one witness rectangle exists, implementations are not required to select any particular witness rectangle; both consistently selecting the same rectangle each time the program is run, and picking a random rectangle each time the program is run, are reasonable behaviours. | |
| </p><p>If the program is <i>not</i> successful for the given input, then an implementation has two options: | |
| </p> | |
| <ul><li>If it can <i>prove</i> that the program is not successful, it should exit with an error message, indicating the existence of an error.</li> | |
| <li>If it cannot prove that the program is not successful, it enters an infinite loop.</li></ul> | |
| <p>It's mostly up to the implementation how much effort it puts into proving that no witness rectangle exists; one implementation could enter an infinite loop on a program/input combination, while another implementation could exit with an error on the same program and input. However, an implementation must at least be able to definitively determine whether a witness rectangle exists in cases where every tile in the program contains a lowercase letter (because such problems can be solved simply via brute force). However, an implementation <i>must</i> always eventually terminate if a witness rectangle does exist. | |
| </p> | |
| <h2><span class="mw-headline" id="Example">Example</span></h2> | |
| <p>The following program is successful if and only if the input is empty: | |
| </p> | |
| <pre>### + = | |
| # ++ == | |
| </pre> | |
| <p>because it can construct the following witness rectangle for the empty input: | |
| </p> | |
| <pre>###= | |
| #+== | |
| +++= | |
| ++== | |
| </pre> | |
| <p>but the fact that it contains no lowercase letters means that any input other than the null string can't possibly match the input sequence. | |
| </p><p>The following program is conjectured to accept exactly the strings of <code>A</code>s (as nybbles: <code>eb</code>) whose length is a composite number: | |
| </p> | |
| <pre>2eb2 eb3 eb eb | |
| 222 333 555 777 | |
| 2 3 5 | |
| </pre> | |
| <p>The following is an example witness rectangle accepting the string <code>AAAAAAAAA</code> of length 3 × 3 = 9. | |
| </p> | |
| <pre>2eb2<span style="color:green">eb3</span>eb | |
| 222<span style="color:green">333</span>555 | |
| 2<span style="color:blue">eb</span><span style="color:green">3</span><span style="color:red">eb</span>5<span style="color:blue">eb</span> | |
| <span style="color:blue">555</span><span style="color:red">555</span><span style="color:blue">555</span> | |
| <span style="color:blue">5</span>eb<span style="color:red">5</span><span style="color:green">eb</span><span style="color:blue">5</span>eb | |
| 777<span style="color:green">777</span>777 | |
| </pre> | |
| <h2><span class="mw-headline" id="Computational_class">Computational class</span></h2> | |
| <p>Numerous <a class="mw-redirect" href="/wiki/Turing_complete" title="Turing complete">Turing complete</a> languages have a fairly direct translation into But Is It Art?, such as <a href="/wiki/Thue" title="Thue">Thue</a> (although you typically have to change the halting behaviour by adding an explicit halt state to the language you're compiling from, doing so rarely affects the computational class); But Is It Art? is thus also Turing complete. (Most of the constructions work via choosing the tiles in such a way that the witness rectangle forms a complete history of the execution of the program being compiled.) | |
| </p> | |
| <h2><span class="mw-headline" id="External_resources">External resources</span></h2> | |
| <ul><li>Implementation at <a class="external text" href="https://github.com/qpliu/esolang/blob/master/random/art.hs" rel="nofollow">https://github.com/qpliu/esolang/blob/master/random/art.hs</a></li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20250729025451 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.011 seconds | |
| Real time usage: 0.036 seconds | |
| Preprocessor visited node count: 37/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:11226-0!canonical and timestamp 20250729025451 and revision id 162353. Rendering was triggered because: diff-page | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p>ByteByteJump is an extremely simple One Instruction Set Computer (<a href="/wiki/OISC" title="OISC">OISC</a>). Its single instruction copies 1 byte from a memory location to another, and then performs an unconditional jump. | |
| </p><p>An instruction consists of 3 addresses stored consecutively in memory: | |
| </p> | |
| <pre>A,B,C | |
| </pre> | |
| <p>A is the source address, B is the destination address, and C is the jump address. <b>N.B:</b> ByteByteJump uses <a class="extiw" href="https://en.wikipedia.org/wiki/Byte_addressing" title="wikipedia:Byte addressing">byte addressing</a>. | |
| </p><p>ByteByteJump has no ALU, but arithmetic operations and conditional jumps can still be performed by using self-modifying code and lookup tables (see <a href="#Example:_Subtract_and_jump_if_negative">Example</a>). Despite its apparent simplicity, ByteByteJump actually belongs to the computational class of real microprocessors: any particular ByteByteJump machine is a <a href="/wiki/Bounded-storage_machine" title="Bounded-storage machine">bounded-storage machine</a>. | |
| </p><p><a href="#WordWordJump">WordWordJump</a> is the larger family of machines to which ByteByteJump belongs. An <i>X</i>*<i>Y</i>-bit WordWordJump machine has <i>Y</i>-bit data words and <i>X</i>*<i>Y</i>-bit address words, where <i>X</i> must be ≥2 for the machine to be able to compute. The optimal value for <i>X</i> (as explained <a href="#Optimal_number_of_words_per_address?">here</a>) seems to be 3. | |
| </p><p><a href="#The_two-instruction_ByteByte/Jump">ByteByte/Jump</a> is ByteByteJump's sister machine. It splits the single instruction of ByteByteJump into two for improved code density. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Virtual_Machine_implementation"><span class="tocnumber">1</span> <span class="toctext">Virtual Machine implementation</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#WordWordJump"><span class="tocnumber">2</span> <span class="toctext">WordWordJump</span></a></li> | |
| <li class="toclevel-1 tocsection-3"><a href="#Optimal_number_of_words_per_address?"><span class="tocnumber">3</span> <span class="toctext">Optimal number of words per address?</span></a></li> | |
| <li class="toclevel-1 tocsection-4"><a href="#The_two-instruction_ByteByte/Jump"><span class="tocnumber">4</span> <span class="toctext">The two-instruction <i>ByteByte/Jump</i></span></a></li> | |
| <li class="toclevel-1 tocsection-5"><a href="#Example:_Subtract_and_jump_if_negative"><span class="tocnumber">5</span> <span class="toctext">Example: Subtract and jump if negative</span></a></li> | |
| <li class="toclevel-1 tocsection-6"><a href="#X*Y-bit_move_machines"><span class="tocnumber">6</span> <span class="toctext"><i>X</i>*<i>Y</i>-bit move machines</span></a></li> | |
| <li class="toclevel-1 tocsection-7"><a href="#See_Also"><span class="tocnumber">7</span> <span class="toctext">See Also</span></a></li> | |
| <li class="toclevel-1 tocsection-8"><a href="#External_resources"><span class="tocnumber">8</span> <span class="toctext">External resources</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Virtual_Machine_implementation">Virtual Machine implementation</span></h2> | |
| <p>Here's an implementation in C of a ByteByteJump VM with 4-byte addresses: | |
| </p> | |
| <pre>uint8_t mem[MEMSIZE]; | |
| uint32_t *pc = (uint32_t *)mem; | |
| for(;;) { | |
| mem[pc[1]] = mem[pc[0]]; | |
| pc = (uint32_t *)(mem + pc[2]); | |
| } | |
| </pre> | |
| <p>The VM above will run forever. Instead, we could quit upon reaching a "do-nothing-forever" instruction, i.e. one that: | |
| </p> | |
| <ul><li>has the same address for both source and destination, and</li> | |
| <li>jumps back to itself.</li></ul> | |
| <h2><span class="mw-headline" id="WordWordJump">WordWordJump</span></h2> | |
| <p>ByteByteJump can be considered to be a member of the larger family of <i>WordWordJump</i> machines. The simplest possible WordWordJump machine is <a href="/wiki/BitBitJump" title="BitBitJump">BitBitJump</a> which moves 1 bit at a time. We define an <i><b>X</b>*<b>Y</b>-bit WordWordJump</i> machine to have <i><b>X</b></i> words per address, and <i><b>Y</b></i> bits per word. Thus, a 32-bit ByteByteJump machine could also be referred to as a 4*8-bit WordWordJump machine. | |
| </p> | |
| <h2><span id="Optimal_number_of_words_per_address.3F"></span><span class="mw-headline" id="Optimal_number_of_words_per_address?">Optimal number of words per address?</span></h2> | |
| <p>How many data words should an address word optimally consist of? I.e. what should <i>X</i> be for an optimal <i>X</i>*<i>Y</i>-bit WordWordJump machine? Well, since we have no ALU, arithmetic/logic operations have to be performed by way of table lookups, which requires <i>X</i> to be ≥ 2 for the machine to function at all. But having at least 3 words per address simplifies things by allowing us to directly index into a 3-dimensional array of type [opcode][operand][operand]. On the other hand, <i>X</i> should be as small as possible to maximize code density. So it seems 3 is the magic number. Which means that an (in this sense) optimal ByteByteJump machine is one with 24-bit (3-byte) addresses. It would perhaps seem more natural to have 4-byte addresses for a ByteByteJump VM running on a 32-bit host. And with 24-bit addresses we can only access 16 MiB (vs 4 GiB using 32-bit addresses). But if we need a bigger address range, we can instead keep the 3-words-per-address format and increase the wordsize. A 3*10-bit WordWordJump machine for example can address 1 GiWords, and a 3*12-bit one can address 64 GiWords. | |
| </p><p>Here's a 3*10-bit WordWordJump VM: | |
| </p> | |
| <pre>uint16_t *mem, *pc; | |
| ... | |
| for (;;) { | |
| mem[pc[3]<<20 | pc[4]<<10 | pc[5]] = | |
| mem[pc[0]<<20 | pc[1]<<10 | pc[2]]; | |
| pc = mem + (pc[6]<<20 | pc[7]<<10 | pc[8]); | |
| } | |
| </pre> | |
| <p>The above machine uses 16 bits to store each 10-bit word. Alternatively you could pack 3 10-bit words into a 32-bit integer. | |
| </p> | |
| <h2><span id="The_two-instruction_ByteByte.2FJump"></span><span class="mw-headline" id="The_two-instruction_ByteByte/Jump">The two-instruction <i>ByteByte/Jump</i></span></h2> | |
| <p>We could split the aggregate <i>move-and-jump</i> instruction into its constituent parts: <i>move</i> and <i>jump</i>, using a 1-bit opcode. This would result in improved code density, the flipside being a halved address range and some added instruction decoding work. | |
| </p><p>Let's use the most significant address bit as the opcode: 0=<i>move byte</i>, 1=<i>jump</i>. Since we now have 1 bit less for the source and jump addresses, the destination msb no longer serves any real purpose. But we'll put that bit to good use by adding support for a <i>variable</i> number of destinations. How? By defining a destination msb of 0 to mean that this is the last destination, and a 1 to mean that there are more destinations to follow. | |
| </p><p>To distinguish this new 2-opcode ByteByteJump dialect from the original opcode-less one, we'll put in a forward slash and call it <i>ByteByte<b>/</b>Jump</i>. We analogously define an <i><b>X</b>*<b>Y</b>-bit WordWord/Jump</i> machine to have <i><b>X</b></i>*<i><b>Y</b></i>-bit instruction words (but only <i><b>X</b></i>*<i><b>Y</b></i>-1 address bits, since the most significant bit is used for the opcode / destination endmarker. | |
| </p><p>Since we now have separate <i>move</i> and <i>jump</i> instructions, we could simply halt on detecting an infinite one-instruction loop: | |
| </p> | |
| <pre><i>A</i>: Jump <i>A</i> | |
| </pre> | |
| <h2><span class="mw-headline" id="Example:_Subtract_and_jump_if_negative">Example: Subtract and jump if negative</span></h2> | |
| <p>Suppose we have the following values stored in memory: | |
| </p> | |
| <pre>Address | Value | |
| ---------------+------ | |
| 000800..00087F | 01 | |
| 000880..0008FF | 02 | |
| 01<i>XXYY</i> | <i>XX</i> | |
| 02<i>XXYY</i> | <i>YY</i> | |
| 03<i>XXYY</i> | <i>XX</i>-<i>YY</i> | |
| </pre> | |
| <p>Then the following ByteByteJump program (using 3-byte addresses) will take the byte value at address 100h, subtract the byte value at address 200h, store the resulting byte value at address 300h, and jump to address 400h if the result was negative (≥ 80h). Addresses which differ between the big-endian and little-endian versions are marked as <b>bold</b>. | |
| </p> | |
| <pre>Big-endian version | Little-endian version | |
| -----------------------------+----------------------------- | |
| 000000: 000100 000013 000009 | 000000: 000100 000013 000009 | |
| 000009: 000200 <b>000014</b> 000012 | 000009: 000200 <b>000012</b> 000012 | |
| 000012: 030000 000300 00001B | 000012: 030000 000300 00001B | |
| 00001B: 000300 <b>000026</b> 000024 | 00001B: 000300 <b>000024</b> 000024 | |
| 000024: 000800 <b>00002D</b> 00002D | 000024: 000800 <b>00002F</b> 00002D | |
| 00002D: 003F36 <b>000035</b> 000000 | 00002D: 003F36 <b>000033</b> 000000 | |
| 000036: 000000 000000 000400 | 000036: 000000 000000 000400 | |
| 00003F: ...... ...... ...... | 00003F: ...... ...... ...... | |
| </pre> | |
| <p>Below is the previous ByteByteJump example rewritten in ByteByte/Jump machine code. Instruction words which differ between the big-endian and little-endian versions are marked as <b>bold</b>. | |
| </p> | |
| <pre>Big-endian version | Little-endian version | |
| -----------------------------+----------------------------- | |
| 000000: 000100 00000D | 000000: 000100 00000D | |
| 000006: 000200 <b>00000E</b> | 000006: 000200 <b>00000C</b> | |
| 00000C: 030000 800300 <b>000017</b> | 00000C: 030000 800300 <b>000015</b> | |
| 000015: 000800 <b>00001B</b> | 000015: 000800 <b>00001D</b> | |
| 00001B: 002724 <b>000023</b> | 00001B: 002724 <b>000021</b> | |
| 000021: 800000 | 000021: 800000 | |
| 000024: 800400 | 000024: 800400 | |
| 000027: ...... | 000027: ...... | |
| </pre> | |
| <p>The ByteByteJump version takes up 63 bytes, while the ByteByte/Jump version takes up 39 bytes. At address 00000C in the ByteByte/Jump program, notice the use of multiple (in this case 2) destinations for the <i>move</i> instruction. | |
| </p> | |
| <h2><span id="X.2AY-bit_move_machines"></span><span class="mw-headline" id="X*Y-bit_move_machines"><i>X</i>*<i>Y</i>-bit move machines</span></h2> | |
| <p>A similar architecture to the <i>X</i>*<i>Y</i>-bit WordWordJump is the <i>X</i>*<i>Y</i>-bit Move machine. Just as with WordWordJump, <i>X</i> must be greater than or equal to 2 for the machine to be able to work without an ALU. This type of machine has only 2 address operands: source and destination. The jump address (or program counter) is instead mapped to some fixed location in memory. | |
| </p><p><a class="external text" href="http://people.eku.edu/styere/index.html" rel="nofollow">Eugene Styer</a> created two machines of this type in 1996: | |
| </p> | |
| <ol><li>Byte Move with 16-bit addresses and byte-addressable memory</li> | |
| <li>As above, but with 24-bit addresses</li></ol> | |
| <p>Both of these machines are described <a class="external text" href="http://people.eku.edu/styere/oisc.html" rel="nofollow">here</a>. From the same page you can also download a simulator with an integrated macro assembler and some example programs. | |
| </p><p>As mentioned at the bottom of that page:<br/> | |
| <i>"It should be noted that with the exception of Word Move, none of the machines has any requirement for 'magic' locations except for the program counter and ordinary memory-mapped I/O devices (although Byte Move 24-bit uses some, those are for convience and not necessity). This is in contrast to some Move machine designs that use special addresses for addition, subtraction, etc. (write A to 0010, B to 0020, read A+B from 0030)."</i> | |
| </p> | |
| <h2><span class="mw-headline" id="See_Also">See Also</span></h2> | |
| <ul><li><a href="/wiki/OISC" title="OISC">OISC</a></li> | |
| <li><a href="/wiki/BitBitJump" title="BitBitJump">BitBitJump</a> - the simplest WordWordJump machine</li> | |
| <li><a href="/wiki/FlipJump" title="FlipJump">FlipJump</a> - similar but flips a bit and jump</li> | |
| <li><a href="/wiki/BytePusher" title="BytePusher">BytePusher</a> - a minimalist virtual videogame console with a ByteByteJump CPU</li> | |
| <li><a href="/wiki/ByteByte" title="ByteByte">ByteByte</a> - byte move with cyclical program counter</li> | |
| <li><a href="/wiki/ByteMover" title="ByteMover">ByteMover</a> - a variation on ByteByteJump</li></ul> | |
| <h2><span class="mw-headline" id="External_resources">External resources</span></h2> | |
| <ul><li><a class="external text" href="http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?arnumber=47458" rel="nofollow">NAP (no ALU processor): the great communicator</a></li> | |
| <li><a class="external text" href="http://styere.xyz/oisc.html" rel="nofollow">One Instruction Computers - How Low Can You Go?</a></li> | |
| <li><a class="extiw" href="https://en.wikipedia.org/wiki/IBM_1620" title="wikipedia:IBM 1620">IBM 1620</a>, a.k.a the CADET - "<b>C</b>an't <b>A</b>dd, <b>D</b>oesn't <b>E</b>ven <b>T</b>ry"</li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20250723235654 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.015 seconds | |
| Real time usage: 0.015 seconds | |
| Preprocessor visited node count: 38/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:3357-0!canonical and timestamp 20250723235654 and revision id 101525. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><table style="float:right;border:1px solid silver;background-color:rgb(249, 249, 249);max-width:256px;padding:5px;"> | |
| <caption><b>Chicken</b></caption> | |
| <tbody><tr> | |
| <th style="text-align: left;vertical-align: top;"><a href="/wiki/Esolang:Categorization#Paradigm" title="Esolang:Categorization">Paradigm(s)</a></th> | |
| <td>imperative</td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;">Designed by</th> | |
| <td>Torbjörn Söderstedt</td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;"><a href="/wiki/Category:Years" title="Category:Years">Appeared in</a></th> | |
| <td><a href="/wiki/Category:2013" title="Category:2013">2013</a></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;">Type system</th> | |
| <td>dynamic, weak</td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;"><a href="/wiki/Esolang:Categorization#Memory" title="Esolang:Categorization">Memory system</a></th> | |
| <td><a href="/wiki/Category:Stack-based" title="Category:Stack-based">Stack-based</a></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;"><a href="/wiki/Esolang:Categorization#Dimensions" title="Esolang:Categorization">Dimensions</a></th> | |
| <td>one-dimensional</td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;"><a href="/wiki/Computational_class" title="Computational class">Computational class</a></th> | |
| <td><a href="/wiki/Category:Turing_complete" title="Category:Turing complete">Turing complete</a></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;">Reference implementation</th> | |
| <td><a class="external text" href="https://web.archive.org/web/20180420010853/http://torso.me/chicken" rel="nofollow">Chicken homepage</a> <i>(from the <a class="extiw" href="https://en.wikipedia.org/wiki/Wayback_Machine" title="wikipedia:Wayback Machine">Wayback Machine</a>; retrieved on 20 April 2018)</i></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;">Dialects</th> | |
| <td>Chicken, MiniChicken</td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;">Influenced</th> | |
| <td><a href="/wiki/Blue_Hens" title="Blue Hens">Blue Hens</a>, <a href="/wiki/%E7%A1%95%E9%BC%A0" title="硕鼠">硕鼠</a>, <a href="/wiki/%E9%80%80%EF%BC%81%E9%80%80%EF%BC%81%E9%80%80%EF%BC%81" title="退!退!退!">退!退!退!</a>, <a href="/wiki/WooYeah" title="WooYeah">WooYeah</a></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;">File extension(s)</th> | |
| <td>Unknown</td> | |
| </tr> | |
| </tbody></table> | |
| <p><b>Chicken</b> is an <a href="/wiki/Esoteric_programming_language" title="Esoteric programming language">esoteric programming language</a> by Torbjörn Söderstedt, in which "chicken" is the only valid symbol. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Language_overview"><span class="tocnumber">1</span> <span class="toctext">Language overview</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Memory_model"><span class="tocnumber">2</span> <span class="toctext">Memory model</span></a></li> | |
| <li class="toclevel-1 tocsection-3"><a href="#Instructions"><span class="tocnumber">3</span> <span class="toctext">Instructions</span></a></li> | |
| <li class="toclevel-1 tocsection-4"><a href="#Data_Type"><span class="tocnumber">4</span> <span class="toctext">Data Type</span></a></li> | |
| <li class="toclevel-1 tocsection-5"><a href="#Examples"><span class="tocnumber">5</span> <span class="toctext">Examples</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-6"><a href="#Hello,_world!"><span class="tocnumber">5.1</span> <span class="toctext">Hello, world!</span></a></li> | |
| <li class="toclevel-2 tocsection-7"><a href="#Quine"><span class="tocnumber">5.2</span> <span class="toctext">Quine</span></a></li> | |
| <li class="toclevel-2 tocsection-8"><a href="#Cat"><span class="tocnumber">5.3</span> <span class="toctext">Cat</span></a></li> | |
| <li class="toclevel-2 tocsection-9"><a href="#99_Chickens"><span class="tocnumber">5.4</span> <span class="toctext">99 Chickens</span></a></li> | |
| <li class="toclevel-2 tocsection-10"><a href="#Deadfish"><span class="tocnumber">5.5</span> <span class="toctext">Deadfish</span></a></li> | |
| <li class="toclevel-2 tocsection-11"><a href="#undefined"><span class="tocnumber">5.6</span> <span class="toctext">undefined</span></a></li> | |
| <li class="toclevel-2 tocsection-12"><a href="#NaN"><span class="tocnumber">5.7</span> <span class="toctext">NaN</span></a></li> | |
| <li class="toclevel-2 tocsection-13"><a href="#A+B_Problem"><span class="tocnumber">5.8</span> <span class="toctext">A+B Problem</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-14"><a href="#MiniChicken"><span class="tocnumber">6</span> <span class="toctext">MiniChicken</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-15"><a href="#Translator_to/from_Chicken"><span class="tocnumber">6.1</span> <span class="toctext">Translator to/from Chicken</span></a></li> | |
| <li class="toclevel-2 tocsection-16"><a href="#Cat_program"><span class="tocnumber">6.2</span> <span class="toctext">Cat program</span></a></li> | |
| <li class="toclevel-2 tocsection-17"><a href="#Quine_2"><span class="tocnumber">6.3</span> <span class="toctext">Quine</span></a></li> | |
| <li class="toclevel-2 tocsection-18"><a href="#A+B_Problem_2"><span class="tocnumber">6.4</span> <span class="toctext">A+B Problem</span></a></li> | |
| <li class="toclevel-2 tocsection-19"><a href="#Computational_class"><span class="tocnumber">6.5</span> <span class="toctext">Computational class</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-20"><a href="#See_also"><span class="tocnumber">7</span> <span class="toctext">See also</span></a></li> | |
| <li class="toclevel-1 tocsection-21"><a href="#External_resources"><span class="tocnumber">8</span> <span class="toctext">External resources</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Language_overview">Language overview</span></h2> | |
| <p>A chicken program consists of the tokens "chicken", " " and "\n". Every line has a number of chickens separated by spaces. The number of chickens corresponds to an opcode. Trailing newlines are significant, as an empty line will produce a "0" opcode. | |
| </p><p>Instructions are loaded onto the stack and executed there directly, which allows for injecting arbitrary code and executing it through a jump. Self-modifying code is also possible because the program stack is not bounded. | |
| </p><p>The user is able to supply an input value before executing the program. This input is stored in one of the two registers. | |
| </p> | |
| <h2><span class="mw-headline" id="Memory_model">Memory model</span></h2> | |
| <p>The stack (represents the memory of the program) has three segments. | |
| </p><p>The first segment contains two registers. The first register just points to the stack itself (by reference). The second register contains the user input, which is usually a string. These registers are used by the LOAD instruction. | |
| </p><p>The second segment contains the loaded code. For each line of the code there is a cell on the stack containing the amount of chickens on that line. This segment is directly used for execution. It is automatically padded with a single EXIT instruction. | |
| </p><p>The third segment contains the actual program stack. As instructions are executed, they will push and pop values in this space. Since the segments are not isolated, it is possible to modify values in the code space or execute in the user stack space. | |
| </p> | |
| <h2><span class="mw-headline" id="Instructions">Instructions</span></h2> | |
| <p>Chicken supports the following instructions: | |
| </p> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <th>Opcode | |
| </th> | |
| <th>Name | |
| </th> | |
| <th>Name (chicken) | |
| </th> | |
| <th>Description | |
| </th></tr> | |
| <tr> | |
| <td><code>0</code> | |
| </td> | |
| <td>exit | |
| </td> | |
| <td>axe | |
| </td> | |
| <td>Stop execution. | |
| </td></tr> | |
| <tr> | |
| <td><code>1</code> | |
| </td> | |
| <td>chicken | |
| </td> | |
| <td>chicken | |
| </td> | |
| <td>Push the string "chicken" onto the stack. | |
| </td></tr> | |
| <tr> | |
| <td><code>2</code> | |
| </td> | |
| <td>add | |
| </td> | |
| <td>add | |
| </td> | |
| <td>Add two top stack values. | |
| </td></tr> | |
| <tr> | |
| <td><code>3</code> | |
| </td> | |
| <td>subtract | |
| </td> | |
| <td>fox | |
| </td> | |
| <td>Subtract two top stack values. | |
| </td></tr> | |
| <tr> | |
| <td><code>4</code> | |
| </td> | |
| <td>multiply | |
| </td> | |
| <td>rooster | |
| </td> | |
| <td>Multiply two top stack values. | |
| </td></tr> | |
| <tr> | |
| <td><code>5</code> | |
| </td> | |
| <td>compare | |
| </td> | |
| <td>compare | |
| </td> | |
| <td>Compare two top stack values for equality, push truthy or falsy result onto the stack. | |
| </td></tr> | |
| <tr> | |
| <td><code>6</code> | |
| </td> | |
| <td>load | |
| </td> | |
| <td>pick | |
| </td> | |
| <td>Double wide instruction. Next instruction indicates source to load from. 0 loads from stack, 1 loads from user input. Top of stack points to address/index to load onto stack. | |
| </td></tr> | |
| <tr> | |
| <td><code>7</code> | |
| </td> | |
| <td>store | |
| </td> | |
| <td>peck | |
| </td> | |
| <td>Top of stack points to address/index to store to. The value below that will be popped and stored. | |
| </td></tr> | |
| <tr> | |
| <td><code>8</code> | |
| </td> | |
| <td>jump | |
| </td> | |
| <td>fr | |
| </td> | |
| <td>Top of stack is a relative offset to jump to. The value below that is the condition. Jump only happens if condition is truthy. | |
| </td></tr> | |
| <tr> | |
| <td><code>9</code> | |
| </td> | |
| <td>char | |
| </td> | |
| <td>BBQ | |
| </td> | |
| <td>Pop <code><i>x</i></code> from stack and push <code>&#<i>x</i>;</code> | |
| </td></tr> | |
| <tr> | |
| <td><code>10+</code> | |
| </td> | |
| <td>push | |
| </td> | |
| <td> | |
| </td> | |
| <td>Pushes the literal number n-10 onto the stack. | |
| </td></tr></tbody></table> | |
| <p>The output is the top of stack HTML unescaped, for example, <code>&#65;</code> will become <code>A</code>. | |
| </p> | |
| <h2><span class="mw-headline" id="Data_Type">Data Type</span></h2> | |
| <p>In the original implementation, Chicken is dynamically and weak typed and types behave like they behave in JavaScript, but this is usually unimplemented in other implementations. | |
| </p> | |
| <h2><span class="mw-headline" id="Examples">Examples</span></h2> | |
| <h3><span id="Hello.2C_world.21"></span><span class="mw-headline" id="Hello,_world!"><a href="/wiki/Hello,_world!" title="Hello, world!">Hello, world!</a></span></h3> | |
| <pre>chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken | |
| chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken | |
| chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| </pre> | |
| <h3><span class="mw-headline" id="Quine"><a href="/wiki/Quine" title="Quine">Quine</a></span></h3> | |
| <pre>chicken | |
| </pre> | |
| <h3><span class="mw-headline" id="Cat"><a class="mw-redirect" href="/wiki/Cat" title="Cat">Cat</a></span></h3> | |
| <pre>chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| </pre> | |
| <h3><span class="mw-headline" id="99_Chickens"><a href="/wiki/99_bottles_of_beer" title="99 bottles of beer">99 Chickens</a></span></h3> | |
| <pre>chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken | |
| chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken | |
| chicken | |
| chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken | |
| </pre> | |
| <h3><span class="mw-headline" id="Deadfish"><a href="/wiki/Deadfish" title="Deadfish">Deadfish</a></span></h3> | |
| <pre>chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken | |
| chicken | |
| chicken chicken | |
| chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken | |
| chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken | |
| </pre> | |
| <h3><span class="mw-headline" id="undefined">undefined</span></h3> | |
| <pre>chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| </pre> | |
| <p>This pushes a JavaScript <code>undefined</code> literal onto the stack in the original implementation. | |
| </p> | |
| <h3><span class="mw-headline" id="NaN">NaN</span></h3> | |
| <pre>chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken | |
| </pre> | |
| <h3><span id="A.2BB_Problem"></span><span class="mw-headline" id="A+B_Problem"><a href="/wiki/A%2BB_Problem" title="A+B Problem">A+B Problem</a></span></h3> | |
| <p>Only supports one-digit A+B, for example, input is <code>1 2</code> and output will be <code>3</code>. | |
| </p> | |
| <pre>chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken chicken chicken chicken | |
| chicken | |
| chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken | |
| chicken chicken chicken | |
| chicken chicken | |
| </pre> | |
| <h2><span class="mw-headline" id="MiniChicken">MiniChicken</span></h2> | |
| <p>MiniChicken is a version of chicken created by <a href="/wiki/User:Cortex" title="User:Cortex">Cortex</a>. Numbers in MiniChicken are equivalent to a line of that many <code>chicken</code>s in Chicken, and a space is equivalent to a newline in Chicken. However, for no other reason than so it can make a <a href="/wiki/Quine" title="Quine">quine</a>, the number <code>1</code> pushes the number 1 onto the stack instead of the string "chicken". | |
| </p> | |
| <h3><span id="Translator_to.2Ffrom_Chicken"></span><span class="mw-headline" id="Translator_to/from_Chicken">Translator to/from Chicken</span></h3> | |
| <p>Written in <a href="/wiki/Python" title="Python">Python</a> 3. | |
| </p> | |
| <pre><span style="color:#00f">def</span> <span style="color:#f60">chicken_to_minichicken</span>(code: <span style="color:#77a">str</span>) <span style="color:#00f">-></span> <span style="color:#77a">str</span>: | |
| res <span style="color:#00f">=</span> [] | |
| code <span style="color:#00f">=</span> code.<span style="color:#77a">lower</span>() | |
| <span style="color:#00f">for</span> l <span style="color:#00f">in</span> code.<span style="color:#77a">split</span>(<span style="color:#090">"\n"</span>): | |
| res.<span style="color:#77a">append</span>(<span style="color:#77a">str</span>(l.<span style="color:#77a">count</span>(<span style="color:#090">"chicken"</span>))) | |
| <span style="color:#00f">return</span> <span style="color:#090">" "</span>.<span style="color:#77a">join</span>(res) | |
| <span style="color:#00f">def</span> <span style="color:#f60">minichicken_to_chicken</span>(code: <span style="color:#77a">str</span>) <span style="color:#00f">-></span> <span style="color:#77a">str</span>: | |
| res <span style="color:#00f">=</span> [] | |
| <span style="color:#00f">for</span> n <span style="color:#00f">in</span> code.<span style="color:#77a">split</span>(): | |
| res.<span style="color:#77a">append</span>(<span style="color:#090">" "</span>.<span style="color:#77a">join</span>(<span style="color:#090">"chicken"</span> <span style="color:#00f">for</span> _ <span style="color:#00f">in</span> <span style="color:#77a">range</span>(<span style="color:#77a">int</span>(n)))) | |
| <span style="color:#00f">return</span> <span style="color:#090">"\n"</span>.<span style="color:#77a">join</span>(res) | |
| </pre> | |
| <h3><span class="mw-headline" id="Cat_program">Cat program</span></h3> | |
| <pre>11 6 0 | |
| </pre> | |
| <h3><span class="mw-headline" id="Quine_2">Quine</span></h3> | |
| <pre>1 | |
| </pre> | |
| <h3><span id="A.2BB_Problem_2"></span><span class="mw-headline" id="A+B_Problem_2"><a href="/wiki/A%2BB_Problem" title="A+B Problem">A+B Problem</a></span></h3> | |
| <p>Only supports one-digit A+B, for example, input is <code>1 2</code> and output will be <code>3</code>. | |
| </p> | |
| <pre>10 6 1 10 3 12 6 1 10 3 2 | |
| </pre> | |
| <h3><span class="mw-headline" id="Computational_class">Computational class</span></h3> | |
| <p>Chicken/MiniChicken is <a class="mw-redirect" href="/wiki/Turing_complete" title="Turing complete">Turing complete</a>, as long as the values are unbounded. It can be translated from a 2-register <a href="/wiki/Minsky_machine" title="Minsky machine">Minsky machine</a> as follows: | |
| </p> | |
| <ul><li><code>11 2</code> to increment first counter</li> | |
| <li><code>10 6 11 2 10 7</code> to increment second counter</li> | |
| <li><code>11 3</code> to decrement first counter</li> | |
| <li><code>10 6 11 3 10 7</code> to decrement second counter</li> | |
| <li><code>11 6 10 5 <offset> 8</code> to jump if first counter = 0</li> | |
| <li><code>10 6 10 5 <offset> 8</code> to jump if second counter = 0</li></ul> | |
| <h2><span class="mw-headline" id="See_also">See also</span></h2> | |
| <ul><li><a href="/wiki/%E7%A1%95%E9%BC%A0" title="硕鼠">硕鼠</a></li> | |
| <li><a href="/wiki/%E9%80%80%EF%BC%81%E9%80%80%EF%BC%81%E9%80%80%EF%BC%81" title="退!退!退!">退!退!退!</a></li> | |
| <li><a href="/wiki/Blue_Hens" title="Blue Hens">Blue Hens</a></li> | |
| <li><a href="/wiki/WooYeah" title="WooYeah">WooYeah</a></li> | |
| <li><a href="/wiki/H%CC%B1" title="H̱">H̱</a></li></ul> | |
| <h2><span class="mw-headline" id="External_resources">External resources</span></h2> | |
| <ul><li><a class="external text" href="https://web.archive.org/web/20180420010853/http://torso.me/chicken" rel="nofollow">Chicken homepage</a> <i>(from the <a class="extiw" href="https://en.wikipedia.org/wiki/Wayback_Machine" title="wikipedia:Wayback Machine">Wayback Machine</a>; retrieved on 20 April 2018)</i> Includes instruction spec and original JavaScript implementation</li> | |
| <li><a class="external text" href="https://github.com/igorw/chicken-php" rel="nofollow">igorw/chicken</a> PHP implementation</li> | |
| <li><a class="external text" href="https://github.com/powder96/ChickenASM-PHP" rel="nofollow">powder96/ChickenASM-PHP</a> PHP implementation</li> | |
| <li><a class="external text" href="https://github.com/kosayoda/chickenpy" rel="nofollow">kosayoda/chickenpy</a> and <a class="external text" href="https://github.com/auscompgeek/chickenpie" rel="nofollow">auscompgeek/chickenpie</a> Python implementations</li> | |
| <li><a class="external text" href="https://github.com/armichaud/chicken_esolang" rel="nofollow">armichaud/chicken_esolang</a> Rust implementation plus a more detailed explanation for chicken</li> | |
| <li><a class="external autonumber" href="https://none-none1.github.io/Interpret-Esolangs-Online/chicken.js" rel="nofollow">[1]</a> Alternate JavaScript implementation</li> | |
| <li><a class="external text" href="https://github.com/none-None1/ChickenCS" rel="nofollow">none-None1/ChickenCS</a> C# implmentation for both Chicken and MiniChicken (In MiniChicken opcode <code>1</code> still prints <code>chicken</code>) <a class="external text" href="https://tio.run/##7RxrU9tI8ju/oqNUxVKwHRvIy46TEC@b5RJICsil6oC6GskD1kav0oPYt@G357pHki1bD0u2gUoKByJ7pmemX9Pd09NG8xqmbdk/fwaebl3C8djzudndSH5qHgYmd3XNm2vu24bBNV@3La/5nlsEMgex/2mu4YSP/OYRvwwM5u6NHJd7Hg3vbjx5vPEY@kNd@8Yt0C2fu9iJ/@N76D/EvmS3B8wC7tk@LVmHwdhipq4xwxiDP3b4AAxmXQbsktdB9z3R5oHKh@yKg6F/4/AvdsWONVd3fJx2dzDo4EO8Dr8cwPHJEbz79OkjfDn8Aw53D7GPmid94Yfdw6iPmsR/8W/8BvvENDnjaHbxUfThM9E3@ZjRR0sGammM4995jHP6Jhhn9E0wjn@zMM7ow5@DwPiFMH6ygQrFPYdpPFa6/vHGPxuEvdBNixmgGczz4LNrX7rMFF0hAL001GmfQAVCPWh14ckTsAJT5W4GEJHXg7YA8nwX90sGkKCzB1sCSrVtIwOG6O3BtgAJrAG/0C0@yMIKKe3BTogVszJR2u1/QJinAmYQmOa4Di6/4C7uJxuxZNq36TDBiohTk9YpO@jlBKqhaxF59OhmddPStF0zO6MFZGVuanrhhIitNCFa6qZAaF6EQR7N9l0XrRXjWxeYKTOgeVh4uWv7RSsjT/0ph9hgEC8@qseN40UI@O441ZaGohda18C1QH6nX@6jSl9yt/mZuR6XRwpsQqp1rCjNE/tYoCEraQKvUy0a87UhyH/arsn8vZHGHfIUSjX0pEN2KC1arYiNXqDeGRsbvw8bzcC4MzY@/pXZODF7gptxBGM73GW@7cKmHDchW@O3C/mqX4A8aoY2pSe8x48fME42VCTM4t8nFm/UJCu2ifPhsy4mK8PgBE6vI1zKIhHT7aOFHHUzQUbYNc7uGqftajaG3ndd6MCoEnIa8zh58U5mb/642VXlPI6Un6gcMtXmK1AD8j@jUAWEJih1WljplprzuhwlFNLcKimyIIX2iOS7AZeUN1Jb6kgtSamvnTiMM26BNmGS6hTQrRd7nPDXw764V3U5@5a/zPXGknpaZv/Dr2kAImcw3S/wBnDHQAdwz/wehmEBiSmLkey@CdLvzcZvYzYKRVnMgGWJLsCmUDS3hU26pcrclULrxhpCa8qnYGg9baDEyUysHUGMkxBKZYbFR6swfxCHXeEnYYC6CxAlg6nE49GmFdis7KnGc1ONl5sqIkRkQfDkPZoQkrms7D7oCb5kcszNs67VVKaKzjy@15k71RlKMyzQGZBdeNCDO1EbyroC0uQPx/LCVGAU91U@a4rYJ0Z2hpHd/EF4Sp8ZQxwqgqcQch6@VTSAfFk84IIZHu8We5oFsLl@gAjNM/rTd9H@/ah7/qtIlq/DnDQqEQl4pieZIYpGXtn6AA6YHid4T8@BuZeekpO8fvIEjn3uQLsD@5YT@DOdQitM3dK1yGD0sqiOtNwJ7wsgLZ8JIqQx4v4Bgf5BRf9ygCoqoYTpQdpBT5QHPZDVElzPTnRhY8SiDeN8nU5XaIK4bMulCwVrDKXS6Rrb8myDN7@6us8/6haXpcklSSfrDk/KCRGKJoLTC90QbDiH04Z5XmGOeCB1nww5TD779hSrOnzXDQO1jg3gwrVNUgxrwNwBgqCAiTOW7cOlfsWtCms3zGn3frwWhFegB6giU@54Pi1tX0wXjvoqrHZo@7wDX4diQsTaT2qY7UakROQNdKsO3BrA2A7iLrRRQ6i9rVVY80R3vA54SBW3rnTXtkxu@XDFXJ2pBof@X/v9D3uH//1j792X98Txge45BhvDgKsBKqN1YectFlqAaulVjCFItZsfuXWJpKAmtxZ6a0RXS6/yfYhqgr5Lw10Xk32EIpIVhazjs52y2yPm/6aY54q7fvPE7g@ZK2tKNeI4GpESocccA9plEY3HnrbOQxNgStnpifzDwazVS9vuEnxfgf/lDi/V5FF8kMpuTclpMWJTN/CnHhG6axhUHRGLJAe3MkeqTHyKdSChP1s3qgRlda68XPNY2D6vLN5CYa6OUev87hRubU57XY77rp337Tvwu3Lit@7Ii5x5GRuWuojWvjV3BwN55uQm1cMaFUXJjLMFa3rzMTb5oP5sU@x3@uX8TlY8QUJIe5d@YfIqHNULn7ggslZDoZy5ZxbF9WcpLcpmgxgeXtLOwcdHlq0OiDvzjXkznDDbi0icGrboXRmEFw0UwyBrVHSAgZkTTDzBsWPovlyDWj28/hefPzlhFeIRN@0rvmc6/njPwm7uKWWjoaxahWKTmqpK0PN8dlR8UFB2UNl477mu7XbgUJSUAR85XPP5YH07skDlwvzK@mPZhVqWo2Rl1OXMqpXWhKlcQbNojyYE/R/u2tksnDt1/01I6NHyqOa4R5dU12LVoJ38t0jfaLH3WTJ6yVeyWjR1baJndSQ3QC9Uk2ATSd0EqdD7LFK/4ogMhbC5ubre4jSJmqGllDjHFdE9YcZssQXe7sBRYKX8kO6Ias50KskNLItUKCuWjrwVjn0VYdNHQfhlMtQPonmVvBstAtqbhgLN99xPfPx3FBhgqJeMDCThJa3AMJZKH8nSscjaefr/MAgqn4ZI0l64H2GS0RdmQYxbZo/pieoqijqytssr0fW6aCescLqY5ZvezE6Q54@odWpV4AVJk1TkaUj/ug4wWYF3o1EhC7X/GbUF7c405oo2tu4oFbKNgetS0KvZpokxfDilUJFT3Tkv4HAyUPzAx@VKEOMbgdkFqlwNoKVZ@gp3YlTC3PQK19pUMrVsMUy2AY1dVxzIkun8yhGaTnlO4A0TLgg3cTLhYNoDDirXWICYmbbnT86yUQTgkedB10pf/eC@T/Xr4izl4@FyOutc1f166wCkraUZFhPD6EJV6E3C8kED2ufdEgwP44xdX54bvMgeRIurd7H4VFVU3JRsAfQKwtm@F85KwmncpHB27oWzknAe36Rwnt4LZwnhhMUO4nY374p@Jls@X0eizpeNiJmEV18wXWHwuVhoaYyiQhY12RBjNAf26NE82JuoqoHqQspgX4qCclQkBMHw2WOieEalt2p25cxiXogSmDWXPrKooIbl19Osq3ozJki9UYLUiCD19giartWSSAsnvJQSOolHWDrAkzJPmR3CT4YjmukB0e4Ly3PEid/hmk7fDkUL2YFWr1erlUKVNHuyc6Ilaenl9skq9a7ZMTqiVg9V4ub8ybOl/QnlUxgkU/D7lr@9JWeb9xJH55VsPGGj5mKjO5ulUCDlDUeo50Lper0w9bAOE/6q9eMHg9e9/CTSKpY185A3/WpuXTgAZVU1XrtDiNEOuc7OlZvdaGLL6xezQs79/t7KQqYVUOuim/57YWegncomJRlHClHPuGi7CbVYUfrrEUoxmmjGNm/MEzz/TTzB3Z8DUWtxbfXGJPXiXlJrCBjCwDsqLF/Z9jtUjcC6d/KdJ@nlb6IQOTb00cPMawdGfzRD6kqZpRhr4S6abhYY/noz7@m/tzB7OUF8aiX/1EI9vOesTkLGHwxIOZBZmPR9zRHiOZoUBeSrRR3eSmePzh6eDTbPSCRE8QGVYOxdMSOgL/rIgcU9jTlcScoq9f2CKEcQA8tiEpi5tZnlevQlhpR6zJcGpTTcTfC4eRyo4crylvhbG8m@qE6zAdtKBu7XG9c/f261AH924CW02/AcBQjtZ/SzA9viw/PoiT/bBNLegmfQosYdhNlqi@Znov8pvafOHWi/gC38Jyallq1o9nAwPrbpv2kDTvgS215E8G/f/myY/wc" rel="nofollow">Try it online!</a></li> | |
| <li><a class="external text" href="http://isotropic.org/papers/chicken.pdf" rel="nofollow">Chicken Chicken Chicken: Chicken Chicken</a> The reason this language was created.</li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20251119025808 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.041 seconds | |
| Real time usage: 0.086 seconds | |
| Preprocessor visited node count: 599/1000000 | |
| Post‐expand include size: 4992/2097152 bytes | |
| Template argument size: 1389/2097152 bytes | |
| Highest expansion depth: 7/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 23886/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 23.736 1 -total | |
| 34.58% 8.209 1 Template:Infobox_proglang | |
| 26.96% 6.398 39 Template:C | |
| 26.48% 6.286 1 Template:Cd | |
| 4.11% 0.976 2 Template:Wayback | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:8916-0!canonical and timestamp 20251119025808 and revision id 168658. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b>Come Here</b> is a programming language devised by <a href="/wiki/User:Smjg" title="User:Smjg">User:Smjg</a>. Its aim is to do away with the <code>GOTO</code> statement that is considered harmful by many people, but nonetheless is far too common in the world's languages. | |
| </p><p>To achieve this, the <code>GOTO</code> statement is replaced by <code>COME FROM</code>. Indeed, <code>COME FROM</code> is the only control flow statement in Come Here. Loops and conditionals must be simulated by using <code>COME FROM</code> with a computed argument. | |
| </p><p>The only data type is the integer. Strings are stored as their little-endian integer representations. There is no defined limit on the size of a Come Here integer. In the official implementation it is unlimited (except by the available memory, of course), but this is not a requirement. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Syntax_and_statement_semantics"><span class="tocnumber">1</span> <span class="toctext">Syntax and statement semantics</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Code_example"><span class="tocnumber">2</span> <span class="toctext">Code example</span></a></li> | |
| <li class="toclevel-1 tocsection-3"><a href="#Computational_class"><span class="tocnumber">3</span> <span class="toctext">Computational class</span></a></li> | |
| <li class="toclevel-1 tocsection-4"><a href="#External_link"><span class="tocnumber">4</span> <span class="toctext">External link</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Syntax_and_statement_semantics">Syntax and statement semantics</span></h2> | |
| <p>Each statement consists of an optional numeric label, a keyword (or in one case, two keywords), followed by one or more juxtaposed arguments. Whitespace is irrelevant. | |
| </p> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <th>Statement</th> | |
| <th>Description | |
| </th></tr> | |
| <tr> | |
| <td><code>NOTE <i>one or more tokens</i></code></td> | |
| <td>Comment | |
| </td></tr> | |
| <tr> | |
| <td><code>CALL <i>exp</i> <i>var</i></code></td> | |
| <td>Assigns value <i>exp</i> to variable <i>var</i>. | |
| </td></tr> | |
| <tr> | |
| <td><code>ASK <i>var</i></code></td> | |
| <td>Receives a line from stdin and stores it in <i>var</i>. | |
| </td></tr> | |
| <tr> | |
| <td><code>TELL <i>one or more values</i></code></td> | |
| <td>Writes the arguments in string form to stdout. | |
| </td></tr> | |
| <tr> | |
| <td><code>COME FROM <i>exp</i></code></td> | |
| <td>Transfers control here after the statement labelled <i>exp</i> is executed. | |
| </td></tr></tbody></table> | |
| <h2><span class="mw-headline" id="Code_example">Code example</span></h2> | |
| <p>The following program prints the message "Hello, world!" ten times. | |
| </p> | |
| <pre>10 CALL 10 count | |
| COME FROM 10 + SGN count | |
| TELL "Hello, world!" NEXT | |
| 11 CALL count - 1 count | |
| </pre> | |
| <p>The second line in this code takes the sign of the variable <i>count</i> (0-1, 0 or 1), and therefore comes from the statement labelled 9, 10 or 11 depending on the value of <i>count</i>. It is illegal to <code>COME FROM</code> a non-existent label, hence the dummy label 10. In this instance, <i>count</i> will never be negative; therefore there is no need for a statement to be labelled 9. | |
| </p> | |
| <h2><span class="mw-headline" id="Computational_class">Computational class</span></h2> | |
| <p>As long as the implementation places no limit on the size of the integer data type, Come Here is <a class="mw-redirect" href="/wiki/Turing_complete" title="Turing complete">Turing complete</a> since it can simulate a <a href="/wiki/Minsky_machine" title="Minsky machine">Minsky machine</a>. | |
| </p><p>Because Come Here has no built-in support for arrays or other data structures, such things must be encoded by using a defined number of integer variables. | |
| </p> | |
| <h2><span class="mw-headline" id="External_link">External link</span></h2> | |
| <ul><li><a class="external text" href="http://wwwep.stewartsplace.org.uk/languages/comehere/" rel="nofollow">The Come Here Programming Language</a></li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20250724015308 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.008 seconds | |
| Real time usage: 0.009 seconds | |
| Preprocessor visited node count: 15/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:1990-0!canonical and timestamp 20250724015308 and revision id 31583. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b>Convalescent</b> is a two-instruction esolang utilizing prime factors of integers. It was designed by <a href="/wiki/User:Keymaker" title="User:Keymaker">User:Keymaker</a> in <a href="/wiki/Category:2024" title="Category:2024">2024</a>. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Program_and_execution"><span class="tocnumber">1</span> <span class="toctext">Program and execution</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Translation_example"><span class="tocnumber">2</span> <span class="toctext">Translation example</span></a></li> | |
| <li class="toclevel-1 tocsection-3"><a href="#Computational_class"><span class="tocnumber">3</span> <span class="toctext">Computational class</span></a></li> | |
| <li class="toclevel-1 tocsection-4"><a href="#External_resources"><span class="tocnumber">4</span> <span class="toctext">External resources</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Program_and_execution">Program and execution</span></h2> | |
| <p>The program consists of two types of instructions <code>;</code> and <code>+</code>. Instructions are executed deterministically from the first to the last, and after executing the last the program pointer moves back to the first. The memory is an unordered list of non-negative integers. Initially the list has one instance of the the smallest <a class="new" href="/w/index.php?title=Prime&action=edit&redlink=1" title="Prime (page does not exist)">prime</a>, 2. There is also the accumulator, a non-negative integer, initially 0. The program halts if the memory becomes empty (which can only happen after executing the <code>+</code> instruction), or if the <code>+</code> instruction is executed when the accumulator is 0 or 1. | |
| The instructions are: | |
| </p> | |
| <ul><li><code>;</code> increases the accumulator by one.</li> | |
| <li><code>+</code> causes the following effect (although an interpreter may arrive at the same end result differently):</li></ul> | |
| <dl><dd>1. Get the prime factorization of the accumulator's value. If the accumulator is 0 or 1 the program halts instead.</dd> | |
| <dd>2. For every different value in the prime factorization, see if that type exists in the memory. If at least one instance is found in the memory, the instruction is considered successful.</dd> | |
| <dd>3. If even one instance was found, this (step 3) is executed, otherwise not. For each different type of value in the prime factorization, it is seen if there are instances of that type in the memory. If there are no existing instances, then all the instances in the prime factorization are added to the memory. In case one or more instances exist, one instance is removed from the memory, and n-1 (where n is the number of instances in the prime factorization) are added to the memory.</dd> | |
| <dd>4. If instruction was deemed successful in step 2 (even one instance of the prime factors was found to exist in the memory), the accumulator is set to 1, otherwise it is set to 0.</dd></dl> | |
| <p>Because the programs can become immensely large and unstorable, there is an alternative format that in addition to understanding <code>;</code> and <code>+</code> normally treats integers (positive, non-zero) written inside parentheses as that number of <code>;</code> instructions. | |
| </p> | |
| <h2><span class="mw-headline" id="Translation_example">Translation example</span></h2> | |
| <p>Here is a simple <a href="/wiki/Minsky_machine" title="Minsky machine">Minsky machine</a> program: | |
| </p> | |
| <pre>1 inc A 2 | |
| 2 inc A 3 | |
| 3 inc B 4 | |
| 4 inc B 5 | |
| 5 dec A 4 6 | |
| 6 halt | |
| </pre> | |
| <p>Run through the translator, this is the Convalescent translation in the alternative format: | |
| </p> | |
| <pre>(4)+(2277)+;;+ | |
| (697)+(205378)+(1926)+(1681)+(113692)+;;+ | |
| (1927)+(205378)+(2910)+(1681)+(171748)+;;+ | |
| (2911)+(2196)+(2172)+(1681)+(28248)+;;+ | |
| (2173)+(2196)+(1270)+(1681)+(16522)+;;+ | |
| (1271)+(58)+(2172)+(1681)+(1516)+;;+ | |
| (37)+(66)+;;+(4489)+;+ | |
| </pre> | |
| <h2><span class="mw-headline" id="Computational_class">Computational class</span></h2> | |
| <p>The language is <a href="/wiki/Turing-complete" title="Turing-complete">Turing-complete</a>, which is shown via Minsky Machine translation. See external resources. | |
| </p> | |
| <h2><span class="mw-headline" id="External_resources">External resources</span></h2> | |
| <ul><li><a class="external text" href="http://yiap.nfshost.com/esoteric/convalescent/convalescent.html" rel="nofollow">Convalescent information</a> (detailed explanations of the language and the MM translation, translator program, interpreter in Python)</li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20250724191610 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.011 seconds | |
| Real time usage: 0.012 seconds | |
| Preprocessor visited node count: 17/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:21455-0!canonical and timestamp 20250724191610 and revision id 148443. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b>Countable</b> is a <a href="/wiki/Turing_tarpit" title="Turing tarpit">Turing tarpit</a> based on <a href="/wiki/Iterate" title="Iterate">Iterate</a>'s accumulative model. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Memory"><span class="tocnumber">1</span> <span class="toctext">Memory</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Commands"><span class="tocnumber">2</span> <span class="toctext">Commands</span></a></li> | |
| <li class="toclevel-1 tocsection-3"><a href="#Completeness"><span class="tocnumber">3</span> <span class="toctext">Completeness</span></a></li> | |
| <li class="toclevel-1 tocsection-4"><a href="#Examples"><span class="tocnumber">4</span> <span class="toctext">Examples</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-5"><a href="#Cat"><span class="tocnumber">4.1</span> <span class="toctext">Cat</span></a></li> | |
| <li class="toclevel-2 tocsection-6"><a href="#Decrement"><span class="tocnumber">4.2</span> <span class="toctext">Decrement</span></a></li> | |
| <li class="toclevel-2 tocsection-7"><a href="#Subtraction"><span class="tocnumber">4.3</span> <span class="toctext">Subtraction</span></a></li> | |
| <li class="toclevel-2 tocsection-8"><a href="#Division"><span class="tocnumber">4.4</span> <span class="toctext">Division</span></a></li> | |
| <li class="toclevel-2 tocsection-9"><a href="#Equality"><span class="tocnumber">4.5</span> <span class="toctext">Equality</span></a></li> | |
| <li class="toclevel-2 tocsection-10"><a href="#Kolakoski_sequence"><span class="tocnumber">4.6</span> <span class="toctext">Kolakoski sequence</span></a></li> | |
| <li class="toclevel-2 tocsection-11"><a href="#A+B_problem"><span class="tocnumber">4.7</span> <span class="toctext">A+B problem</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-12"><a href="#Interpreter"><span class="tocnumber">5</span> <span class="toctext">Interpreter</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Memory">Memory</span></h2> | |
| <p>Countable consists of a set of accumulators, which can be created, incremented, and read from, with no additional interactions. All accumulators can store a single positive integer from 0 to infinity. | |
| </p> | |
| <h2><span class="mw-headline" id="Commands">Commands</span></h2> | |
| <p><i>n</i> and <i>x</i> refer to a numeric value, which can be a positive integer or infinity. Dereferencing may be done by prefixing a value with one or more <code>a</code>'s. Registers 0 and infinity are valid registers. | |
| </p> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <th>Command</th> | |
| <th>Action | |
| </th></tr> | |
| <tr> | |
| <td><code>x+n</code></td> | |
| <td>Increment accumulator <i>x</i> by <i>n</i>. <i>n</i> must be a positive integer, and may be omitted if it is equal to 1. | |
| </td></tr> | |
| <tr> | |
| <td><code>x*n< ... ></code></td> | |
| <td>Repeat the inner contents <i>n</i> times, with an optional label <i>x</i>. Multiple loops may share a label, and the label may be dynamic. | |
| </td></tr> | |
| <tr> | |
| <td><code>x&</code></td> | |
| <td>Jump to the end of label <i>x</i> if you are inside it, skipping to the next iteration of the loop. | |
| </td></tr> | |
| <tr> | |
| <td><code>x@</code></td> | |
| <td><i>(Optional)</i> Read a byte, storing it in accumulator <i>x</i>. | |
| </td></tr> | |
| <tr> | |
| <td><code>%n</code></td> | |
| <td><i>(Optional)</i> Output <i>n</i> modulo 256 as a byte. | |
| </td></tr></tbody></table> | |
| <h2><span class="mw-headline" id="Completeness">Completeness</span></h2> | |
| <p>Countable is Turing-complete. See <a href="/wiki/Countable/Turing-completeness_proof" title="Countable/Turing-completeness proof">Countable/Turing-completeness proof</a>. | |
| </p> | |
| <h2><span class="mw-headline" id="Examples">Examples</span></h2> | |
| <h3><span class="mw-headline" id="Cat">Cat</span></h3> | |
| <pre>1+2 // This will be used to track the current accumulator. | |
| 1*1< // Outer loop to act as a breaking mechanism | |
| 2*∞< // Actual read-write loop | |
| a1@ // Store input into the current accumulator | |
| *aa1< // If that input isn't zero... | |
| %aa1 // Print it | |
| 1+1 // Update the pointer to point to the next empty accumulator | |
| 2& // Skip the break | |
| > | |
| 1& // If the input is zero, break | |
| > | |
| > | |
| </pre> | |
| <h3><span class="mw-headline" id="Decrement">Decrement</span></h3> | |
| <pre>1+VALUE // Where VALUE is any numeric value | |
| 1*a1< // Increment a2 to equal a1 minus one | |
| *a3< // Doesn't run on the first step, since a3 == 0 then | |
| 2+1 // Increment a2 | |
| 1& // Skip more increments of a3 | |
| > | |
| 3+1 // Set a3 to 1 | |
| > | |
| </pre> | |
| <h3><span class="mw-headline" id="Subtraction">Subtraction</span></h3> | |
| <pre>5+VALUE1 // Value 1 | |
| 1+VALUE2 // Value 2 | |
| 2+5 // Value tracker | |
| 3+6 // Flag tracker | |
| 4+7 // Result tracker | |
| *a1< // Decrement loop | |
| 1*aa2< | |
| *aa3< | |
| a4+1 | |
| 1& | |
| > | |
| a3+1 | |
| > | |
| 2+2 | |
| 3+2 | |
| 4+2 | |
| > | |
| /* | |
| initial | |
| flag | |
| result -> initial | |
| flag | |
| result -> initial | |
| flag | |
| result -> ... | |
| */ | |
| </pre> | |
| <h3><span class="mw-headline" id="Division">Division</span></h3> | |
| <pre>1+VALUE1 // Value 1 | |
| 2+VALUE2 // Value 2 | |
| 3+0 // Result | |
| 4+6 // Equal flag | |
| 5+6 // Pointer | |
| 4+a1 // Move the equal flag to the value | |
| a4+1 // and set it | |
| /* | |
| Example: 7 / 3 | |
| = = = = = = = = | |
| 0 0 0 0 0 0 0 1 | |
| \ _ / \ _ / \ _ | |
| 0 0 0 1 1 1 2 2 | |
| */ | |
| 1*1< | |
| *∞< // Repeatedly increment until the value is met | |
| *a2< // Division | |
| *aa5< // Is the current value equal? | |
| 1& // Exit | |
| > | |
| 5+1 // Otherwise, keep going | |
| > | |
| 3+1 // Every N steps, count up the result by one | |
| > | |
| > | |
| </pre> | |
| <h3><span class="mw-headline" id="Equality">Equality</span></h3> | |
| <pre>1+VALUE1 // value 1 | |
| 2+VALUE2 // value 2 | |
| 3+5 // ruler | |
| 4+5 // pointer | |
| // A B r p < = < = < = ... < = > ... | |
| // a b 5 5 1 0 1 0 1 0 ... 0 1 0 ... | |
| *a1< // the ruler creates a set of two pointers for each value 0 to value 1 | |
| a3+1 // all values less than value 1 have a lesser flag set | |
| 3+2 // and their equal flag is unset | |
| > | |
| 3+1 // the last value has the lesser flag unset | |
| a3+1 // and the equal flag set | |
| *a2< // the pointer will travel rightwards N times | |
| 4+2 | |
| > | |
| 1*1< | |
| *aa4< // if it lands on a pair with the lesser flag set | |
| %76 %101 %115 %115 // it is less | |
| 1& | |
| > | |
| 4+1 // now checking equal flag... | |
| *aa4< // if it lands on a pair with the equal flag set | |
| %69 %113 %117 %97 %108 // it is equal | |
| 1& | |
| > | |
| %71 %114 %101 %97 %116 %101 %114 // otherwise it is greater | |
| > | |
| </pre> | |
| <p>Inequality can also be checked by using labels, however may be unsafe if improperly managed. | |
| </p> | |
| <pre>1+VALUE1 | |
| 2+VALUE2 | |
| a1*< | |
| a2& | |
| // this portion runs only if a1 ≠ a2 | |
| > | |
| </pre> | |
| <p>The check above can be used to set one accumulator to equal another, assuming the value you want to equal is greater than your current value. | |
| </p> | |
| <pre>1+VALUE1 | |
| 2+VALUE2 | |
| a1*1< | |
| *∞< | |
| a2& | |
| 2+1 | |
| > | |
| > | |
| </pre> | |
| <h3><span class="mw-headline" id="Kolakoski_sequence"><a href="/wiki/Kolakoski_sequence" title="Kolakoski sequence">Kolakoski sequence</a></span></h3> | |
| <pre>1+3 // Current digit | |
| 2+3 // End of stack | |
| 3+1 // Kolakoski digit 3 (2 is stored as 1 for ease of processing) | |
| %49 %50 // 1, 2 | |
| *∞< | |
| 1*1< | |
| *aa1< // if the current digit is 2... | |
| *aa2< // if the last digit is 2... | |
| 2+2 // set next 2 digits to 1 | |
| 1& | |
| > // else... | |
| *2< // if the last digit is 1... | |
| 2+1 // set next 2 digits to 2 | |
| a2+1 // ^^^ | |
| > | |
| 1& | |
| > // else... | |
| *1< // if the current digit is 1... | |
| *aa2< // if the last digit is 2... | |
| 2+1 // set next digits to 1 | |
| 1& | |
| > // else if the last digit is 1... | |
| 2+1 // set next digits to 2 | |
| a2+1 // ^^^ | |
| > | |
| > | |
| a1+49 // move the current digit to its corresponding character | |
| %aa1 // print it | |
| 1+1 // advance to the next digit | |
| > | |
| </pre> | |
| <h3><span id="A.2BB_problem"></span><span class="mw-headline" id="A+B_problem"><a class="mw-redirect" href="/wiki/A%2BB_problem" title="A+B problem">A+B problem</a></span></h3> | |
| <p>This program showcases multiple constructs and procedures in one. | |
| </p> | |
| <pre>// populating lookup table | |
| 256+48 256+48 | |
| a256+1 256+1 a256+0 256+1 | |
| a256+1 256+1 a256+1 256+1 | |
| a256+1 256+1 a256+2 256+1 | |
| a256+1 256+1 a256+3 256+1 | |
| a256+1 256+1 a256+4 256+1 | |
| a256+1 256+1 a256+5 256+1 | |
| a256+1 256+1 a256+6 256+1 | |
| a256+1 256+1 a256+7 256+1 | |
| a256+1 256+1 a256+8 256+1 | |
| a256+1 256+1 a256+9 256+1 | |
| // 257 = number A | |
| // 258 = number B | |
| 259+271 // previous value | |
| 260+274 // cur value | |
| 261+275 // input | |
| 262+276 // lookup | |
| 263+256 // current number | |
| 1*2< | |
| 263+1 // advance to next number | |
| 2*∞< | |
| a261@ // get input | |
| *aa261< // find the corresponding value in the lookup table | |
| a262+2 | |
| > | |
| *aaa262< // is it a number? | |
| a262+1 // get the literal value | |
| *10< // multiply the last value by 10 | |
| a260+aa259 | |
| > | |
| a260+aaa262 // append the new digit | |
| 259+3 | |
| 260+3 | |
| 261+3 | |
| 262+3 | |
| 2& | |
| > | |
| a263+aa259 // if not, output the result | |
| 259+3 | |
| 260+3 | |
| 261+3 | |
| 262+3 | |
| 1& | |
| > | |
| > | |
| 264+a262 264+1 // previous current value | |
| a264+a257 a264+a258 // A + B | |
| 265+a262 265+2 // previous reversed value | |
| 266+a262 266+aa264 266+aa264 266+1 // current value | |
| 267+a262 267+aa264 267+aa264 267+2 // reversed value | |
| 268+a262 268+aa264 268+aa264 268+4 // equal flag | |
| 269+a262 269+aa264 269+aa264 269+3 // previous mod | |
| 270+a262 270+aa264 270+aa264 270+4 // pointer | |
| // reverse the result for printing | |
| 0*1< | |
| *∞< | |
| 1*1< | |
| *aa264< | |
| *aa264< // move the equal flag to the end | |
| 268+2 | |
| > | |
| 1& // check if current value isn't zero here | |
| > | |
| 0& // otherwise the first step is done | |
| > | |
| a268+1 // set it | |
| a269+9 // for modulo calculation | |
| 10*1< | |
| *∞< // calculate division + mod | |
| *10< | |
| *aa270< | |
| 10& | |
| > | |
| 270+1 | |
| 9*1< | |
| 0*1< // preventing early exit | |
| aa269& // check if mod will surpass 10 | |
| > | |
| a270+aa269 a270+1 // increment otherwise | |
| > | |
| 270+1 | |
| 269+2 | |
| > | |
| a266+1 | |
| > | |
| > | |
| 270+1 | |
| 9*1< // one last pass | |
| 0*1< // preventing early exit | |
| aa269& // check if mod will surpass 10 | |
| > | |
| a270+aa269 a270+1 // increment otherwise | |
| > | |
| *10< // push to the reversed string | |
| a267+aa265 | |
| > | |
| a267+aa270 | |
| // shift right | |
| 268+5 | |
| 269+5 | |
| 270+4 | |
| a266*1< // move last reverse pointer to current value pointer | |
| *∞< | |
| a265& | |
| 265+1 | |
| > | |
| > | |
| 266+aa264 266+aa264 266+5 | |
| 267+aa264 267+aa264 267+5 | |
| a265*1< // move last value pointer to last reverse pointer | |
| *∞< | |
| a264& | |
| 264+1 | |
| > | |
| > | |
| 265+1 | |
| > | |
| > | |
| // output the result (same logic as before) | |
| a264+aa265 | |
| 0*1< | |
| *∞< | |
| 1*1< | |
| *aa264< | |
| *aa264< // move the equal flag to the end | |
| 268+2 | |
| > | |
| 1& // check if current value isn't zero here | |
| > | |
| 0& // otherwise the first step is done | |
| > | |
| a268+1 // set it | |
| a269+9 // for modulo calculation | |
| 10*1< | |
| *∞< // calculate division + mod | |
| *10< | |
| *aa270< | |
| 10& | |
| > | |
| 270+1 | |
| 9*1< | |
| 0*1< // preventing early exit | |
| aa269& // check if mod will surpass 10 | |
| > | |
| a270+aa269 a270+1 // increment otherwise | |
| > | |
| 270+1 | |
| 269+2 | |
| > | |
| a266+1 | |
| > | |
| > | |
| 270+1 | |
| 9*1< // one last pass | |
| 0*1< // preventing early exit | |
| aa269& // check if mod will surpass 10 | |
| > | |
| a270+aa269 a270+1 // increment otherwise | |
| > | |
| a270+48 | |
| %aa270 // output digit | |
| // shift right | |
| 268+5 | |
| 269+5 | |
| 270+4 | |
| a266*1< // move last reverse pointer to current value pointer | |
| *∞< | |
| a265& | |
| 265+1 | |
| > | |
| > | |
| 266+aa264 266+aa264 266+5 | |
| 267+aa264 267+aa264 267+5 | |
| a265*1< // move last value pointer to last reverse pointer | |
| *∞< | |
| a264& | |
| 264+1 | |
| > | |
| > | |
| 265+1 | |
| > | |
| > | |
| </pre> | |
| <h2><span class="mw-headline" id="Interpreter">Interpreter</span></h2> | |
| <ul><li><a class="external free" href="http://github.com/aadenboy/EsolangInterpreters/blob/main/Countable/interpreter.lua" rel="nofollow">http://github.com/aadenboy/EsolangInterpreters/blob/main/Countable/interpreter.lua</a></li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20260205233855 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.012 seconds | |
| Real time usage: 0.048 seconds | |
| Preprocessor visited node count: 84/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 7821/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:24572-0!canonical and timestamp 20260205233855 and revision id 175135. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><br/> | |
| Cowlang is an esoteric programming language written by <a class="new" href="/w/index.php?title=User:Treeplate&action=edit&redlink=1" title="User:Treeplate (page does not exist)">User:Treeplate</a> for the second truttle1 practical programming language jam, in February 2025. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Tokens"><span class="tocnumber">1</span> <span class="toctext">Tokens</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-2"><a href="#String"><span class="tocnumber">1.1</span> <span class="toctext">String</span></a></li> | |
| <li class="toclevel-2 tocsection-3"><a href="#Integers"><span class="tocnumber">1.2</span> <span class="toctext">Integers</span></a></li> | |
| <li class="toclevel-2 tocsection-4"><a href="#Symbols"><span class="tocnumber">1.3</span> <span class="toctext">Symbols</span></a></li> | |
| <li class="toclevel-2 tocsection-5"><a href="#Comments"><span class="tocnumber">1.4</span> <span class="toctext">Comments</span></a></li> | |
| <li class="toclevel-2 tocsection-6"><a href="#=_Whitespace"><span class="tocnumber">1.5</span> <span class="toctext">= Whitespace</span></a></li> | |
| <li class="toclevel-2 tocsection-7"><a href="#Identifiers"><span class="tocnumber">1.6</span> <span class="toctext">Identifiers</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-8"><a href="#Parsing"><span class="tocnumber">2</span> <span class="toctext">Parsing</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-9"><a href="#Statements"><span class="tocnumber">2.1</span> <span class="toctext">Statements</span></a> | |
| <ul> | |
| <li class="toclevel-3 tocsection-10"><a href="#Next_token_is_("><span class="tocnumber">2.1.1</span> <span class="toctext">Next token is (</span></a></li> | |
| <li class="toclevel-3 tocsection-11"><a href="#Next_token_is_<"><span class="tocnumber">2.1.2</span> <span class="toctext">Next token is <</span></a></li> | |
| <li class="toclevel-3 tocsection-12"><a href="#Starting_with_identifier_if"><span class="tocnumber">2.1.3</span> <span class="toctext">Starting with identifier if</span></a></li> | |
| <li class="toclevel-3 tocsection-13"><a href="#Starting_with_identifier_loop"><span class="tocnumber">2.1.4</span> <span class="toctext">Starting with identifier loop</span></a></li> | |
| <li class="toclevel-3 tocsection-14"><a href="#Other"><span class="tocnumber">2.1.5</span> <span class="toctext">Other</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-2 tocsection-15"><a href="#Expressions"><span class="tocnumber">2.2</span> <span class="toctext">Expressions</span></a></li> | |
| <li class="toclevel-2 tocsection-16"><a href="#RTL"><span class="tocnumber">2.3</span> <span class="toctext">RTL</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-17"><a href="#Examples"><span class="tocnumber">3</span> <span class="toctext">Examples</span></a></li> | |
| <li class="toclevel-1 tocsection-18"><a href="#Implementation"><span class="tocnumber">4</span> <span class="toctext">Implementation</span></a></li> | |
| </ul> | |
| </div> | |
| <h1><span class="mw-headline" id="Tokens">Tokens</span></h1> | |
| <p>There are 4 types of tokens. | |
| </p> | |
| <h2><span class="mw-headline" id="String">String</span></h2> | |
| <p>Strings are <code>'</code>-delimited with no escapes. | |
| </p> | |
| <h2><span class="mw-headline" id="Integers">Integers</span></h2> | |
| <p>Integers are sequences of the following characters: <code>0123456789</code>. This is required to fit in 63 bits. | |
| </p> | |
| <h2><span class="mw-headline" id="Symbols">Symbols</span></h2> | |
| <p>Symbols are the following characters: <code>[]()+-*/%&|^<</code>. | |
| </p> | |
| <h2><span class="mw-headline" id="Comments">Comments</span></h2> | |
| <p><code>//</code> denotes the start of a comment, which ends at the first newline (0xa) that isn't preceded by a <code>\</code>. | |
| </p> | |
| <h2><span id=".3D_Whitespace"></span><span class="mw-headline" id="=_Whitespace">= Whitespace</span></h2> | |
| <p>Spaces (0x20), tabs (0x9), carriage returns (0xd), and newlines (0xa) are ignored. | |
| </p> | |
| <h2><span class="mw-headline" id="Identifiers">Identifiers</span></h2> | |
| <p>Any other character marks the start of an identifier, which ends at a space, tab, carriage return, newline, or any of the following characters: <code>[]()+-*/%&|^<</code>. | |
| </p> | |
| <h1><span class="mw-headline" id="Parsing">Parsing</span></h1> | |
| <h2><span class="mw-headline" id="Statements">Statements</span></h2> | |
| <p>These tokens are parsed into a set of statements, which are parsed the following way: | |
| === Starting with identifier <code>def</code> | |
| Parse an identifier (the name). | |
| </p> | |
| <h4><span id="Next_token_is_.28"></span><span class="mw-headline" id="Next_token_is_(">Next token is <code>(</code></span></h4> | |
| <p>Parse identifiers until you get to a <code>)</code> (the parameters). | |
| Parse statements until you get to an identifier `end` (the body). | |
| The statement is declaring a function. | |
| </p> | |
| <h4><span id="Next_token_is_.3C"></span><span class="mw-headline" id="Next_token_is_<">Next token is <code><</code></span></h4> | |
| <p>Parse an expression. | |
| The statement is evaluating the expression and assigning it to a new variable. | |
| </p> | |
| <h3><span class="mw-headline" id="Starting_with_identifier_if">Starting with identifier <code>if</code></span></h3> | |
| <p>First, parse an expression (the condition). | |
| Then, parse statements until there is an identifier <code>end</code>. (the block). | |
| The statement is executing the block only if the condition evaluates to 0. | |
| </p> | |
| <h3><span class="mw-headline" id="Starting_with_identifier_loop">Starting with identifier <code>loop</code></span></h3> | |
| <p>First, parse an expression (the condition). | |
| Then, parse statements until there is an identifier <code>end</code>. (the block). | |
| The statement is repeatedly executing the block until the condition does not evaluate to 0. | |
| </p> | |
| <h3><span class="mw-headline" id="Other">Other</span></h3> | |
| <p>First, parse an expression. | |
| If that expression is assignable (indexing or variable) and the next token is <code><</code>, parse another expression. The statement is assigning the second expression to the first expression. | |
| Otherwise, the statement is evaluating the expression. | |
| </p> | |
| <h2><span class="mw-headline" id="Expressions">Expressions</span></h2> | |
| <p>The following table lists the precedence of expressions. Expressions are listed top to bottom, in descending precedence. In case of precedence tie, expressions are right-associative. a, b and c are operands. | |
| </p> | |
| <ul><li><code>a | b</code> (bitwise or)</li> | |
| <li><code>a ^ b</code> (bitwise xor)</li> | |
| <li><code>a & b</code> (bitwise and)</li> | |
| <li><code>a * b</code> (multiply), <code>a / b</code> (divide and floor), <code>a % b</code> (modulus)</li> | |
| <li><code>a + b</code> (add), <code>a - b</code> (subtract)</li> | |
| <li><code>a[b]</code> (indexing into a list), <code>a(b c)</code> (function call)</li> | |
| <li>identifiers (<code>variable</code>), strings, lists (<code>[a b c]</code>) and integers</li></ul> | |
| <h2><span class="mw-headline" id="RTL">RTL</span></h2> | |
| <ul><li><code>print(str)</code> (prints str)</li> | |
| <li><code>intToStr(int)</code> (converts int to str)</li> | |
| <li><code>random(int)</code> (returns an integer between 0 (incl.) and int (excl.))</li> | |
| <li><code>input()</code> (returns line of stdin)</li> | |
| <li><code>strToInt(str)</code> (parses str as an integer)</li> | |
| <li><code>positive(int)</code> (returns 0 if int is positive and 1 otherwise)</li> | |
| <li><code>readFile(str)</code> (reads file str)</li> | |
| <li><code>split(str, int)</code> (splits str into a list of strings that are separated by the character int in str)</li> | |
| <li><code>length(list)</code> (returns length of list)</li> | |
| <li><code>list(int)</code> (returns a list with int zeros)</li> | |
| <li><code>addTo(list, element)</code> (adds element to end of list)</li> | |
| <li><code>addToAt(list, index, element)</code> (adds element to list at index)</li> | |
| <li><code>popFrom(list, element)</code> (pops element from end of list)</li> | |
| <li><code>popFromAt(list, index, element)</code> (pops element from list at index)</li></ul> | |
| <h1><span class="mw-headline" id="Examples">Examples</span></h1> | |
| <p>Fibonacci | |
| </p> | |
| <pre>def fib(i) | |
| def resultNotAssigned < 0 | |
| if i | |
| result < 0 | |
| resultNotAssigned < 1 | |
| end | |
| if 1-i | |
| result < 1 | |
| resultNotAssigned < 1 | |
| end | |
| if resultNotAssigned | |
| result < fib(i-1) + fib(i-2) | |
| end | |
| end | |
| print(intToStr(fib(0))) | |
| print(intToStr(fib(1))) | |
| print(intToStr(fib(6))) | |
| print(intToStr(fib(20))) | |
| </pre> | |
| <p>prints "pass" | |
| <code> | |
| print('PASS') | |
| </code> | |
| </p> | |
| <h1><span class="mw-headline" id="Implementation">Implementation</span></h1> | |
| <p><a class="external free" href="https://github.com/treeplate/cowlang" rel="nofollow">https://github.com/treeplate/cowlang</a> | |
| </p> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20250724055638 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.013 seconds | |
| Real time usage: 0.030 seconds | |
| Preprocessor visited node count: 56/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:22338-0!canonical and timestamp 20250724055638 and revision id 156392. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><br/> | |
| <b>dotcomma</b> is a simple esolang designed and first implemented by CGCC user <a class="external text" href="https://codegolf.stackexchange.com/users/79857/redwolf-programs" rel="nofollow">Redwolf Programs</a>. It was designed to have as few instructions as possible, while still being interesting. It is based around blocks and operators, with the only two operators (<code>.</code> and <code>,</code>) having a number of unique purposes depending on context. | |
| </p><p>Information in dotcomma, represented as signed integers, can be stored either through the return values of blocks and operators, or with a queue. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Blocks"><span class="tocnumber">1</span> <span class="toctext">Blocks</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#The_._operator"><span class="tocnumber">2</span> <span class="toctext">The . operator</span></a></li> | |
| <li class="toclevel-1 tocsection-3"><a href="#The_,_operator"><span class="tocnumber">3</span> <span class="toctext">The , operator</span></a></li> | |
| <li class="toclevel-1 tocsection-4"><a href="#The_Queue"><span class="tocnumber">4</span> <span class="toctext">The Queue</span></a></li> | |
| <li class="toclevel-1 tocsection-5"><a href="#Format"><span class="tocnumber">5</span> <span class="toctext">Format</span></a></li> | |
| <li class="toclevel-1 tocsection-6"><a href="#Examples"><span class="tocnumber">6</span> <span class="toctext">Examples</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-7"><a href="#Output_0:"><span class="tocnumber">6.1</span> <span class="toctext">Output 0:</span></a></li> | |
| <li class="toclevel-2 tocsection-8"><a href="#Output_1:"><span class="tocnumber">6.2</span> <span class="toctext">Output 1:</span></a></li> | |
| <li class="toclevel-2 tocsection-9"><a href="#Output_2:"><span class="tocnumber">6.3</span> <span class="toctext">Output 2:</span></a></li> | |
| <li class="toclevel-2 tocsection-10"><a href="#(Don't)_output_-1:"><span class="tocnumber">6.4</span> <span class="toctext">(Don't) output -1:</span></a></li> | |
| <li class="toclevel-2 tocsection-11"><a href="#Infinite_loop:"><span class="tocnumber">6.5</span> <span class="toctext">Infinite loop:</span></a></li> | |
| <li class="toclevel-2 tocsection-12"><a href="#Add_two_numbers:"><span class="tocnumber">6.6</span> <span class="toctext">Add two numbers:</span></a></li> | |
| <li class="toclevel-2 tocsection-13"><a href="#Truth-machine:"><span class="tocnumber">6.7</span> <span class="toctext">Truth-machine:</span></a></li> | |
| <li class="toclevel-2 tocsection-14"><a href="#Subtract_two_numbers:"><span class="tocnumber">6.8</span> <span class="toctext">Subtract two numbers:</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-15"><a href="#Other"><span class="tocnumber">7</span> <span class="toctext">Other</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Blocks">Blocks</span></h2> | |
| <p>A block is any section of code that is wrapped in matching brackets <code>[</code> and <code>]</code>, such as <code>[.]</code> or <code>[.[[,.],],]</code>. Blocks can be nested arbitrarily deep. Every block has a return value, which defaults to <code>0</code>. This can be changed or read with operators. | |
| </p><p>By default, a block only acts as a container for code and does not affect control flow in any way. The whole program is wrapped in a block by the interpreter. | |
| </p> | |
| <h2><span class="mw-headline" id="The_._operator">The <code>.</code> operator</span></h2> | |
| <p>The <code>.</code> operator is mainly used for representing constants, reading from blocks, adding numbers, and creating loops. | |
| </p><p>Its return value depends on what it is immediately preceded by: | |
| </p> | |
| <ul><li><b>Any number of blocks:</b> The sum of the return values of the blocks for each time they are evaluated</li> | |
| <li><b>An operator:</b> The return value of the operator</li> | |
| <li><b>The beginning of a block (<code>[</code>):</b> <code>1</code></li></ul> | |
| <p>What it does with this return value depends on what it is immediately followed by: | |
| </p> | |
| <ul><li><b>A block:</b> If its return value is <code>0</code>, the block is ignored. Otherwise, the block is evaluated until its return value is <code>0</code></li> | |
| <li><b>The end of a block (<code>]</code>):</b> Its return value is used as the block's return value</li></ul> | |
| <h2><span id="The_.2C_operator"></span><span class="mw-headline" id="The_,_operator">The <code>,</code> operator</span></h2> | |
| <p>The <code>,</code> operator is mainly used for managing the queue, or for various control flow purposes. | |
| </p><p>Its return value depends on what it is immediately preceded by: | |
| </p> | |
| <ul><li><b>A block:</b> The return value of the last time the block was evaluated, or <code>-1</code> if it never evaluated</li> | |
| <li><b>An operator:</b> The return value of the operator</li> | |
| <li><b>The beginning of a block (<code>[</code>):</b> The front of the queue (which is then removed, similar to popping from a stack), or <code>-1</code> if it is empty</li></ul> | |
| <p>What it does with this return value depends on what it is immediately followed by: | |
| </p> | |
| <ul><li><b>A block:</b> If its return value is negative, the block is ignored</li> | |
| <li><b>The end of a block (<code>]</code>):</b> Its return value is used as the block's return value, as well as being added to the back of the queue</li></ul> | |
| <h2><span class="mw-headline" id="The_Queue">The Queue</span></h2> | |
| <p>A <a class="external text" href="https://computersciencewiki.org/index.php/Queue" rel="nofollow">queue</a> is a way of storing information similar to a stack. While a stack is a Last-In-First-Out data structure, a queue is a First-In-First-Out structure. This means an items at the back of the queue (the most recent added) will not be read until every item in front of it is removed. | |
| </p><p>The queue starts out containing all input to the program, with the first input at the front of the queue. The state of the queue when the program ends is used as output, with the front of the queue being the first item outputted. | |
| </p> | |
| <h2><span class="mw-headline" id="Format">Format</span></h2> | |
| <p>Any characters other than <code>[.,]</code> will be ignored. Any brackets must be balanced. | |
| </p> | |
| <h2><span class="mw-headline" id="Examples">Examples</span></h2> | |
| <h3><span class="mw-headline" id="Output_0:">Output <code>0</code>:</span></h3> | |
| <pre> [], | |
| </pre> | |
| <p>This program evaluates an empty block, with its return value (defaulting to <code>0</code>) being read by the <code>,</code>. The <code>,</code> is followed by the end of the program (treated as the end of a block), so the result will be outputed. | |
| </p> | |
| <h3><span class="mw-headline" id="Output_1:">Output <code>1</code>:</span></h3> | |
| <pre> [.], | |
| </pre> | |
| <p>This program is similar to the first. However, the <code>.</code>'s return value will be <code>1</code> (as it's preceded by the beginning of the block), so it will set the block's return value to <code>1</code> (which is read and outputted by <code>,</code>). | |
| </p> | |
| <h3><span class="mw-headline" id="Output_2:">Output <code>2</code>:</span></h3> | |
| <pre> [.][.]., | |
| </pre> | |
| <p>This program is a bit more interesting. The <code>[.]</code> (return value <code>1</code>) block is repeated twice, and the sum of the two is read with the last <code>.</code> (note that it, unlike the <code>,</code> operator, takes the sum of every return value of every block directly before it). The <code>,</code> will take the <code>.</code>'s return value and output it. | |
| </p> | |
| <h3><span id=".28Don.27t.29_output_-1:"></span><span class="mw-headline" id="(Don't)_output_-1:">(Don't) output <code>-1</code>:</span></h3> | |
| <pre> [].[], | |
| </pre> | |
| <p>This program is the first so far that uses control flow. The first empty block has a return value of <code>0</code>, so the <code>.</code> will cause the second empty block to not be evaluated. Because the <code>,</code> operator reads the return value of the previous block's last evaluation, which was never, it will return <code>-1</code>. Importantly, if you replaced the <code>,</code> with a <code>.,</code>, the program would output <code>0</code> as the <code>.</code> operator will consider a block that has never been evaluated to have a return value of <code>0</code> (otherwise, adding the return value of multiple blocks could work in unintended ways if one of them is ignored or looped). | |
| </p><p>It doesn't output anything, because attempting to add a negative value to the queue does nothing. | |
| </p> | |
| <h3><span class="mw-headline" id="Infinite_loop:">Infinite loop:</span></h3> | |
| <pre> .[.] | |
| </pre> | |
| <p>Both <code>.</code>'s return values will be <code>1</code> (because they is preceded by the beginning of the program or a block), and the block will be looped infinitely as it always returns <code>1</code>. | |
| </p> | |
| <h3><span class="mw-headline" id="Add_two_numbers:">Add two numbers:</span></h3> | |
| <pre> [,.][,.]., | |
| </pre> | |
| <p>This program is very similar to <i>output <code>2</code></i>, but uses two <code>[,.]</code> blocks instead of <code>[.]</code>. This will take input (<code>,</code>), and use it as the block's return value (<code>.</code>). You could also use <code>[,]</code>, but this would add the two inputs back into the queue (as the <code>,</code> is followed by the end of the block). | |
| </p> | |
| <h3><span class="mw-headline" id="Truth-machine:"><a href="/wiki/Truth-machine" title="Truth-machine">Truth-machine</a>:</span></h3> | |
| <pre> [,].[.,] | |
| </pre> | |
| <p>This program is actually a pretty elegant display of many of dotcomma's features. The <code>[,]</code> block will take a number from the queue, re-add it, and assign it to the block's return value. If it is not <code>0</code>, the block <code>[.,]</code> (push <code>1</code> to the queue) will be looped infinitely. | |
| </p> | |
| <h3><span class="mw-headline" id="Subtract_two_numbers:">Subtract two numbers:</span></h3> | |
| <pre> [[,]][,] | |
| .[ | |
| [ | |
| [,.][[].[],]., | |
| ] | |
| [ | |
| [,.][[].[],]. | |
| ], | |
| ] | |
| [,][,.] | |
| </pre> | |
| <p>As this is the most complicated program so far, it's broken up into chunks. The first line, <code>[[,]][,]</code>, will return the value of the second item in the queue, assuming there are two. This is to ensure the second number (the one being subtracted from the first) isn't <code>0</code>. | |
| </p><p>Next is a loop consisting of two parts, which each decrement one of the items in the queue. The output of the second is also used as the loop block's return value, so that when it reaches <code>0</code> the loop ends. The final <code>[,][,.]</code> will remove the second item in the queue (the remaining <code>0</code>), leaving only the answer. | |
| </p> | |
| <h2><span class="mw-headline" id="Other">Other</span></h2> | |
| <p>Interpreter: <a class="external free" href="https://github.com/Radvylf/dotcomma" rel="nofollow">https://github.com/Radvylf/dotcomma</a> | |
| </p> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20250806131313 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.020 seconds | |
| Real time usage: 0.024 seconds | |
| Preprocessor visited node count: 100/1000000 | |
| Post‐expand include size: 16/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 5/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 247/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 1.409 1 Template:Lowercase | |
| 100.00% 1.409 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:13777-0!canonical and timestamp 20250806131333 and revision id 162949. Rendering was triggered because: edit-page | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b>DownRight</b> is an <a href="/wiki/Esoteric_programming_language" title="Esoteric programming language">esoteric programming language</a> created by <a href="/wiki/User:Ais523" title="User:Ais523">User:ais523</a> in <a href="/wiki/Category:2010" title="Category:2010">2010</a>, although the details of the syntax were not finished until <a href="/wiki/Category:2011" title="Category:2011">2011</a>. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Semantics"><span class="tocnumber">1</span> <span class="toctext">Semantics</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Syntax"><span class="tocnumber">2</span> <span class="toctext">Syntax</span></a></li> | |
| <li class="toclevel-1 tocsection-3"><a href="#Computational_class"><span class="tocnumber">3</span> <span class="toctext">Computational class</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-4"><a href="#Simpler_proof"><span class="tocnumber">3.1</span> <span class="toctext">Simpler proof</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-5"><a href="#Languages/systems_that_translate_into_DownRight"><span class="tocnumber">4</span> <span class="toctext">Languages/systems that translate into DownRight</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-6"><a href="#Tag_system_into_DownRight"><span class="tocnumber">4.1</span> <span class="toctext">Tag system into DownRight</span></a></li> | |
| <li class="toclevel-2 tocsection-7"><a href="#Cyclic_Tag_into_DownRight"><span class="tocnumber">4.2</span> <span class="toctext">Cyclic Tag into DownRight</span></a></li> | |
| <li class="toclevel-2 tocsection-8"><a href="#Minsky_Machine_into_DownRight"><span class="tocnumber">4.3</span> <span class="toctext">Minsky Machine into DownRight</span></a></li> | |
| <li class="toclevel-2 tocsection-9"><a href="#Miserie_into_DownRight"><span class="tocnumber">4.4</span> <span class="toctext">Miserie into DownRight</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-10"><a href="#DownRight_into_Cyclic_Tag"><span class="tocnumber">5</span> <span class="toctext">DownRight into Cyclic Tag</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-11"><a href="#Translation_example"><span class="tocnumber">5.1</span> <span class="toctext">Translation example</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-12"><a href="#Note_on_a_future_interpreter"><span class="tocnumber">6</span> <span class="toctext">Note on a future interpreter</span></a></li> | |
| <li class="toclevel-1 tocsection-13"><a href="#Implementations_and_relevant_software"><span class="tocnumber">7</span> <span class="toctext">Implementations and relevant software</span></a></li> | |
| <li class="toclevel-1 tocsection-14"><a href="#See_also"><span class="tocnumber">8</span> <span class="toctext">See also</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Semantics">Semantics</span></h2> | |
| <p>A DownRight program is a two-dimensional matrix of possibly empty strings, the instructions, where the alphabet for the strings consists of only two symbols, "down" and "right". Program execution uses nothing but the program (which never changes), the instruction pointer (starting out at the first, i.e. top-left, cell) and one queue (the only place data is stored), which also contains only "down" and "right" (single symbols this time, not strings). The queue starts out initialised with the contents of the first cell. Program execution proceeds by repeatedly removing symbols from the front of the queue and moving the instruction pointer down or right according to the symbol removed (wrapping both vertically and horizontally, treating the program as a torus). Whenever the IP moves onto an instruction, it is pushed character-by-character onto the back of the queue. If the queue is empty when an attempt is made to remove a symbol from it, the program halts. | |
| </p><p>In DownRight programs themselves, the width and height of the program must be co-prime. (An extension of the language without this restriction is easy to imagine, and many interpreters are likely to be able to interpret this extended version too. However, removing the restriction makes the language substantially harder to compile into several languages, because with the restriction, one number can easily be used to represent both coordinates.) | |
| </p> | |
| <h2><span class="mw-headline" id="Syntax">Syntax</span></h2> | |
| <p>(Much of the syntax is due to <a href="/wiki/User:Vorpal" title="User:Vorpal">User:Vorpal</a>.) Each string in a DownRight program is notated as a non-empty sequence of characters that contains no whitespace; all characters but ↓ and → are treated as comments and ignored, with ↓ and → being treated as the "down" and "right" symbols respectively. (When notating an empty string, at least one comment character must be used, so as to make the character sequence non-empty.) These are written in sequence, with rows written top-to-bottom and strings written left-to-right within a row; strings in a row must be separated with sequences of horizontal whitespace (spaces and horizontal tabs), and rows themselves must be separated by sequences of whitespace that contain at least one vertical whitespace character (newline, formfeed, or vertical tab). Trailing whitespace on the program is ignored; apart from that, a program is a syntax error if each row does not have exactly the same number of columns, or if the number of rows and the number of columns are not coprime. | |
| </p> | |
| <h2><span class="mw-headline" id="Computational_class">Computational class</span></h2> | |
| <p>DownRight is <a class="mw-redirect" href="/wiki/Turing_complete" title="Turing complete">Turing complete</a>. The proof below by <a href="/wiki/User:Ais523" title="User:Ais523">User:ais523</a> (2010) was the one that originally showed the Turing-completeness of the language. | |
| </p><p>The easiest way to show this is probably via the following algorithm to compile <a href="/wiki/Tag_system" title="Tag system">tag systems</a> with no halt symbol (which are nonetheless Turing complete despite not having one, as they halt when their queue gets too short) into DownRight: | |
| </p> | |
| <ul><li>Add an otherwise unused symbol to the tag system whose production rule produces itself, then <i>m</i>-2 arbitrary symbols, then the initial word (effectively, transform the tag system into one where the initial word is a single symbol long); call this symbol S</li> | |
| <li>Add unused symbols to the tag system until there are at least 5 symbols, and a prime number of them (call this number <i>p</i>) that is not a factor of <i>m</i>; their production rules are irrelevant</li> | |
| <li>Find another prime <i>q</i> that is neither equal to <i>m</i> nor <i>p</i></li> | |
| <li>Assign an integer from 0 to <i>p</i>-1 inclusive to each symbol, with S being numbered 0</li> | |
| <li>For each word in a production rule, encode it into a DownRight string as follows: for each symbol in the word, take the corresponding number <i>n</i>, and convert it to a substring consisting of a right symbol, then <i>n</i> down symbols, then <i>q</i>-1 right symbols, then (<i>p</i>-<i>n</i>) down symbols; as an exception, the word encoding the production rule for S should omit its first right symbol</li> | |
| <li>Make the program <i>p</i> rows high and <i>qm</i> columns wide; the production rule for each symbol should go at coordinates (0 from the left, <i>n</i> from the top), where <i>n</i> is the number that corresponds to that symbol, and every other string should be empty</li></ul> | |
| <p>The way this works is by mapping the tag system queue to the DownRight queue (using the same encoding as was used to encode the production rules); every <i>m</i>th symbol will cross the first column (as each symbol moves exactly <i>q</i> spaces to the right, and the program is <i>qm</i> columns wide), and so just as in a tag system, all but every <i>m</i>th symbol will be disregarded and have no effect (with each symbol moving a total of <i>p</i> rows downwards, and so leaving the program at the same vertical height). The location where that column is crossed will depend on the symbol, and cross at the row corresponding to the symbol, so what is added to the queue will be the encoding of the appropriate production rule, again just as in a tag system. Finally, <i>p</i> must be coprime with <i>qm</i>, as it is prime and not a factor of <i>q</i> nor <i>m</i> (by definition). | |
| </p> | |
| <h3><span class="mw-headline" id="Simpler_proof">Simpler proof</span></h3> | |
| <dl><dd><i>Note that this proof uses <code>v</code> and <code>></code> for down and right symbols. They may be replaced with the actual DownRight arrows.</i></dd></dl> | |
| <p>Here's <a href="/wiki/User:Keymaker" title="User:Keymaker">User:Keymaker</a>'s alternative proof (2025) of DownRight's Turing-completeness, via <a href="/wiki/Cyclic_tag_system" title="Cyclic tag system">Cyclic Tag</a> translation: | |
| </p><p>Creating the construction will demand only a few simple calculations, which for many people are simple to calculate in their minds. The most complicated procedure is multiplying an arbitrary (but relatively small) positive integer by two, which is a process easily done without thinking; for example by collecting n number of white stones in a bowl, where n is the number that is to be doubled. Then, take every white stone from the bowl one by one until none are left, and whenever taking a white stone, place two black stones into the bowl. After all white stones are gone, there will be 2*n black stones. | |
| </p><p>The height of the matrix is the number of production rules in the Cyclic Tag program multiplied by two. The width of the matrix is the aforementioned value increased by one. Because any n and n+1 (assuming n is 1 or larger) are co-prime, the matrix fulfils DownRight's co-primality requirement for the matrix dimensions. (Simply add one black stone into the bowl containing the height, to get the width.) | |
| </p><p>Now that the matrix dimensions are set, it can be filled. | |
| </p><p>At index 1,1 (the top-left corner) there is the cell whose data initializes the queue at the start of a DownRight program. Therein is placed the short sequence ">v" (which moves the pointer to 2,2) followed by the initial queue in its encoded form. | |
| </p><p>The encoding for 0 and 1 is, throughout this translation, this: Replace every 0 with "vv" and 1 with n ">" arrows, where n is the width of the matrix, followed by "vv". So, for example, in a matrix where width is 7, this construction would be >>>>>>>vv for 1. (0 is "vv" regardless of width or height.) Initial queue data "1001" would be >>>>>>>vvvvvv>>>>>>>vv in this example. Do not forget to add the ">v" before the initial queue that is placed at index 1,1 (making the complete 1,1 string >v>>>>>>>vvvvvv>>>>>>>vv in this case). | |
| </p><p>Go through every production rule of the Cyclic Tag program and start at index 1,2 (x=1, y=2). Take the production rule, such as "101;". Remove the ";", replace each digit with the corresponding construction mentioned above. (For an empty production rule the resulting string is an empty string.) For a matrix with its width as 7 (as in above example), the string would be >>>>>>>vvvv>>>>>>>vv (1 0 1). It is placed at index 1,2. Then increase the y location by two and do the same procedure for the next production rule, for as long as there are them (if there are more than one). They are placed at (1,4), (1,6), and so forth. Once each is set, the translation is complete. | |
| </p> | |
| <h2><span id="Languages.2Fsystems_that_translate_into_DownRight"></span><span class="mw-headline" id="Languages/systems_that_translate_into_DownRight">Languages/systems that translate into DownRight</span></h2> | |
| <h3><span class="mw-headline" id="Tag_system_into_DownRight">Tag system into DownRight</span></h3> | |
| <ul><li>See: <a class="mw-selflink-fragment" href="#Computational_class">DownRight#Computational_class</a></li></ul> | |
| <h3><span class="mw-headline" id="Cyclic_Tag_into_DownRight">Cyclic Tag into DownRight</span></h3> | |
| <ul><li>See: <a class="mw-selflink-fragment" href="#Simpler_proof">DownRight#Simpler proof</a></li></ul> | |
| <h3><span class="mw-headline" id="Minsky_Machine_into_DownRight">Minsky Machine into DownRight</span></h3> | |
| <p><a href="/wiki/User:Keymaker" title="User:Keymaker">User:Keymaker</a> has created two <a href="/wiki/Minsky_machine" title="Minsky machine">Minsky machine</a> translations, the first in 2018 and the improved one in 2019 (but they were not published until 2025). The first uses 2-register MM and stores the two registers as a multiple of primes 2 and 3. The second translation can feature any number of registers and stores each register on its own, in 2^n units of "vvvv". Following the execution of the program is much easier, too. | |
| </p> | |
| <ul><li><a href="/wiki/Minsky_Machine_to_DownRight_translation" title="Minsky Machine to DownRight translation">Minsky Machine to DownRight translation</a></li></ul> | |
| <h3><span class="mw-headline" id="Miserie_into_DownRight">Miserie into DownRight</span></h3> | |
| <p><a href="/wiki/Miserie" title="Miserie">Miserie</a> is a minimal state and queue language designed specifically for DownRight translation. Because of some errors in <a href="/wiki/User:Keymaker" title="User:Keymaker">User:Keymaker</a>'s thinking, the translation took much longer than expected (and was the reason the Minsky Machine translations were not published earlier). What is notable in this translation is that it operates a binary queue construction within the DownRight queue alongside data used for arbitrary state control. The memory usage is horrific as is the execution speed! Miserie itself is quite capable; for instance, there exists an <a href="/wiki/I/D_machine" title="I/D machine">I/D machine</a> to Miserie translation. (However, with present implementations running any I/D machine to Miserie to DownRight construction is more or less impossible.) | |
| </p> | |
| <ul><li><a href="/wiki/Miserie_to_DownRight_translation" title="Miserie to DownRight translation">Miserie to DownRight translation</a></li></ul> | |
| <h2><span class="mw-headline" id="DownRight_into_Cyclic_Tag">DownRight into Cyclic Tag</span></h2> | |
| <p>This small aside by <a href="/wiki/User:Ais523" title="User:Ais523">User:ais523</a> may not have been seen widely enough: | |
| </p> | |
| <dl><dd>Also interesting is that DownRight compiles quite easily into cyclic tag (for a DownRight program <i>x</i> columns wide and <i>y</i> rows high, map the cell at (<i>a</i> from the left, <i>b</i> from the top) to the (<i>ya</i>+<i>xb</i>)th production rule (modulo <i>xy</i>), with production rules encoded as (<i>y</i>-1) 0s then a 1 for a down symbol, and (<i>x</i>-1) 0s then a 1 for a right symbol.)</dd></dl> | |
| <p>This means that anything translated into DownRight can be translated into Cyclic Tag quite efficiently. | |
| </p> | |
| <h3><span class="mw-headline" id="Translation_example">Translation example</span></h3> | |
| <p>TODO: Example, preferably with some kind of informative graphics that exhibits the relationship between the two systems. | |
| </p> | |
| <h2><span class="mw-headline" id="Note_on_a_future_interpreter">Note on a future interpreter</span></h2> | |
| <p>What is needed in a future interpreter is optimization of steps. An interpreter like dori2.py optimizes memory usage (although that, too, could be made faster with more advanced programming techniques and implementation in C), but it has no optimization on executing instructions. Some ideas might be: | |
| </p> | |
| <ul><li>Place any good ideas here!</li></ul> | |
| <h2><span class="mw-headline" id="Implementations_and_relevant_software">Implementations and relevant software</span></h2> | |
| <ul><li>Two early implementations can be found on the <a href="/wiki/Talk:DownRight" title="Talk:DownRight">talk page</a>.</li> | |
| <li><a class="external text" href="http://yiap.nfshost.com/esoteric/downright/dori2.py" rel="nofollow">http://yiap.nfshost.com/esoteric/downright/dori2.py</a> - <i>dori2</i>, a memory-optimizing interpreter (uses the simplified input format, or a matrix that uses "v" and ">" characters (for technical reasons))</li> | |
| <li><a class="external text" href="http://yiap.nfshost.com/esoteric/downright/drintgen.py" rel="nofollow">http://yiap.nfshost.com/esoteric/downright/drintgen.py</a> - <i>drintgen</i>, for creating a html/Javascript interpreter of a given DownRight program, which can be run and inspected in browser (uses the simplified input format)</li></ul> | |
| <h2><span class="mw-headline" id="See_also">See also</span></h2> | |
| <ul><li><a href="/wiki/Re:direction" title="Re:direction">Re:direction</a></li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20250919133254 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.016 seconds | |
| Real time usage: 0.017 seconds | |
| Preprocessor visited node count: 63/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:3898-0!canonical and timestamp 20250919133254 and revision id 164794. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><a href="/wiki/Esolang:Featured_languages" title="Esolang:Featured languages"><span class="featured-icon" title="This is a featured language; *click* for more information."></span></a></p><div class="featured-text"> | |
| <dl><dd><i>This is a <a href="/wiki/Esolang:Featured_languages" title="Esolang:Featured languages">featured language</a>.</i></dd></dl> | |
| </div> | |
| <p><b>Emmental</b> is an <a href="/wiki/Esoteric_programming_language" title="Esoteric programming language">esoteric programming language</a> designed by <a href="/wiki/Chris_Pressey" title="Chris Pressey">Chris Pressey</a> in 2007. | |
| </p><p>Emmental is a self-modifying language. It is defined by a meta-circular interpreter (an Emmental interpreter described in Emmental.) The meta-circular interpreter provides an operation which modifies operations of the meta-circular interpreter. | |
| </p><p>Emmental is a <a href="/wiki/Stack" title="Stack">stack</a>-based language, but it also has a <a href="/wiki/Queue" title="Queue">queue</a>. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Instruction_set"><span class="tocnumber">1</span> <span class="toctext">Instruction set</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Examples"><span class="tocnumber">2</span> <span class="toctext">Examples</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-3"><a href="#Infinite_loop"><span class="tocnumber">2.1</span> <span class="toctext">Infinite loop</span></a></li> | |
| <li class="toclevel-2 tocsection-4"><a href="#Cat_program"><span class="tocnumber">2.2</span> <span class="toctext">Cat program</span></a></li> | |
| <li class="toclevel-2 tocsection-5"><a href="#Hello,_World!"><span class="tocnumber">2.3</span> <span class="toctext">Hello, World!</span></a></li> | |
| <li class="toclevel-2 tocsection-6"><a href="#Conditional_branching"><span class="tocnumber">2.4</span> <span class="toctext">Conditional branching</span></a> | |
| <ul> | |
| <li class="toclevel-3 tocsection-7"><a href="#Using_the_discrete_log"><span class="tocnumber">2.4.1</span> <span class="toctext">Using the discrete log</span></a></li> | |
| <li class="toclevel-3 tocsection-8"><a href="#Using_implicit_modulo_256"><span class="tocnumber">2.4.2</span> <span class="toctext">Using implicit modulo 256</span></a></li> | |
| <li class="toclevel-3 tocsection-9"><a href="#Using_massive_symbol_redefinition"><span class="tocnumber">2.4.3</span> <span class="toctext">Using massive symbol redefinition</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-2 tocsection-10"><a href="#Truth-machine"><span class="tocnumber">2.5</span> <span class="toctext">Truth-machine</span></a></li> | |
| <li class="toclevel-2 tocsection-11"><a href="#99_Bottles_of_Beer"><span class="tocnumber">2.6</span> <span class="toctext">99 Bottles of Beer</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-12"><a href="#Computability_class"><span class="tocnumber">3</span> <span class="toctext">Computability class</span></a></li> | |
| <li class="toclevel-1 tocsection-13"><a href="#Implementations"><span class="tocnumber">4</span> <span class="toctext">Implementations</span></a></li> | |
| <li class="toclevel-1 tocsection-14"><a href="#See_also"><span class="tocnumber">5</span> <span class="toctext">See also</span></a></li> | |
| <li class="toclevel-1 tocsection-15"><a href="#External_resources"><span class="tocnumber">6</span> <span class="toctext">External resources</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Instruction_set">Instruction set</span></h2> | |
| <p>(Emmental's instruction set can be redefined, so what follows is the initial instruction set.) | |
| </p> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <th>Instruction | |
| </th> | |
| <th>Description | |
| </th></tr> | |
| <tr> | |
| <td><code>#</code></td> | |
| <td>Push <code>NUL</code> (ASCII 0) onto stack. | |
| </td></tr> | |
| <tr> | |
| <td><code>0..9</code></td> | |
| <td>Pop symbol, multiply by 10, add 0..9 respectively, push back on. | |
| </td></tr> | |
| <tr> | |
| <td><code>+</code></td> | |
| <td>Pop two symbols, add them, push back result. | |
| </td></tr> | |
| <tr> | |
| <td><code>-</code></td> | |
| <td>Pop two symbols, subtract first from second, push back result. | |
| </td></tr> | |
| <tr> | |
| <td><code>~</code></td> | |
| <td>Pop symbol, push discrete base-2 log of symbol. As a special case, the discrete base-2 log of 0 is considered to be 8. | |
| </td></tr> | |
| <tr> | |
| <td><code>.</code></td> | |
| <td>Pop symbol from the stack and output it. | |
| </td></tr> | |
| <tr> | |
| <td><code>,</code></td> | |
| <td>Input symbol and push it onto stack. | |
| </td></tr> | |
| <tr> | |
| <td><code>^</code></td> | |
| <td>Enqueue top element of stack without popping it. | |
| </td></tr> | |
| <tr> | |
| <td><code>v</code></td> | |
| <td>Dequeue symbol from queue and push onto stack. | |
| </td></tr> | |
| <tr> | |
| <td><code>:</code></td> | |
| <td>Duplicate top element of stack. | |
| </td></tr> | |
| <tr> | |
| <td><code>!</code></td> | |
| <td>Pop a symbol and an Emmental program (a string of symbols terminated by <code>;</code>). Then redefine that symbol as having the same semantics as that Emmental program in the meta-circular interpreter. | |
| </td></tr> | |
| <tr> | |
| <td><code>?</code></td> | |
| <td>Pop a symbol and execute it (with the current interpreter). This is sometimes called the 'eval' operator. | |
| </td></tr> | |
| <tr> | |
| <td><code>;</code></td> | |
| <td>Push the symbol <code>;</code> onto the stack. | |
| </td></tr></tbody></table> | |
| <h2><span class="mw-headline" id="Examples">Examples</span></h2> | |
| <h3><span class="mw-headline" id="Infinite_loop">Infinite loop</span></h3> | |
| <p>Go into an infinite loop. This is done by redefining <code>0</code> to mean <code>#48?</code>, and then executing <code>0</code>. | |
| </p> | |
| <pre>;#35#52#56#63#48!0 | |
| </pre> | |
| <h3><span class="mw-headline" id="Cat_program"><a href="/wiki/Cat_program" title="Cat program">Cat program</a></span></h3> | |
| <p>Redefines <code>*</code> (ASCII 42) to mean <code>,.#42?</code> and executes <code>*</code>. This program is an infinite loop that does not observe EOF. | |
| </p> | |
| <pre>;#44#46#35#52#50#63#42!* | |
| </pre> | |
| <h3><span id="Hello.2C_World.21"></span><span class="mw-headline" id="Hello,_World!"><a class="mw-redirect" href="/wiki/Hello,_World!" title="Hello, World!">Hello, World!</a></span></h3> | |
| <p>Output "Hello, world!". This is done by pushing the ASCII representation of every character on to the stack, and then popping them off with the <code>.</code> operator. | |
| </p> | |
| <pre>#0#10#33#100#108#114#111#119#32#44#111#108#108#101#72............... | |
| </pre> | |
| <p>Alternatively, this code performs a loop over the characters (rather than outputting each character individually.) | |
| </p> | |
| <pre>;#58#126#63#36!;#46#36#!;#0#1!;#0#2!;#0#3!;#0#4!;#0#5!;#0#6!;#0#7!#0#33#100#108#114#111#119#32#44#111#108#108#101#72$ | |
| </pre> | |
| <h3><span class="mw-headline" id="Conditional_branching">Conditional branching</span></h3> | |
| <p>Emmental doesn't have explicit conditional statements, but the eval instruction <code>?</code> can be used to "branch" by executing an instruction that depends on the symbol on top of the stack. The discrete base-2 log instruction <code>~</code> can be used in combination with eval: it basically maps the 256 possible symbols into 9 "equivalency classes" 0, 1, 2-3, 4-7, 8-15, 16-31, 32-63, 64-127 and 128-255. | |
| </p><p>The following programs display different approaches to conditional branching. | |
| </p> | |
| <h4><span class="mw-headline" id="Using_the_discrete_log">Using the discrete log</span></h4> | |
| <p>Input a character and report whether its ASCII value is congruent with 0, 1 or 2 modulo 3. This is done by repeatedly subtracting 3, and branching with the base-2 log. | |
| </p> | |
| <table class="wikitable plainpres"> | |
| <tbody><tr> | |
| <th>Readable version</th> | |
| <th>Emmental program | |
| </th></tr> | |
| <tr> | |
| <td><pre>;''0.#8! | |
| ;''1.#0! | |
| ; | |
| '';'''2''.'#'2'! | |
| '';'''0''.'#'3'! | |
| '? | |
| #1! | |
| ;'#'3'-':'~'?#2! | |
| ;'#'3'-':'~'?#3! | |
| ;'#'3'-':'~'?#4! | |
| ;'#'3'-':'~'?#5! | |
| ;'#'3'-':'~'?#6! | |
| ;'#'3'-':'~'?#7! | |
| ,:~?</pre></td> | |
| <td><pre>;#35#52#56#46#8! | |
| ;#35#52#57#46#0! | |
| ; | |
| #35#53#57 #35#51#53#35#53#51#35#52#56 #35#52#54#35#50#33 | |
| #35#53#57 #35#51#53#35#53#50#35#53#54 #35#52#54#35#51#33 | |
| #63 | |
| #1! | |
| ;#35#51#45#58#126#63#2! | |
| ;#35#51#45#58#126#63#3! | |
| ;#35#51#45#58#126#63#4! | |
| ;#35#51#45#58#126#63#5! | |
| ;#35#51#45#58#126#63#6! | |
| ;#35#51#45#58#126#63#7! | |
| ,:~?</pre> | |
| </td></tr></tbody></table> | |
| <p>For better readability, the program has been written using the notation <code>'A</code> for <code>#65</code> (and so forth with every ASCII char). This is <b>not</b> a feature of the Emmental language, it is merely a convention adopted in this article to help understand the examples. With this notation: | |
| </p> | |
| <ul><li><code>'0</code> means <code>#48</code></li> | |
| <li><code>''0</code> means <code>'#'4'8</code> which in turn means <code>#35#52#56</code></li> | |
| <li><code>'''0</code> means <code>'#'3'5'#'5'2'#'5'6</code> which in turns means <code>#35#51#53#35#53#50#35#53#54</code></li></ul> | |
| <p>Note the nested definitions of symbols 2 and 3 inside the definition of symbol 1: those symbols will be defined when symbol 1 is evaluated. | |
| </p> | |
| <h4><span class="mw-headline" id="Using_implicit_modulo_256">Using implicit modulo 256</span></h4> | |
| <p>Input a character and report whether its ASCII value is odd or even. This is done by multiplying it by 128. | |
| </p> | |
| <table class="wikitable plainpres"> | |
| <tbody><tr> | |
| <td><center><b>Readable version</b></center></td> | |
| <td><pre>; '^'v ':! | |
| ; ''E'. #! | |
| ; ''O'. #128! | |
| ; ':'+':'+':'+':'+':'+':'+':'+ | |
| 'm! | |
| ,m?</pre> | |
| </td></tr> | |
| <tr> | |
| <td><center><b>Emmental program</b></center></td> | |
| <td><pre>#59#94#118#58!#59#35#54#57#46#!#59#35#55#57#46#128! | |
| #59#58#43#58#43#58#43#58#43#58#43#58#43#58#43 | |
| #109!,m?</pre> | |
| </td></tr></tbody></table> | |
| <h4><span class="mw-headline" id="Using_massive_symbol_redefinition">Using massive symbol redefinition</span></h4> | |
| <p>Input a character and report whether its ASCII value is congruent with 0, 1 or 2 modulo 3. This is done by redefining <i>every</i> symbol to "subtract 3 and try again". | |
| </p> | |
| <table class="wikitable plainpres"> | |
| <tbody><tr> | |
| <th>Readable version</th> | |
| <th>Emmental code | |
| </th></tr> | |
| <tr> | |
| <td><pre>; '#'4'8 '. #! | |
| ; '#'4'9 '. #1! | |
| ; '#'5'0 '. #2! | |
| ; '#'3'-':'? #3! | |
| ; '^':'-'#'5'9'+'#'3'v'! #4! | |
| ; | |
| '#'5'9 '#'3 '#'2'5'5'! | |
| ',':'? | |
| #255! | |
| ; #4#4#4#4#4#4#4#4#4#4 #5! | |
| ; #5#5#5#5#5 #5! | |
| ; #5#5#5#5#5#4 #4! | |
| #4 | |
| ; ':'#'1'+ 'd! | |
| ; 'd'd'd'd'd'd'd'd'd'd 'd! | |
| ; 'd'd'd'd'd 'd! | |
| ; 'd'd'd'd'd #4 #255 'd! | |
| d</pre></td> | |
| <td><pre>; #35#52#56#46 #! | |
| ; #35#52#57#46 #1! | |
| ; #35#53#48#46 #2! | |
| ; #35#51#45#58#63 #3! | |
| ; #94#58#45 #35#53#57 #43#35#51 #118#33 #4! | |
| ; | |
| #35#53#57 #35#51 #35#50#53#53#33 | |
| #44#58#63 | |
| #255! | |
| ; #4#4#4#4#4#4#4#4#4#4 #5! | |
| ; #5#5#5#5#5 #5! | |
| ; #5#5#5#5#5#4 #4! | |
| #4 | |
| ; #58#35#49#43 #100! | |
| ; #100#100#100#100#100#100#100#100#100#100 #100! | |
| ; #100#100#100#100#100 #100! | |
| ; #100#100#100#100#100 #4#255 #100! | |
| d</pre> | |
| </td></tr></tbody></table> | |
| <ul><li>the symbols <code>\0</code>, <code>\1</code> and <code>\2</code> are defined to output '0', '1' or '2'.</li> | |
| <li>the symbol <code>\3</code> is defined to "subtract 3 from top stack element, duplicate it, evaluate the copy", and the symbol <code>\4</code> to "pop top stack element and define it to be a synonym of <code>\3</code>".</li> | |
| <li>the symbol <code>\255</code> is defined to "redefine myself to be a synonym of <code>\3</code>; then take one char from input, duplicate it, evaluate the copy".</li> | |
| <li>the symbol <code>\4</code> is redefined to "repeat <code>\4</code> 251 times"</li> | |
| <li>the value 4 is pushed on the stack</li> | |
| <li>the symbol <code>d</code> is defined to "duplicate top stack element and increment the copy"</li> | |
| <li>the symbol <code>d</code> is redefined to "repeat <code>d</code> 250 times, then <code>\4</code>, then <code>\255</code>"</li> | |
| <li><code>d</code></li></ul> | |
| <p>Note that <b>all</b> symbols are redefined to "subtract 3 and try again" when <code>d</code> is executed; for that reason, that occurrence of <code>d</code> must be the very last character in the program — even whitespace are not allowed. | |
| </p> | |
| <h3><span class="mw-headline" id="Truth-machine"><a href="/wiki/Truth-machine" title="Truth-machine">Truth-machine</a></span></h3> | |
| <pre>;#58#46#58#63#49! | |
| ,:.:? | |
| </pre> | |
| <h3><span class="mw-headline" id="99_Bottles_of_Beer">99 Bottles of Beer</span></h3> | |
| <pre>;#35#51#50#46#35#57#56#46#35#49#49#49#46#35#49#49#54#46#35#49#49#54#46#35#49#48#56#46#35#49#48#49#46#35#49#49#53#46#35#51#50#46#35#49#49#49#46#35#49#48#50#46#35#51#50#46#35#57#56#46#35#49#48#49#46#35#49#48#49#46#35#49#49#52#46#81! | |
| ;#35#51#50#46#35#49#49#49#46#35#49#49#48#46#35#51#50#46#35#49#49#54#46#35#49#48#52#46#35#49#48#49#46#35#51#50#46#35#49#49#57#46#35#57#55#46#35#49#48#56#46#35#49#48#56#46#82! | |
| ;#35#51#51#46#83! | |
| ;#35#52#52#46#85; | |
| ;#35#56#52#46#35#57#55#46#35#49#48#55#46#35#49#48#49#46#35#51#50#46#35#49#49#49#46#35#49#49#48#46#35#49#48#49#46#35#51#50#46#35#49#48#48#46#35#49#49#49#46#35#49#49#57#46#35#49#49#48#46#35#52#52#46#35#49#48#46#35#49#49#50#46#35#57#55#46#35#49#49#53#46#35#49#49#53#46#35#51#50#46#35#49#48#53#46#35#49#49#54#46#35#51#50#46#35#57#55#46#35#49#49#52#46#35#49#49#49#46#35#49#49#55#46#35#49#49#48#46#35#49#48#48#46#35#52#52#46#84! | |
| ;#35#49#48#46#78! | |
| ;#58#45#63#124! | |
| ;#94#124#94#124#118#118#10#94#124#94#124#10#118#58#35#52#56#43#46#94#124#10#118#58#35#52#56#43#46#94#124#10#118#118#80! | |
| ;#94#124#94#124#10#118#118#118#10#58#35#52#56#43#46#94#124#10#58#35#52#56#43#46#94#124#10#94#124#10#118#118#90! | |
| ;#35#49#45#32#58#32#35#50#48#48#32#43#32#63#68! | |
| ;#124#35#49#45#35#57#199! | |
| ;#124#58#32#35#50#51#48#43#63#32#35#48#200! | |
| ;#118#35#94#124#124#124#35#48#35#48#230! | |
| ;#80#81#82#85#78#10#80#81#83#78#10#84#78#10#35#55#54#32#94#124#32#68#10#90#81#82#83#78#78#10#118#63#76! | |
| #9 | |
| #9 | |
| L | |
| </pre> | |
| <h2><span class="mw-headline" id="Computability_class">Computability class</span></h2> | |
| <p>An <a href="/wiki/Underload" title="Underload">Underload</a> implementation in Emmental <a class="external text" href="http://oerjan.nvg.org/esoteric/emmental/ul.emm" rel="nofollow">is available</a>, generated by a <a class="external text" href="http://oerjan.nvg.org/esoteric/emmental/EmmUnl.hs" rel="nofollow">Haskell program</a>. | |
| </p><p>It is not quite an ordinary interpreter: It uses Emmental's metacircular evaluation principles to <i>turn</i> the Emmental interpreter into an Underload one. As such, the Underload program you wish to interpret should be appended to the Emmental one. | |
| </p><p>It supports all Underload commands, but not all Underload <i>characters</i>: By the necessities of this kind of Emmental programming, 10 byte values have been reserved for the interpreter's internal use. These are all non-printable control codes. | |
| </p><p>In any case <a href="/wiki/User:Oerjan" title="User:Oerjan">I</a> believe this proves Emmental Turing-complete. However it <i>may</i> happen to do so in a way which I have previously disagreed with Chris Pressey on whether it counts or not. :P | |
| </p><p>I also attempted to minimize the number of initial Emmental instructions used for this, based partially on certain challenges proposed in the Emmental distribution. In particular: | |
| </p> | |
| <ul><li>It doesn't use the queue.</li> | |
| <li>It doesn't use the ~ or : instructions.</li></ul> | |
| <p>In fact, it only uses the initial instructions <code>#1-.?!</code> (and the special stack-separator function of <code>;</code>). | |
| </p> | |
| <h2><span class="mw-headline" id="Implementations">Implementations</span></h2> | |
| <p>The Emmental reference interpreter is written in Haskell and <a class="external text" href="https://codeberg.org/catseye/Emmental" rel="nofollow">can be found in the Emmental distribution on Codeberg</a>. It also contains some example programs as test cases. | |
| </p><p>There is also an <a href="/wiki/Emmental/emmental.ml" title="Emmental/emmental.ml">implementation in OCaml</a> by <a href="/wiki/User:Koen" title="User:Koen">User:Koen</a>. | |
| </p><p>All three implementations are in the public domain. | |
| </p> | |
| <h2><span class="mw-headline" id="See_also">See also</span></h2> | |
| <ul><li><a href="/wiki/Enema" title="Enema">Enema</a>, another stack-based, instruction-rewriting esolang</li> | |
| <li><a href="/wiki/Mascarpone" title="Mascarpone">Mascarpone</a>, a direct successor of Emmental</li> | |
| <li><a href="/wiki/Square-like" title="Square-like">Square-like</a>, a queue based instruction creating(however not rewriting) esolang directly inspired by Emmental</li></ul> | |
| <h2><span class="mw-headline" id="External_resources">External resources</span></h2> | |
| <ul><li><a class="external text" href="https://catseye.tc/node/Emmental" rel="nofollow">Emmental project at Cat's Eye Technologies</a></li> | |
| <li><a class="external text" href="https://emmentool.vercel.app/" rel="nofollow">Emmentool</a>, tool for turning text into emmental code. By <a href="/wiki/User:Truttle1" title="User:Truttle1">User:Truttle1</a></li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20251114042233 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.021 seconds | |
| Real time usage: 0.022 seconds | |
| Preprocessor visited node count: 107/1000000 | |
| Post‐expand include size: 340/2097152 bytes | |
| Template argument size: 55/2097152 bytes | |
| Highest expansion depth: 3/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 1411/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 1.491 1 -total | |
| 43.88% 0.654 1 Template:Featured_language | |
| 32.12% 0.479 1 Template:Catseye | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:2334-0!canonical and timestamp 20251114042233 and revision id 168122. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><dl><dd><i>This article is not detailed enough and needs to be expanded. Please help us by <span class="plainlinks"><a class="external text" href="//esolangs.org/w/index.php?title=ETA&action=edit" rel="nofollow">adding some more information</a></span>.</i></dd></dl> | |
| <p><b>ETA</b> is an <a href="/wiki/Esoteric_programming_language" title="Esoteric programming language">esoteric programming language</a> designed by <a class="new" href="/w/index.php?title=Mike_Taylor&action=edit&redlink=1" title="Mike Taylor (page does not exist)">Mike Taylor</a> in 1999. The name comes from its instruction set, based on the eight most common letters in the English language: E, T, A, O, I, N, S, H. "Eta" is also the seventh letter in the Greek alphabet, and ETA uses base-7 numbering. The language is <a href="/wiki/Stack" title="Stack">stack</a>-based and all characters that are not instructions are treated as comments. | |
| <b>Eta</b> has 7 instructions: | |
| </p> | |
| <table class="wikitable"> | |
| <caption>Instructions | |
| </caption> | |
| <tbody><tr> | |
| <th>Command</th> | |
| <th>What it does | |
| </th></tr> | |
| <tr> | |
| <td>E</td> | |
| <td>Pop two numbers of the stack, first b, then a.Then push floor(b/a) first and b%a second. | |
| </td></tr> | |
| <tr> | |
| <td>T</td> | |
| <td>Pop 2 numbers off the stack, first <code>addr</code>, then <code>cond</code>. If <code>cond!=0</code> then jump to the <code>addr</code>th instruction. The first instruction is instruction 1. Jumping to instruction 0 terminates the program. | |
| </td></tr> | |
| <tr> | |
| <td>A</td> | |
| <td>Push the current instruction number. | |
| </td></tr> | |
| <tr> | |
| <td>O</td> | |
| <td>Print and pop top of stack as an ASCII character | |
| </td></tr> | |
| <tr> | |
| <td>I</td> | |
| <td>Push the input as an ASCII character | |
| </td></tr> | |
| <tr> | |
| <td>N</td> | |
| <td>Push a base-7 number. The digits are:<br/>H=0 T=1 A=2 O=3 I=4 N=5 S=6. E terminates the number. <br/>Example: NTONE=(1x7^2+3x7^1+5x7^0) | |
| </td></tr> | |
| <tr> | |
| <td>S</td> | |
| <td>Pop 2 numbers off the stack: first b, then a. Push b-a on the stack. | |
| </td></tr> | |
| <tr> | |
| <td>H</td> | |
| <td>Pops a number n from the stack.<br/>If n>0 then remove the <code>n</code>th value and push it on top of stack.<br/> If n<=0 then push the <code>n</code>th item onto top of stack and keep the original one intact unlike the top case. <br/>If n=0, this is effectively a DUP. | |
| </td></tr></tbody></table> | |
| <p>"Hello, World!" Program | |
| </p> | |
| <pre>NINEONAHAEONATOEONAAAEONATSEONTNOEONIIEONSAEONATSEONATOEONATEONAHOEONTOAEO | |
| </pre> | |
| <p>Cat Program | |
| </p> | |
| <pre>IO | |
| </pre> | |
| <h2><span class="mw-headline" id="See_also">See also</span></h2> | |
| <ul><li><a href="/wiki/Beatnik" title="Beatnik">Beatnik</a></li> | |
| <li><a href="/wiki/Shakespeare" title="Shakespeare">Shakespeare</a></li> | |
| <li><a href="/wiki/ThETA" title="ThETA">ThETA</a></li></ul> | |
| <h2><span class="mw-headline" id="External_resources">External resources</span></h2> | |
| <ul><li><a class="external text" href="http://www.miketaylor.org.uk/tech/eta/doc/" rel="nofollow">The ETA Project</a></li> | |
| <li><a class="external text" href="https://github.com/helvm/helma#readme" rel="nofollow">ETA interpreter implemented in Haskell</a></li> | |
| <li><a class="external text" href="https://github.com/helvm/helpa#readme" rel="nofollow">EAS (ETA assembler) implemented in Haskell</a></li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20260129181024 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [] | |
| CPU time usage: 0.010 seconds | |
| Real time usage: 0.029 seconds | |
| Preprocessor visited node count: 19/1000000 | |
| Post‐expand include size: 267/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 4/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 1.113 1 Template:Stub | |
| 100.00% 1.113 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:1043-0!canonical and timestamp 20260129181024 and revision id 152641. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b>Etre</b> is a <a href="/wiki/Turing_tarpit" title="Turing tarpit">Turing tarpit</a> designed by <a href="/wiki/User:Keymaker" title="User:Keymaker">User:Keymaker</a> in <a href="/wiki/Category:2013" title="Category:2013">2013</a>. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Description"><span class="tocnumber">1</span> <span class="toctext">Description</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Minsky_Machine_to_Etre"><span class="tocnumber">2</span> <span class="toctext">Minsky Machine to Etre</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-3"><a href="#Reading_MM-to-Etre_translation's_memory"><span class="tocnumber">2.1</span> <span class="toctext">Reading MM-to-Etre translation's memory</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-4"><a href="#External_resources"><span class="tocnumber">3</span> <span class="toctext">External resources</span></a></li> | |
| <li class="toclevel-1 tocsection-5"><a href="#See_also"><span class="tocnumber">4</span> <span class="toctext">See also</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Description">Description</span></h2> | |
| <p>The language has the instructions '-' and '()'. The parentheses must be matching and can contain any number of '-' or '()' pairs. Other characters in a program are simply ignored. | |
| The memory is an array or a string, where values are either 0 or 1, and which initially has the length of 1 and the one value at that point is 0. Memory pointer is initally pointing to this first unit/cell. | |
| </p> | |
| <ul><li><b>-</b> moves the memory pointer one forward/right. If the pointer moves out of bounds, it is set back to the very first cell, and the memory is extended by one 0-cell.</li> | |
| <li><b>()</b> form loops. At first, () flips the current memory cell (0 to 1, 1 to 0). Then the loop is executed as long as the current cell (at the beginning of every loop cycle, as in <a href="/wiki/Brainfuck" title="Brainfuck">brainfuck</a> loops) is non-zero. A loop, whenever it is encountered, always alters memory (and does it exactly once, before the code within () is executed), but the actual code inside the () might never be executed if the initial flipping changes the current cell from 1 to 0.</li></ul> | |
| <h2><span class="mw-headline" id="Minsky_Machine_to_Etre">Minsky Machine to Etre</span></h2> | |
| <p>One way to prove that the language is <a href="/wiki/Turing-complete" title="Turing-complete">Turing-complete</a> is translating Minsky Machine into it. The work can be done for example with this translator: <a class="external text" href="http://yiap.nfshost.com/esoteric/etre/mmtoetre.py" rel="nofollow">http://yiap.nfshost.com/esoteric/etre/mmtoetre.py</a> | |
| </p><p>An example <a class="external text" href="http://yiap.nfshost.com/esoteric/etre/mmprog.txt" rel="nofollow">Minsky Machine program</a> that doubles a register (its value initially 1) ten times creates the following Etre program: | |
| </p> | |
| <pre>-------------------------------------------------------------------------------- | |
| -------------------------------------------------------------------------------- | |
| -------------------------------------------------------------------------------- | |
| -------------------------------------------------------------------------------- | |
| -------------------------------------------------------------------------------- | |
| -------------------------------------------------------------------------------- | |
| -------------------------------------------------------------------------------- | |
| -------------------------------------------------------------------------------- | |
| -------------------------------------------------------------------------------- | |
| -------------------------------------------------------------------------------- | |
| -------------------------------------------------------------------------------- | |
| -------------------------------------------------------------------------------- | |
| -------------------------------------------------------------------------------- | |
| -------------------------------------------------------------------------------- | |
| -------------------------------------------------------------------------------- | |
| -------------------------------------------------------------------------------- | |
| -------------------------------------------------------------------------------- | |
| -------------------------------------------------------------------------------- | |
| -------------------------------------------------------------------------------- | |
| -------------------------------------------------------------------------------- | |
| ---------------------------------------------------------------------------(-(-( | |
| -(-(-(-(-(-(-(-(-(-(-(-(-(-(-(-))))))))))))))))))-(-(-))-(-(-))-(-(-))-(-(-))-(- | |
| (-))-(-(-))-(--(-(-(-(-(-(-(-(-(-(-(-(-(-(-(-(-(-)))))))))))))))))-(------------ | |
| -----()(-)-()(-)(-())-()(-)(-())-()(-)(-())-()(-)(-())-()(-)(-())-()(-)(-)----() | |
| -----------------())-(----------------()(-)-()(-)(-())-()(-)(-())-()(-)(-())-()( | |
| -)(-())-()(-)(-())-()(-)(-)-----()-----------------())-(---------------()(-)-()( | |
| -)(-())-()(-)(-())-()(-)(-())-()(-)(-())-()(-)(-())-()(-)(-)------()------------ | |
| -----())-(--------------()(-)-()(-)(-())-()(-)(-())-()(-)(-())-()(-)(-())-()(-)( | |
| -())-()(-)(-)-------()-----------------())-(-------------()(-)-()(-)(-())-()(-)( | |
| -())-()(-)(-())-()(-)(-())-()(-)(-())-()(-)(-)--------()-----------------())-(-- | |
| ----------()(-)-()(-)(-())-()(-)(-())-()(-)(-())-()(-)(-())-()(-)(-())-()(-)(-)- | |
| --------()-----------------())-(-----------()(-)-()(-)(-())-()(-)(-())-()(-)(-() | |
| )-()(-)(-())-()(-)(-())-()(-)(-)----------()-----------------())-(----------()(- | |
| )-()(-)(-())-()(-)(-())-()(-)(-())-()(-)(-())-()(-)(-())-()(-)(-)-----------()-- | |
| ---------------())-(---------()(-)-()(-)(-())-()(-)(-())-()(-)(-())-()(-)(-())-( | |
| )(-)(-())-()(-)(-)------------()-----------------())-(--------()(-)-()(-)-()(-)- | |
| ()(-)(-())-()(-)(-())-()(-)(-())-()(-)(-)-------------()-----------------())-(-- | |
| -----()(-)-()(-)-()(-)---(()-()(-)-()(-)-()(-)(-)--(--------------())----------- | |
| -----------()(-)-()(-)-()(-)--())(-)-()(-)-()(-)-()(-)(-)--(------------()------ | |
| ------------------()(-)-()(-)-()(-)(-())-()(-)-()(-)-()(-)-()(-)(-)--())-------- | |
| ---------------------())-(------()(-)-()(-)-()(-)-()(-)-()(-)-()(-)(-())-()(-)(- | |
| )---------------()-----------------())-(-----()(-)-()(-)-()(-)-()(-)-()(-)-()(-) | |
| (-())-()(-)(-)-------------()--------------------())-(----()(-)-()(-)-()(-)-()(- | |
| )-()(-)---(()-()(-)(-)--(----------------())--------------------()(-)-()(-)-()(- | |
| )-()(-)-()(-)--())(-)-()(-)(-)--(---------------()---------------------()(-)-()( | |
| -)-()(-)-()(-)-()(-)(-())-()(-)-()(-)(-)--())--------------------------------()) | |
| -(---()(-)-()(-)-()(-)-()(-)(-())-()(-)(-())-()(-)(-())-()(-)(-)---------------- | |
| ()-------------------())-(--()(-)---(()-()(-)-()(-)-()(-)-()(-)-()(-)(-)--(----- | |
| ------------())-------------------()(-)--())(-)-()(-)-()(-)-()(-)-()(-)-()(-)(-) | |
| --(-----------()-------------------------()(-)(-())-()(-)-()(-)-()(-)-()(-)-()(- | |
| )-()(-)(-)--())----------------------------------())-(-()(-)-()(-)-()(-)-()(-)-( | |
| )(-)-()(-)-()(-)(-)-()------------------------------------())-()(-)-()(-)-()(-)- | |
| ()(-)-()(-)-()(-)-()(-)(-)---------------------(-(-(-(-(-(-(-(-(-(-(-(-(-(-(-(-( | |
| -)))))))))))))))))-()(-)-()(-)-()(-)-()(-)-()(-)-()(-)(-)---(------------------( | |
| )-----------------()(-)-()(-)-()(-)-()(-)-()(-)-()(-)-()(-)(-)---())-(---------- | |
| --------()----------------()(-)-()(-)-()(-)-()(-)-()(-)-()(-)-()(-)(-)----())-(- | |
| -----------------()---------------()(-)-()(-)-()(-)-()(-)-()(-)-()(-)-()(-)(-)-- | |
| ---())-(------------------()--------------()(-)-()(-)-()(-)-()(-)-()(-)-()(-)-() | |
| (-)(-)------())-(------------------()-------------()(-)-()(-)-()(-)-()(-)-()(-)- | |
| ()(-)-()(-)(-)-------())-(------------------()------------()(-)-()(-)-()(-)-()(- | |
| )-()(-)-()(-)-()(-)(-)--------())-(------------------()-----------()(-)-()(-)-() | |
| (-)-()(-)-()(-)-()(-)-()(-)(-)---------())-(------------------()----------()(-)- | |
| ()(-)-()(-)-()(-)-()(-)-()(-)-()(-)(-)----------())-(------------------()------- | |
| --()(-)-()(-)-()(-)-()(-)-()(-)-()(-)-()(-)(-)-----------())-(------------------ | |
| ()--------()(-)-()(-)-()(-)-()(-)-()(-)-()(-)-()(-)(-)------------())-(--------- | |
| ---------()-------()(-)-()(-)-()(-)-()(-)-()(-)-()(-)-()(-)(-)-------------())-( | |
| ------------------()------()(-)-()(-)-()(-)-()(-)-()(-)-()(-)-()(-)(-)---------- | |
| ----())-(------------------()-----()(-)-()(-)-()(-)-()(-)-()(-)-()(-)-()(-)(-)-- | |
| -------------())-(------------------()----()(-)-()(-)-()(-)-()(-)-()(-)-()(-)-() | |
| (-)(-)----------------())-(------------------()---()(-)-()(-)-()(-)-()(-)-()(-)- | |
| ()(-)-()(-)(-)-----------------())-(------------------()--()(-)-()(-)-()(-)-()(- | |
| )-()(-)-()(-)-()(-)(-)------------------())-(------------------()-()(-)-()(-)-() | |
| (-)-()(-)-()(-)-()(-)-()(-)(-)-------------------())-------------------()(-)-()( | |
| -)-()(-)-()(-)-()(-)-()(-)-()(-)(-)-) | |
| </pre> | |
| <h3><span id="Reading_MM-to-Etre_translation.27s_memory"></span><span class="mw-headline" id="Reading_MM-to-Etre_translation's_memory">Reading MM-to-Etre translation's memory</span></h3> | |
| <p>For example, take this MM program: | |
| </p> | |
| <pre>1 inc B 2 | |
| 2 inc A 3 | |
| 3 inc B 4 | |
| 4 dec B 4 5 | |
| 5 halt | |
| </pre> | |
| <p>It increases B-register, then A, then B again, and then decreases B until it becomes 0, after which the program halts. | |
| </p><p>Translated to Etre using the translator, with an extra argument given, the program's output is the following: | |
| </p> | |
| <pre>B = 0 | |
| A = 1 | |
| 5 MM lines/instructions | |
| extra arguments; will add 'C' debug character to Etre program | |
| -------------------------------------------------------------------------------- | |
| -------------------------------------------------------------------------------- | |
| -------------------------------------------------------------------------------- | |
| -------------------------------------------------------------------------------- | |
| --------------------------------------------------------------------(-(-(-(-(-(- | |
| ))))))-(-(-))-(-(-))-(-(-))-(-(-))-(--(-(-(-(-(-)))))-(-----()(-)-()(-)(-())-()( | |
| -)(-())-()(-)(-())-()(-)(-)----()-----())-(----()(-)-()(-)-()(-)-()(-)(-())-()(- | |
| )(-)-----()-----())-(---()(-)-()(-)(-())-()(-)(-())-()(-)(-())-()(-)(-)------()- | |
| ----())-(--()(-)---(()-()(-)-()(-)-()(-)(-)--(-----())-------()(-)--())(-)-()(-) | |
| -()(-)-()(-)(-)--(----()--------()(-)(-())-()(-)-()(-)-()(-)-()(-)(-)--())------ | |
| ----())-(-()(-)-()(-)-()(-)-()(-)-()(-)(-)-()------------())-()(-)-()(-)-()(-)-( | |
| )(-)-()(-)(-)---------(-(-(-(-(-)))))-()(-)-()(-)-()(-)-()(-)(-)---(------()---- | |
| -()(-)-()(-)-()(-)-()(-)-()(-)(-)---())-(------()----()(-)-()(-)-()(-)-()(-)-()( | |
| -)(-)----())-(------()---()(-)-()(-)-()(-)-()(-)-()(-)(-)-----())-(------()--()( | |
| -)-()(-)-()(-)-()(-)-()(-)(-)------())-(------()-()(-)-()(-)-()(-)-()(-)-()(-)(- | |
| )-------())-------()(-)-()(-)-()(-)-()(-)-()(-)(-)C-) | |
| </pre> | |
| <p>The lines | |
| </p> | |
| <pre>B = 0 | |
| A = 1 | |
| </pre> | |
| <p>in the output mean the order of the registers. Since the registers appeared in that order in the MM program, B first, A then, that is the order they are in the Etre program. Yes, using '0' instead of '1' to mark '1st' is somewhat confusing, but imagine they are array indexes (which they actually are, in the Python program). | |
| </p><p>Running the program (from which the translator's note part that includes an extra 'C' is removed) in Keymaker's Etre interpreter, the interpreter outputs the following debug data: | |
| </p> | |
| <pre>DEBUG (C) at inst[1250]. Current memory: | |
| 0100000001011111011101101101111110 | |
| ^ 0 | |
| DEBUG (C) at inst[1250]. Current memory: | |
| 010000000110111101110110111011111111110 | |
| ^ 0 | |
| DEBUG (C) at inst[1250]. Current memory: | |
| 01000000011101110111101101110111111111111110 | |
| ^ 0 | |
| DEBUG (C) at inst[1250]. Current memory: | |
| 01000000011101111011101101110111111111111111111110 | |
| ^ 0 | |
| DEBUG (C) at inst[1250]. Current memory: | |
| 01000000011101111101101101110111111111111111111111111110 | |
| ^ 0 | |
| DEBUG (C) at inst[1250]. Current memory: | |
| 01000000011110111101101101110111111111111111111111111111111110 | |
| ^ 0 | |
| DEBUG (C) at inst[1250]. Current memory: | |
| 000000000111111111011011011101111111111111111111111111111111111110 | |
| ^ 0 | |
| Done. Final memory state: | |
| 000000000111111111011011011101111111111111111111111111111111111110 | |
| ^ 1 | |
| </pre> | |
| <p>The debug command 'C' is executed at the end of the main loop, where execution goes after each simulated MM instruction. | |
| </p><p>The first debug | |
| </p> | |
| <pre>DEBUG (C) at inst[1250]. Current memory: | |
| 0100000001011111011101101101111110 | |
| ^ 0 | |
| </pre> | |
| <p>(where memory pointer is in cell 0, as told by "^ 0" line) can be read as | |
| </p> | |
| <pre>0mnxxxxxyyyyyttt0BBB0tt0AA0tttttt0 | |
| </pre> | |
| <p>where: | |
| </p> | |
| <ul><li>The first three cells 0mn are for program's internal purposes. Can be ignored.</li> | |
| <li>xxxxx and yyyyy cells are for program's internal logic to mark what MM line/instruction to execute. The amount of them is the number of MM lines * 2 (which is 5*2=10 here). Can be ignored.</li> | |
| <li>Then follows whatever number of trash-bits there happens to be at a given time (3 in this case) followed by 0. Can be ignored.</li> | |
| <li>Then a row of 1s (or "BBB") terminated by a 0 signifying the first register (B in this case). The value of the register is the number of 1-bits minus 2. So "111" here means 3-2=1. ("11" signifies zero, the reason of which is left to the reader, if he/she has time to trace the workings of this system.) This is followed by any number of trash-bits, 2 of them here, terminated by a 0.</li> | |
| <li>Then another row of 1s (or "AA") to mark the second register (A here). Its value is presently 0 (2-2=0). This "11" is too followed by a 0, then any number of trash-bits, 6 of them here, and a 0 again.</li></ul> | |
| <p>Similarly, the final memory state | |
| </p> | |
| <pre>Done. Final memory state: | |
| 000000000111111111011011011101111111111111111111111111111111111110 | |
| ^ 1 | |
| </pre> | |
| <p>(where memory pointer is in cell 1) can be read as | |
| </p> | |
| <pre>0mnxxxxxyyyyyttttt0BB0tt0AAA0tttttttttttttttttttttttttttttttttttt0 | |
| </pre> | |
| <p>where | |
| </p> | |
| <ul><li>B is 0 (as marked by two 1s here)</li> | |
| <li>A is 1 (as marked by three 1s here)</li></ul> | |
| <h2><span class="mw-headline" id="External_resources">External resources</span></h2> | |
| <ul><li><a class="external text" href="http://yiap.nfshost.com/esoteric/etre/etre.html" rel="nofollow">Etre page</a> (the specs, a MM-to-Etre translator, an interpreter in C)</li></ul> | |
| <h2><span class="mw-headline" id="See_also">See also</span></h2> | |
| <ul><li><a href="/wiki/Exoshell" title="Exoshell">Exoshell</a></li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20260128162516 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.011 seconds | |
| Real time usage: 0.013 seconds | |
| Preprocessor visited node count: 20/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:9112-0!canonical and timestamp 20260128162516 and revision id 174410. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b>evil</b> is a minimal language of the line-noise school. It was devised by <a class="external text" href="http://tomwrensch.com" rel="nofollow">Tom Wrensch</a> in about <a href="/wiki/Category:1999" title="Category:1999">1999</a>, while he was a graduate student at the University of Colorado. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Model"><span class="tocnumber">1</span> <span class="toctext">Model</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Commands"><span class="tocnumber">2</span> <span class="toctext">Commands</span></a></li> | |
| <li class="toclevel-1 tocsection-3"><a href="#Weaving"><span class="tocnumber">3</span> <span class="toctext">Weaving</span></a></li> | |
| <li class="toclevel-1 tocsection-4"><a href="#Examples"><span class="tocnumber">4</span> <span class="toctext">Examples</span></a> | |
| <ul> | |
| <li class="toclevel-2 tocsection-5"><a href="#Hello,_world!"><span class="tocnumber">4.1</span> <span class="toctext">Hello, world!</span></a></li> | |
| <li class="toclevel-2 tocsection-6"><a href="#Shorter_Hello,_world"><span class="tocnumber">4.2</span> <span class="toctext">Shorter Hello, world</span></a></li> | |
| <li class="toclevel-2 tocsection-7"><a href="#Quine"><span class="tocnumber">4.3</span> <span class="toctext">Quine</span></a></li> | |
| </ul> | |
| </li> | |
| <li class="toclevel-1 tocsection-8"><a href="#Constructing_Constants"><span class="tocnumber">5</span> <span class="toctext">Constructing Constants</span></a></li> | |
| <li class="toclevel-1 tocsection-9"><a href="#External_resources"><span class="tocnumber">6</span> <span class="toctext">External resources</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Model">Model</span></h2> | |
| <p>The <i>evil</i> computation model involves: | |
| </p> | |
| <ul><li>The accumulator (<b>A</b>), a single unsigned byte</li> | |
| <li>The marking mode (<b>M</b>), a state bit specifying one of two options (<i>standard</i> or <i>alternate</i>)</li> | |
| <li>A pool of memory storing the source code (<b>S</b>)</li> | |
| <li>The <i>wheel</i> (<b>W</b>), a variable-sized circular list of unsigned bytes</li> | |
| <li>The <i>pental</i> (<b>P</b>), a wheel whose size is fixed at five</li></ul> | |
| <p>The source, wheel, and pental all have pointers pointing to an area inside them, called <b>*S</b>, <b>*W</b>, and <b>*P</b>. They wrap as necessary. The source pointer <b>*S</b> is the <a class="mw-redirect" href="/wiki/Instruction_pointer" title="Instruction pointer">instruction pointer</a>; program execution works by repeatedly executing the command it points to, and then incrementing it. | |
| </p><p>Commands in <i>evil</i> are lowercase letters. Uppercase letters are reserved for future library calls. Other characters are ignored. The program ends when the source pointer goes out of memory. | |
| </p><p>Two commands are <i>marker characters</i>. This means that they do nothing by themselves, but will be jumped to during certain commands, depending on the state of the marking mode. In <i>standard</i> marking mode, the commands <b>b</b> and <b>f</b> will jump to the first <b>m</b> command it finds. In <i>alternate</i> mode, this command is <b>j</b>. | |
| </p> | |
| <h2><span class="mw-headline" id="Commands">Commands</span></h2> | |
| <table class="wikitable"> | |
| <tbody><tr> | |
| <th>Letter</th> | |
| <th>Effect | |
| </th></tr> | |
| <tr> | |
| <td>a</td> | |
| <td>Increments A. | |
| </td></tr> | |
| <tr> | |
| <td>b</td> | |
| <td>Scans backward to the first valid marker character for the mode. Sets *S to the position of that marker character. | |
| </td></tr> | |
| <tr> | |
| <td>c</td> | |
| <td>Inserts a new wheel cell before the current cell. Changes *W to point to the new cell. | |
| </td></tr> | |
| <tr> | |
| <td>d</td> | |
| <td>Deletes the currently pointed-to cell on the wheel. | |
| </td></tr> | |
| <tr> | |
| <td>e</td> | |
| <td>Applies the weave function to A. See below for more info. | |
| </td></tr> | |
| <tr> | |
| <td>f</td> | |
| <td>Scans forward to the first valid marker character. Sets *S to the position of that marker character. | |
| </td></tr> | |
| <tr> | |
| <td>g</td> | |
| <td>Sets A to the value inside the current Pental cell. | |
| </td></tr> | |
| <tr> | |
| <td>h</td> | |
| <td>Increments *P. | |
| </td></tr> | |
| <tr> | |
| <td>i</td> | |
| <td>Increments *W. | |
| </td></tr> | |
| <tr> | |
| <td>j</td> | |
| <td>Mark character for alternate marking mode. | |
| </td></tr> | |
| <tr> | |
| <td>k</td> | |
| <td>Sets the current Pental cell to A. | |
| </td></tr> | |
| <tr> | |
| <td>l</td> | |
| <td>Swaps A and the current wheel cell. | |
| </td></tr> | |
| <tr> | |
| <td>m</td> | |
| <td>Mark character for standard marking mode. | |
| </td></tr> | |
| <tr> | |
| <td>n</td> | |
| <td>Decrements *P. | |
| </td></tr> | |
| <tr> | |
| <td>o</td> | |
| <td>Decrements *W. | |
| </td></tr> | |
| <tr> | |
| <td>p</td> | |
| <td>Sets A to the value inside the current wheel cell. | |
| </td></tr> | |
| <tr> | |
| <td>q</td> | |
| <td>Swaps W and S, and swaps *W and *S. | |
| </td></tr> | |
| <tr> | |
| <td>r</td> | |
| <td>Reads a character from input and sets A to it. | |
| </td></tr> | |
| <tr> | |
| <td>s</td> | |
| <td>Skip next command if A is equal to 0. | |
| </td></tr> | |
| <tr> | |
| <td>t</td> | |
| <td>Skip next command if A is not equal to 0. | |
| </td></tr> | |
| <tr> | |
| <td>u</td> | |
| <td>Decrements A. | |
| </td></tr> | |
| <tr> | |
| <td>v</td> | |
| <td>Swaps A and the current Pental cell. | |
| </td></tr> | |
| <tr> | |
| <td>w</td> | |
| <td>Writes A to output, as a character. | |
| </td></tr> | |
| <tr> | |
| <td>x</td> | |
| <td>Swaps the mark state between standard and alternate mode. | |
| </td></tr> | |
| <tr> | |
| <td>y</td> | |
| <td>Sets the current wheel cell to A. | |
| </td></tr> | |
| <tr> | |
| <td>z</td> | |
| <td>Sets A to 0. | |
| </td></tr></tbody></table> | |
| <h2><span class="mw-headline" id="Weaving">Weaving</span></h2> | |
| <p>The weave operation is used to lower the amount of commands used to generate constants. It translates the 8 bits of input like so: | |
| </p> | |
| <ul><li>Bit 0 is moved to bit 2</li> | |
| <li>Bit 1 is moved to bit 0</li> | |
| <li>Bit 2 is moved to bit 4</li> | |
| <li>Bit 3 is moved to bit 1</li> | |
| <li>Bit 4 is moved to bit 6</li> | |
| <li>Bit 5 is moved to bit 3</li> | |
| <li>Bit 6 is moved to bit 7</li> | |
| <li>Bit 7 is moved to bit 5</li></ul> | |
| <p>So, for example, weaving the number <i>10011101</i> will produce <i>01110110</i>. Note that applying weave eight times in a row leaves the value unchanged. | |
| </p> | |
| <h2><span class="mw-headline" id="Examples">Examples</span></h2> | |
| <h3><span id="Hello.2C_world.21"></span><span class="mw-headline" id="Hello,_world!"><a href="/wiki/Hello,_world!" title="Hello, world!">Hello, world!</a></span></h3> | |
| <p>This hello world only uses the commands <b>a</b>, <b>e</b>, <b>u</b>, <b>z</b>, and <b>w</b>, and outputs the string "Hello, world!\r\n": | |
| </p> | |
| <pre>zaeeeaeeew (H) | |
| zaeeaeeaeaw (e) | |
| zuueeueueaw (l) | |
| zuueeueueaw (l) | |
| zuueeueew (o) | |
| zuueeaeeeaw (,) | |
| zaeeeeew ( ) | |
| zuueeueeeew (w) | |
| zuueeueew (o) | |
| zuueeueeaaaw (r) | |
| zuueeueueaw (l) | |
| zaeeaeeaew (d) | |
| zaeeeeeaw (!) | |
| zaeeuuuw (\r) | |
| zaeaaaaaaw (\n) | |
| </pre> | |
| <p>It constructs the ASCII values of the characters in the <b>A</b> register and writes them out using the <b>w</b> command. The <b>z</b> command zeros <b>A</b>, the <b>a</b> command increments <b>A</b>, the <b>e</b> command shuffles <b>A'</b>s bit order from 76543210 to 64725031, and <b>u</b> decrements <b>A</b>. | |
| </p> | |
| <h3><span id="Shorter_Hello.2C_world"></span><span class="mw-headline" id="Shorter_Hello,_world">Shorter Hello, world</span></h3> | |
| <pre>zaeeeaeeew (H) | |
| uueeaw (e) | |
| aaaaaaaw (l) | |
| w (l) | |
| aaaw (o) | |
| eaaew (,) | |
| aeaaw ( ) | |
| uueeeeuw (w) | |
| ueeeeaw (o) | |
| aaaw (r) | |
| ueeuew (l) | |
| eeaw (d) | |
| uueueuw (!) | |
| eaw (\r) | |
| uuuw (\n) | |
| </pre> | |
| <p>Both programs are generated by the Python program <a class="external text" href="https://ideone.com/RdImLF" rel="nofollow">here</a>. | |
| </p> | |
| <h3><span class="mw-headline" id="Quine"><a class="external text" href="https://esolangs.org/wiki/List_of_quines" rel="nofollow">Quine</a></span></h3> | |
| <pre>zuueeueeuuyk (store m to wheel and pental) | |
| ueeucy (b -> wheel) | |
| guuuucy (i -> wheel) | |
| gaaacy (p -> wheel) | |
| ueecy (w -> wheel) | |
| gaeeucy (f -> wheel) | |
| geeacy (t -> wheel) | |
| uuuucy (p -> wheel) | |
| gcy (m -> wheel) | |
| uuuucy (i -> wheel) | |
| gueecy (c -> wheel) | |
| guuuucy (i -> wheel) | |
| q (swap wheel and source) | |
| </pre> | |
| <p>The above quine writes the code to output all code in the wheel to the wheel, and then swaps the wheel and source code. The source code is now in the wheel, and the code to write the wheel is now the source code. | |
| </p> | |
| <h2><span class="mw-headline" id="Constructing_Constants">Constructing Constants</span></h2> | |
| <p>These snippets construct constants in <b>A</b>, using only the commands <b>a</b>, <b>e</b>, <b>u</b>, and <b>z</b>. | |
| </p><p>Generated by the Python program accessible <a class="external text" href="https://ideone.com/eV4vDt" rel="nofollow">here</a>. | |
| </p> | |
| <pre>000 : z | |
| 001 : za | |
| 002 : zaa | |
| 003 : zaaa | |
| 004 : zae | |
| 005 : zaea | |
| 006 : zaeaa | |
| 007 : zaeaaa | |
| 008 : zaeaaaa | |
| 009 : zaeaaaaa | |
| 010 : zaeaaaaaa | |
| 011 : zaeeuuuuu | |
| 012 : zaeeuuuu | |
| 013 : zaeeuuu | |
| 014 : zaeeuu | |
| 015 : zaeeu | |
| 016 : zaee | |
| 017 : zaeea | |
| 018 : zaeeaa | |
| 019 : zaeaeu | |
| 020 : zaeae | |
| 021 : zaeaea | |
| 022 : zaeaeaa | |
| 023 : zaeeue | |
| 024 : zaeeuea | |
| 025 : zaeeueaa | |
| 026 : zaeeueaaa | |
| 027 : zaeeueaaaa | |
| 028 : zaeeeeaeae | |
| 029 : zaeeeeeuuu | |
| 030 : zaeeeeeuu | |
| 031 : zaeeeeeu | |
| 032 : zaeeeee | |
| 033 : zaeeeeea | |
| 034 : zaeeeeeaa | |
| 035 : zaeeeeaeu | |
| 036 : zaeeeeae | |
| 037 : zaeeeeaea | |
| 038 : zaeeeeaeaa | |
| 039 : zaeaeeeeeu | |
| 040 : zaeaeeeee | |
| 041 : zaeaeeeeea | |
| 042 : zuueeaeeeu | |
| 043 : zuueeaeee | |
| 044 : zuueeaeeea | |
| 045 : zuueeaeeeaa | |
| 046 : zaeeeaeeuu | |
| 047 : zaeeeaeeu | |
| 048 : zaeeeaee | |
| 049 : zaeeeaeea | |
| 050 : zaeeeaeeaa | |
| 051 : zaeeaeueeu | |
| 052 : zaeeaeuee | |
| 053 : zaeeaeueea | |
| 054 : zaeeaeeueu | |
| 055 : zaeeaeeue | |
| 056 : zaeeaeeuea | |
| 057 : zaeeaeeueaa | |
| 058 : zuueueeueu | |
| 059 : zuueueeue | |
| 060 : zaeeeuuuu | |
| 061 : zaeeeuuu | |
| 062 : zaeeeuu | |
| 063 : zaeeeu | |
| 064 : zaeee | |
| 065 : zaeeea | |
| 066 : zaeeeaa | |
| 067 : zaeeaeu | |
| 068 : zaeeae | |
| 069 : zaeaeue | |
| 070 : zaeaeuea | |
| 071 : zaeaeueaa | |
| 072 : zaeeeaeee | |
| 073 : zaeeeaeeea | |
| 074 : zaeeaeeueae | |
| 075 : zuueueeueue | |
| 076 : zaeeeaeeae | |
| 077 : zaeaeeuuu | |
| 078 : zaeaeeuu | |
| 079 : zaeaeeu | |
| 080 : zaeaee | |
| 081 : zaeaeea | |
| 082 : zaeaeeaa | |
| 083 : zaeaeaeu | |
| 084 : zaeaeae | |
| 085 : zaeeuee | |
| 086 : zaeeueea | |
| 087 : zaeeeeeue | |
| 088 : zaeeaeueee | |
| 089 : zaeeeuueuu | |
| 090 : zaeeeuueu | |
| 091 : zaeeeuue | |
| 092 : zaeeeuuea | |
| 093 : zaeeeueuu | |
| 094 : zaeeeueu | |
| 095 : zaeeeue | |
| 096 : zaeeeuea | |
| 097 : zaeeeueaa | |
| 098 : zaeeeueaaa | |
| 099 : zaeeaeeaeu | |
| 100 : zaeeaeeae | |
| 101 : zaeeaeeaea | |
| 102 : zaeeaeeaeaa | |
| 103 : zuueueeaeu | |
| 104 : zuueueeae | |
| 105 : zuueueeaea | |
| 106 : zuueeueueu | |
| 107 : zuueeueue | |
| 108 : zuueeueuea | |
| 109 : zuueeueeuu | |
| 110 : zuueeueeu | |
| 111 : zuueeuee | |
| 112 : zuueeueea | |
| 113 : zuueeueeaa | |
| 114 : zuueeueeaaa | |
| 115 : zaeaeeueeuu | |
| 116 : zaeaeeueeu | |
| 117 : zaeaeeuee | |
| 118 : zaeaeeueea | |
| 119 : zuueeueeee | |
| 120 : zuueeueeeea | |
| 121 : zuueeeueuu | |
| 122 : zuueeeueu | |
| 123 : zuueeeue | |
| 124 : zuueeeuea | |
| 125 : zaeeeeuuu | |
| 126 : zaeeeeuu | |
| 127 : zaeeeeu | |
| 128 : zaeeee | |
| 129 : zaeeeea | |
| 130 : zaeeeeaa | |
| 131 : zaeeeaeu | |
| 132 : zaeeeae | |
| 133 : zaeeaeue | |
| 134 : zaeeaeuea | |
| 135 : zaeeaeueaa | |
| 136 : zaeeeueae | |
| 137 : zaeeeueaea | |
| 138 : zuueueeaee | |
| 139 : zuueeueueue | |
| 140 : zaeeeueaae | |
| 141 : zaeeaeeuuu | |
| 142 : zaeeaeeuu | |
| 143 : zaeeaeeu | |
| 144 : zaeeaee | |
| 145 : zaeeaeea | |
| 146 : zaeeaeeaa | |
| 147 : zaeaeeuue | |
| 148 : zaeaeuee | |
| 149 : zaeaeueea | |
| 150 : zaeaeeueu | |
| 151 : zaeaeeue | |
| 152 : zaeaeeuea | |
| 153 : zaeaeeueaa | |
| 154 : zuueeueueae | |
| 155 : zuueeueeue | |
| 156 : zaeeaeeaeae | |
| 157 : zuueueeaeue | |
| 158 : zuueeueeeu | |
| 159 : zuueeueee | |
| 160 : zaeaeeee | |
| 161 : zaeaeeeea | |
| 162 : zaeaeeeeaa | |
| 163 : zaeaeeeaeu | |
| 164 : zaeaeeeae | |
| 165 : zaeaeeeaea | |
| 166 : zaeaeeeaeaa | |
| 167 : zuueeaeeuuu | |
| 168 : zuueeaeeuu | |
| 169 : zuueeaeeu | |
| 170 : zuueeaee | |
| 171 : zuueueue | |
| 172 : zuueueuea | |
| 173 : zuueueeuu | |
| 174 : zuueueeu | |
| 175 : zuueuee | |
| 176 : zuueueea | |
| 177 : zuueueeaa | |
| 178 : zuueueeaaa | |
| 179 : zuueueeaaaa | |
| 180 : zaeaeaeuee | |
| 181 : zaeeeuueee | |
| 182 : zaeeeuueeea | |
| 183 : zuueeeueee | |
| 184 : zuueeueuuu | |
| 185 : zuueeueuu | |
| 186 : zuueeueu | |
| 187 : zuueeue | |
| 188 : zuueeuea | |
| 189 : zuueeeuu | |
| 190 : zuueeeu | |
| 191 : zuueee | |
| 192 : zaeaeee | |
| 193 : zaeaeeea | |
| 194 : zaeaeeeaa | |
| 195 : zaeaeeaeu | |
| 196 : zaeaeeae | |
| 197 : zaeaeaeue | |
| 198 : zaeaeaeuea | |
| 199 : zaeeeuuee | |
| 200 : zuueeueeae | |
| 201 : zuueeueeaea | |
| 202 : zuueeeueueu | |
| 203 : zuueeeueue | |
| 204 : zuueeueeaae | |
| 205 : zuueeeueeuu | |
| 206 : zuueeeueeu | |
| 207 : zuueeeuee | |
| 208 : zaeaeaee | |
| 209 : zaeeueeae | |
| 210 : zaeeeuueae | |
| 211 : zaeeeueue | |
| 212 : zaeeueee | |
| 213 : zaeeueeea | |
| 214 : zaeeeueeu | |
| 215 : zaeeeuee | |
| 216 : zaeeeueea | |
| 217 : zaeeeueeaa | |
| 218 : zuueeeueae | |
| 219 : zaeeeeuue | |
| 220 : zaeaeeueee | |
| 221 : zaeeeeueuu | |
| 222 : zaeeeeueu | |
| 223 : zaeeeeue | |
| 224 : zaeaeaeee | |
| 225 : zaeaeaeeea | |
| 226 : zaeeeueeae | |
| 227 : zuueeeueaee | |
| 228 : zaeeueeaee | |
| 229 : zaeeeueuee | |
| 230 : zuueeaeuu | |
| 231 : zuueeaeu | |
| 232 : zuueeae | |
| 233 : zuueeaea | |
| 234 : zuueueu | |
| 235 : zuueue | |
| 236 : zuueuea | |
| 237 : zuueeuu | |
| 238 : zuueeu | |
| 239 : zuuee | |
| 240 : zuueea | |
| 241 : zuueeaa | |
| 242 : zuueeaaa | |
| 243 : zuueeaaaa | |
| 244 : zaeeueeeae | |
| 245 : zaeeeueee | |
| 246 : zuueuuuuu | |
| 247 : zuueuuuu | |
| 248 : zuueuuu | |
| 249 : zuueuu | |
| 250 : zuueu | |
| 251 : zuue | |
| 252 : zuuea | |
| 253 : zuuu | |
| 254 : zuu | |
| 255 : zu | |
| </pre> | |
| <h2><span class="mw-headline" id="External_resources">External resources</span></h2> | |
| <ul><li><a class="external text" href="https://github.com/xprogram/esolot" rel="nofollow">The GitHub repository for a collection of esoteric interpreters, including evil.</a> <i>(<a href="/wiki/Template:Deadlink" title="Template:Deadlink">dead link</a>)</i></li> | |
| <li><a class="external text" href="https://web.archive.org/web/20070103000858/www1.pacific.edu/~twrensch/evil/index.html" rel="nofollow">The evil home page</a> <i>(from the <a class="extiw" href="https://en.wikipedia.org/wiki/Wayback_Machine" title="wikipedia:Wayback Machine">Wayback Machine</a>; retrieved on 3 January 2007)</i></li> | |
| <li><a class="external text" href="https://web.archive.org/web/20070906133127/www1.pacific.edu/~twrensch/evil/evil.java" rel="nofollow">Version 0.2 evil interpreter</a> <i>(from the <a class="extiw" href="https://en.wikipedia.org/wiki/Wayback_Machine" title="wikipedia:Wayback Machine">Wayback Machine</a>; retrieved on 6 September 2007)</i></li> | |
| <li><a class="external text" href="https://web.archive.org/web/20061128232206/www1.pacific.edu/~twrensch/evil/evilspec.html" rel="nofollow">The evil programming language specification</a> <i>(from the <a class="extiw" href="https://en.wikipedia.org/wiki/Wayback_Machine" title="wikipedia:Wayback Machine">Wayback Machine</a>; retrieved on 28 November 2006)</i></li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20250724010026 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.024 seconds | |
| Real time usage: 0.119 seconds | |
| Preprocessor visited node count: 73/1000000 | |
| Post‐expand include size: 720/2097152 bytes | |
| Template argument size: 301/2097152 bytes | |
| Highest expansion depth: 5/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 20.092 1 -total | |
| 88.99% 17.880 3 Template:Wayback | |
| 6.41% 1.288 1 Template:Lowercase | |
| 2.15% 0.432 1 Template:Deadlink | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:2026-0!canonical and timestamp 20250724010026 and revision id 142357. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b>Exoshell</b> is a loop-based two-instruction esolang designed by <a href="/wiki/User:Keymaker" title="User:Keymaker">User:Keymaker</a>. An early version of the language was made in 2020 but it was not published until <a href="/wiki/Category:2025" title="Category:2025">2025</a> when the language was redesigned. | |
| </p> | |
| <div aria-labelledby="mw-toc-heading" class="toc" id="toc" role="navigation"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"/><div class="toctitle" dir="ltr" lang="en"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div> | |
| <ul> | |
| <li class="toclevel-1 tocsection-1"><a href="#Program_and_execution"><span class="tocnumber">1</span> <span class="toctext">Program and execution</span></a></li> | |
| <li class="toclevel-1 tocsection-2"><a href="#Computational_class"><span class="tocnumber">2</span> <span class="toctext">Computational class</span></a></li> | |
| <li class="toclevel-1 tocsection-3"><a href="#Translation_example"><span class="tocnumber">3</span> <span class="toctext">Translation example</span></a></li> | |
| <li class="toclevel-1 tocsection-4"><a href="#See_also"><span class="tocnumber">4</span> <span class="toctext">See also</span></a></li> | |
| <li class="toclevel-1 tocsection-5"><a href="#External_resources"><span class="tocnumber">5</span> <span class="toctext">External resources</span></a></li> | |
| </ul> | |
| </div> | |
| <h2><span class="mw-headline" id="Program_and_execution">Program and execution</span></h2> | |
| <p>The program consists of parenthesis characters <code>[</code> and <code>]</code>, which are used to form loops. All other characters are ignored. Parentheses can be nested, and must be matching. The memory is binary queue, initially with data <code>1100</code>. Once the instruction pointer is past the last <code>]</code>, the program halts. Trying to access empty queue is undefined behaviour (which should not happen in a valid program). | |
| </p><p>The two parenthesis characters can be viewed as two instructions: | |
| </p> | |
| <dl><dd><code>[</code> | |
| <dl><dd>If first in queue is 1, remove it from queue and enter loop (go to next instruction).</dd> | |
| <dd>If first in queue is 0, remove it from queue and skip loop (go to instruction right after matching <code>]</code>).</dd></dl></dd> | |
| <dd><code>]</code> | |
| <dl><dd>If first in queue is 1, see next two bits (it is undefined behaviour if queue has less than three digits here). If they are 00 or 01, append <code>111011001101100</code> (for 00) or <code>0111011001101100</code> (for 01), in other cases (10 and 11) append nothing, then (in any case) go to matching <code>[</code>.</dd> | |
| <dd>If first in queue is 0, exit loop (go to next instruction).</dd></dl></dd></dl> | |
| <p>The parentheses encode <i>no additional functionality</i> with nesting or with any other structure formed of them, which was one of the design goals of the language. For instance, in some languages things like the amount of nested parentheses cause different memory operations, or sets of parentheses are interpreted as function calls with arguments. In Exoshell there is none of that; the instructions/parenthesis work the same no matter where they are in the program -- only the state of the queue matters to the program execution. | |
| </p> | |
| <h2><span class="mw-headline" id="Computational_class">Computational class</span></h2> | |
| <p>The language is <a href="/wiki/Turing-complete" title="Turing-complete">Turing-complete</a>, which is shown via Minsky Machine translation. Minsky Machine is translated into <a href="/wiki/Countertrue" title="Countertrue">Countertrue</a>, which is translated into Exoshell. Countertrue was originally meant to be a nameless <a href="/wiki/Intermediate_language" title="Intermediate language">intermediate language</a>, but as it appeared to be quite useful it was defined as a proper esolanguage. | |
| </p> | |
| <h2><span class="mw-headline" id="Translation_example">Translation example</span></h2> | |
| <p>This MM program | |
| </p> | |
| <pre>1 inc A 2 | |
| 2 inc A 4 | |
| 3 dec A 4 5 | |
| 4 inc B 3 | |
| 5 inc A 6 | |
| 6 inc A 7 | |
| 7 dec A 8 9 | |
| 8 dec B 7 7 | |
| 9 inc C 9 | |
| </pre> | |
| <p>becomes, after put through MM to Countertrue translator, and its output through Countertrue to Exoshell translator (line-breaks after every 70 characters for improved readability): | |
| </p> | |
| <pre>[][][][[[]]][][][][][[]][][][][][[[]]][][][][][[]][][][][][[[]]][][][] | |
| [][[]][][][][][[[]]][][][][][[]][][][][][[[]]][][][][][[]][][][][][[[] | |
| ]][][][][][[]][][][][][[[]]][][][][][[]][][][][][[[]]][][][][][[]][][] | |
| [][][[[]]][][][][][[]][][][][][[[]]][][][][][[]][][][][][[[]]][][][][] | |
| [[]][][][][][[[]]][][][][][[]][][][][][[[]]][][][][][[]][][][][][[[]]] | |
| [][][][][[]][][][][][[[]]][][][][][[]][][][][][[[]]][][][][][[]][][][] | |
| [][[[]]][][][][][[]][][][][][[[]]][][][][][[]][][][][][[[]]][][][][][[ | |
| ]][][][][][[[]]][][][][][[]][][][][][[[]]][][][][][[]][][][][][[[]]][] | |
| [][][][[]][][][][][[[]]][][][][][[]][][][][][[[]]][][][][][[]][][][][] | |
| [[[]]][][][][][[]][][][][][[[]]][][][][][[]][][][][][[[]]][][][][][[]] | |
| [][][][][[[]]][][][][][[]][][][][][[[]]][][][][][[]][][][][][[[]]][][] | |
| [][][[]][][][][][[[]]][][][][][[]][][][][][[[]]][][][][][[]][][][][][[ | |
| []]][][][][][[]][][][][][[[]]][][][][][[]][][][][][[[]]][][][][][[]][] | |
| [][][][[[]]][][][][][[]][][][][][[[]]][][][][][[]][][][][][[[]]][][][] | |
| [][[]][][][][][[[]]][][][][][[]][][][][][[[]]][][][][][[]][][[]][][][[ | |
| []]][][][][][[]][][[]][][][][][[]][][][[]][][[]][][][][][[]][][][[]][] | |
| [[]][][][][][[]][][][[]][][[]][][][][][[]][][][[]][][[]][][][][][[]][] | |
| [][[]][][[]][][][][][[]][][][[]][][[]][][][][][[]][][][[]][][[]][][][] | |
| [][[]][][][[]][][[]][][][][][[]][][][[]][][[]][][][][][[]][][][[]][][[ | |
| ]][][][][][[]][][][[]][][[]][][][][][[]][][][[]][][[]][][][][][[]][][] | |
| [[]][][[]][][][][][[]][][][[]][][[]][][][][][[]][][][[]][][[]][][][][] | |
| [[]][][][[]][][[]][][][][][[]][][][[]][][[]][][][][][[]][][][[]][][[]] | |
| [][][][][[]][][][[]][][[]][][][][][[]][][][[]][][[]][][][][][[]][][][[ | |
| ]][][[]][][][][][[]][][][[]][][[]][][][][][[]][][][[]][][[]][][][][][[ | |
| ]][][][[]][][[]][][][][][[]][][][[]][][[]][][][][][[]][][][[]][][[]][] | |
| [][][][[]][][][[]][][[]][][][][][[]][][][[]][][[]][][][][][[]][][][[]] | |
| [][[]][][][][][[]][][][[]][][[]][][][][][[]][][][[]][][[]][][][][][[]] | |
| [][][[]][][[]][][][][][[]][][][[]][][[]][][][][][[]][][][[]][][[]][][] | |
| [][][[]][][][[]][][[]][][][][][[]][][][[]][][[]][][][][][[]][][][[]][] | |
| [[]][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][][[[]][][[ | |
| ]][][][[]][][][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][ | |
| ]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][ | |
| ]][[[]][][]][[[]][][][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[] | |
| ][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][] | |
| [[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][]][[[]][][][ | |
| ]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][ | |
| ]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][] | |
| [[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][] | |
| [][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[] | |
| ][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[] | |
| ][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][] | |
| [[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[ | |
| ]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][ | |
| []]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[] | |
| ][][][[]][][][][]][[[]][][]][[[]][][][]][][][][[]][][][][][][[]][][][[ | |
| ]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][] | |
| [][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[] | |
| ][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][ | |
| ][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[ | |
| ]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[] | |
| ][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][ | |
| ][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][] | |
| [][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][] | |
| [][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[ | |
| []][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][ | |
| []][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]] | |
| [][[]][][][[[]]][][][][][[]][][[]][][][[[]][][[]][][][[]][][[]][][][[[ | |
| ]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]]][[][][[] | |
| ][][][[]][][[]][]][][][][][[]][][][[]][][[]]][[][][[]][][][[]][][[]][] | |
| [][][][][[]][][][[]][][[]][]][][[[]][][[]][][][[]][][][][][[[]][][[]][ | |
| ][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][] | |
| [[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][] | |
| [][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[ | |
| []][][]][[[]][][][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][ | |
| []][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]] | |
| [][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][ | |
| ]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][ | |
| ]][[[]][][]][[[]][][][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[] | |
| ][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][] | |
| [[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][ | |
| []][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][ | |
| ][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]] | |
| [][][[[]][][[]][][][[]][][][][]][[[]][][]][[[]][][][]][][][][[]][][][] | |
| [][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[] | |
| ][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[] | |
| ][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][] | |
| [[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[ | |
| ]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][ | |
| []]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[] | |
| ][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][] | |
| [][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]] | |
| [][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]] | |
| [[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[ | |
| []][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][] | |
| [][[]][][][[]][][[]][][][[[]]][][][][][[]][][[]][][][[[]][][[]][][][[] | |
| ][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][] | |
| [[]][][][[[]][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]] | |
| [][[]]][[[]][][[]][]][][][][[]]][[][][[]][][][[]][][[]][]][][][][][[]] | |
| [][][[]][][[]]][[][][[]][][][[]][][[]][][][][][][[]][][][[]][][[]][]][ | |
| ][[[]][][[]][][][[]][][][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[ | |
| []][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][ | |
| []][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]] | |
| [][[]][][][[[]][][[]][][][[]][][][][]][[[]][][]][[[]][][][]][][][][[]] | |
| [][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][]] | |
| [[[]][][][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][ | |
| []][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]] | |
| [][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][] | |
| [[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][ | |
| ][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][ | |
| []][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]] | |
| [][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][ | |
| ]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][ | |
| ]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][] | |
| [[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][] | |
| [][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[] | |
| ][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[] | |
| ][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][] | |
| [[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[ | |
| ]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][ | |
| []]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[] | |
| ][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][] | |
| [][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]] | |
| [][][][[]][][][][][][[]][][][[]][][[]][][][[[]]][][][][][[]][][[]][][] | |
| [[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][] | |
| [][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[] | |
| ][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[] | |
| ][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][ | |
| ][[]]][[][][[]][][][[]][][[]][]][][][][][[]][][][[]][][[]]][[][][[]][] | |
| [][[]][][[]][][][][][][[]][][][[]][][[]][]][][[[]][][[]][][][[]][][][] | |
| [][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][] | |
| [][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][[]][][][[[]][][[]][] | |
| [][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]]][[][][[]][][][[]][ | |
| ][[]][]][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[] | |
| ][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][ | |
| ][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[ | |
| ]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[] | |
| ][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][ | |
| ][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][] | |
| [][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][] | |
| [][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[ | |
| []][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][ | |
| []][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]] | |
| [][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][] | |
| [[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][ | |
| ][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][ | |
| []][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]] | |
| [][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][ | |
| ]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][ | |
| ]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][] | |
| [[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][] | |
| [][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[] | |
| ][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]]][][][][][[]] | |
| [][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][] | |
| [[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][ | |
| ][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][ | |
| []][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]] | |
| [][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][ | |
| ]][][][][[]][][][][][][[]][][][[]][][[]]][[][][[]][][][[]][][[]][][][] | |
| [][][[]][][][[]][][[]][]][][[[]][][[]][][][[]][][][][][[[]][][[]][][][ | |
| []][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]] | |
| [][[]][][][[[]][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[ | |
| ]][][[]]][[[]][][[]][]][][][][[]]][[][][[]][][][[]][][[]][]][][][][][[ | |
| ]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[] | |
| ][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][ | |
| ][]][[[]][][]][[[]][][][]][][][][[]][][][][][][[]][][][[]][][[]][][][[ | |
| []][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][] | |
| [][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][ | |
| ][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][ | |
| ][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[ | |
| ]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]] | |
| [][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[] | |
| ]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][ | |
| ][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][] | |
| [[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][] | |
| [][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[ | |
| []][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[] | |
| ][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][] | |
| [[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][ | |
| []][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][ | |
| ][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]] | |
| [][][[[]]][][][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[] | |
| ]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][ | |
| ][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][] | |
| [[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][] | |
| [][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[ | |
| []][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[] | |
| ][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]] | |
| [][[]][]][][][][[]]][[][][[]][][][[]][][[]][]][][][][][[]][][][[]][][[ | |
| ]]][[][][[]][][][[]][][[]][][][][][][[]][][][[]][][[]][]][][[[]][][[]] | |
| [][][[]][][][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]] | |
| [][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]] | |
| [[[]][][]][[[]][][][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][ | |
| ][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[ | |
| ]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[] | |
| ][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][ | |
| ][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][] | |
| [][[[]][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]] | |
| ][[[]][][[]][]][][][][[]]][[][][[]][][][[]][][[]][]][][][][][[]][][][[ | |
| ]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][] | |
| [][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[] | |
| ][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][ | |
| ][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[ | |
| ]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[] | |
| ][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][ | |
| ][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][] | |
| [][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][] | |
| [][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[ | |
| []][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][ | |
| []][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]] | |
| [][[]][][][[[]]][][][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[] | |
| ][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][ | |
| ][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[ | |
| ]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[] | |
| ][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][[] | |
| ][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]]] | |
| [[][][[]][][][[]][][[]][]][][][][][[]][][][[]][][[]][][][[[]][][[]][][ | |
| ][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[ | |
| ]][][[]][][][[[]][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][ | |
| [[]][][[]]][[[]][][[]][]][][][][[]]][[][][[]][][][[]][][[]][]][][][][] | |
| [[]][][][[]][][[]]][[][][[]][][][[]][][[]][][][][][][[]][][][[]][][[]] | |
| []][][[[]][][[]][][][[]][][][][][[[]][][[]][][][[]][][][][]][[[]][][[] | |
| ]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][ | |
| ][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][] | |
| [[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][] | |
| [][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[ | |
| []][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[] | |
| ][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][] | |
| [[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][ | |
| []][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][ | |
| ][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]] | |
| [][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][] | |
| [][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][]][[ | |
| []][][][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[] | |
| ][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][] | |
| [[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[ | |
| ]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][ | |
| []]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[] | |
| ][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][] | |
| [][[]][][[]][][][[[]]][][][][][[]][][[]][][][[[]][][[]][][][[]][][][][ | |
| ]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][] | |
| [[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][] | |
| [][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][]][[[]][ | |
| ][][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][ | |
| ][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]] | |
| [][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][] | |
| [][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]] | |
| [[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][ | |
| ][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][ | |
| ][][][[]]][[][][[]][][][[]][][[]][]][][][][][[]][][][[]][][[]]][[][][[ | |
| ]][][][[]][][[]][][][][][][[]][][][[]][][[]][]][][[[]][][[]][][][[]][] | |
| [][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]] | |
| [][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][]] | |
| [[[]][][][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][ | |
| []][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]] | |
| [][[]][][][[[]][][[]][][][[]][][][][]][[[]][][]][[[]][][][]][][][][[]] | |
| [][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[] | |
| ]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][ | |
| ][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][] | |
| [[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][] | |
| [][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[ | |
| []][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[] | |
| ][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][] | |
| [[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][ | |
| []][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][ | |
| ][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]] | |
| [][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][] | |
| [][][][][[]][][][[]][][[]][][][[[]]][][][][][[]][][[]][][][[[]][][[]][ | |
| ][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][] | |
| [[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][] | |
| [][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[ | |
| []][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[] | |
| ][][[]][][][[]][][][][]][[[]][][]][[[]][][][]][][][][[]][][][][][][[]] | |
| [][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][ | |
| ]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][ | |
| ]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][] | |
| [[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][] | |
| [][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][[]][][][[[]][][[]][][] | |
| [[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]]][[][][[]][][][[]][][ | |
| []][]][][][][][[]][][][[]][][[]]][[][][[]][][][[]][][[]][][][][][][[]] | |
| [][][[]][][[]][]][][[[]][][[]][][][[]][][][][][[[]][][[]][][][[]][][][ | |
| ][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][] | |
| [][[[]][][[]][][][[]][][][][]][[[]][][]][[[]][][][]][][][][[]][][][][] | |
| [][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][]][[[]][][ | |
| ][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][ | |
| ][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][] | |
| [][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][] | |
| [][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[ | |
| []][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][ | |
| []][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]] | |
| [][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][] | |
| [[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][ | |
| ][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][ | |
| []][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]] | |
| [][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][ | |
| ]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]]][][][][][[]][][[]][] | |
| [][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][] | |
| [][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[ | |
| []][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][ | |
| []][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]] | |
| [][[]][][][[[]][][[]][][][[]][][][][]][[[]][][]][[[]][][][]][][][][[]] | |
| [][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[] | |
| ]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][ | |
| ][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][] | |
| [[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][] | |
| [][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[ | |
| []][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[] | |
| ][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]] | |
| [][[]][]][][][][[]]][[][][[]][][][[]][][[]][]][][][][][[]][][][[]][][[ | |
| ]]][[][][[]][][][[]][][[]][][][][][][[]][][][[]][][[]][]][][[[]][][[]] | |
| [][][[]][][][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]] | |
| [][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]] | |
| [[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[ | |
| []][][[]][][][[]][][][][]][[[]][][]][[[]][][][]][][][][[]][][][][][][[ | |
| ]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][]][[[]][][][]] | |
| [][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]] | |
| [[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[ | |
| []][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][] | |
| [][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][ | |
| ][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][ | |
| ][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[ | |
| ]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]] | |
| [][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[] | |
| ]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]]][][][] | |
| [][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]] | |
| [][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]] | |
| [[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[ | |
| []][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][] | |
| [][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][ | |
| ][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][ | |
| ][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[ | |
| ]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]] | |
| [][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[] | |
| ]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][ | |
| ][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][] | |
| [[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][] | |
| [][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][[]][][][ | |
| [[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]]][[][][ | |
| []][][][[]][][[]][]][][][][][[]][][][[]][][[]]][[][][[]][][][[]][][[]] | |
| [][][][][][[]][][][[]][][[]][]][][[[]][][[]][][][[]][][][][][[[]][][[] | |
| ][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][] | |
| [][[]][][[]][][][[[]][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][] | |
| []][[[]][][[]]][[[]][][[]][]][][][][[]]][[][][[]][][][[]][][[]][]][][] | |
| [][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[] | |
| ][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[] | |
| ][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][] | |
| [[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[ | |
| ]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][ | |
| []]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[] | |
| ][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][] | |
| [][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]] | |
| [][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]] | |
| [[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[ | |
| []]][][][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[] | |
| ][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[] | |
| ][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][] | |
| [[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[ | |
| ]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][ | |
| []]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[] | |
| ][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][] | |
| [][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]] | |
| [][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]] | |
| [[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[ | |
| []][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][] | |
| [][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][ | |
| ][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][ | |
| ][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[ | |
| ]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]] | |
| [][][][][][[]][][][[]][][[]]][[][][[]][][][[]][][[]][][][][][][[]][][] | |
| [[]][][[]][]][][[[]][][[]][][][[]][][][][][[[]][][[]][][][[]][][][][]] | |
| [[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[ | |
| []][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[ | |
| ]][][[]][]][][][][[]]][[][][[]][][][[]][][[]][]][][][][][[]][][][[]][] | |
| [[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[ | |
| ]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][ | |
| []]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[] | |
| ][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][] | |
| [][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]] | |
| [][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]] | |
| [[[]][][]][[[]][][][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][ | |
| ][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[ | |
| ]][][][[]][][[]][][][[[]]][][][][][[]][][[]][][][[[]][][[]][][][[]][][ | |
| ][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]] | |
| [][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][] | |
| [][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]] | |
| [[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][ | |
| ][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[ | |
| ]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][] | |
| [][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[] | |
| ][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][ | |
| ][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[ | |
| ]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[] | |
| ][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][ | |
| ][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][] | |
| [][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][] | |
| [][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[ | |
| []][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][ | |
| []][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][ | |
| ][][[]]][[][][[]][][][[]][][[]][]][][][][][[]][][][[]][][[]]][[][][[]] | |
| [][][[]][][[]][][][][][][[]][][][[]][][[]][]][][[[]][][[]][][][[]][][] | |
| [][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][] | |
| [][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][]][[ | |
| []][][][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[] | |
| ][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][] | |
| [[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[ | |
| ]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][ | |
| []]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[] | |
| ][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][] | |
| [][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]] | |
| [][][][[]][][][][][][[]][][][[]][][[]][][][[[]]][][][][][[]][][[]][][] | |
| [[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][] | |
| [][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[] | |
| ][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[] | |
| ][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][] | |
| [[]][][][[[]][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]] | |
| [][[]]][[[]][][[]][]][][][][[]]][[][][[]][][][[]][][[]][]][][][][][[]] | |
| [][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][ | |
| ]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][ | |
| ]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][] | |
| [[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][] | |
| [][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[] | |
| ][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[] | |
| ][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][] | |
| [[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[ | |
| ]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][[]][][][[[]][] | |
| [[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]]][[][][[]][][ | |
| ][[]][][[]][]][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][ | |
| ]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][] | |
| [[[]][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][ | |
| [[]][][[]][]][][][][[]]][[][][[]][][][[]][][[]][]][][][][][[]][][][[]] | |
| [][[]]][[][][[]][][][[]][][[]][][][][][][[]][][][[]][][[]][]][][[[]][] | |
| [[]][][][[]][][][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[] | |
| ][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][ | |
| ][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][] | |
| [][[[]][][[]][][][[]][][][][]][[[]][][]][[[]][][][]][][][][[]][][][][] | |
| [][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][]][[[]][][ | |
| ][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][ | |
| ][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][] | |
| [][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][] | |
| [][][][[]][][][[]][][[]][][][[[]]][][][][][[]][][[]][][][[[]][][[]][][ | |
| ][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[ | |
| ]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][] | |
| [][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[] | |
| ][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][ | |
| ][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[ | |
| ]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[] | |
| ][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][ | |
| ][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][] | |
| [][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][] | |
| [][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[ | |
| []][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][ | |
| []][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]] | |
| [][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][] | |
| [[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][ | |
| ][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][ | |
| []][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]] | |
| [][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][ | |
| ]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][[]][ | |
| ][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]]][[ | |
| ][][[]][][][[]][][[]][]][][][][][[]][][][[]][][[]]][[][][[]][][][[]][] | |
| [[]][][][][][][[]][][][[]][][[]][]][][[[]][][[]][][][[]][][][][][[[]][ | |
| ][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[ | |
| ]][][][[]][][[]][][][[[]][][[]][][][[]][][[]][][][[[]][][[]][][][[]][] | |
| [][][]][[[]][][[]]][[[]][][[]][]][][][][[]]][[][][[]][][][[]][][[]][]] | |
| [][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]] | |
| [[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][ | |
| ][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[ | |
| ]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][] | |
| [][[]][][][][][][[]][][][[]][][[]][][][[[]]][][][][][[]][][[]][][][[[] | |
| ][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][] | |
| [[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][ | |
| []][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][ | |
| ][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]] | |
| [][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][] | |
| [][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]] | |
| [[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][ | |
| ][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[ | |
| ]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][] | |
| [][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[] | |
| ][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][ | |
| ][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[ | |
| ]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[] | |
| ][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][ | |
| ][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][] | |
| [][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][] | |
| [][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[ | |
| []][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][ | |
| []][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]] | |
| [][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][] | |
| [[]][][][][][][[]][][][[]][][[]]][[][][[]][][][[]][][[]][][][][][][[]] | |
| [][][[]][][[]][]][][[[]][][[]][][][[]][][][][][[[]][][[]][][][[]][][][ | |
| ][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][] | |
| [][[[]][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]] | |
| ][[[]][][[]][]][][][][[]]][[][][[]][][][[]][][[]][]][][][][][[]][][][[ | |
| ]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][] | |
| [][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[] | |
| ][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]]] | |
| [][][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][ | |
| []][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][ | |
| ][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]] | |
| [][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][] | |
| [][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]] | |
| [[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][ | |
| ][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[ | |
| ]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][] | |
| [][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[] | |
| ][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][ | |
| ][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[ | |
| ]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[] | |
| ][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][ | |
| ][]][[[]][][]][[[]][][][]][][][][[]][][][][][][[]][][][[]][][[]][][][[ | |
| []][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][] | |
| [][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][ | |
| ][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][ | |
| ][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[ | |
| ]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]] | |
| [][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[] | |
| ]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][ | |
| ][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][] | |
| ][][][][[]]][[][][[]][][][[]][][[]][]][][][][][[]][][][[]][][[]]][[][] | |
| [[]][][][[]][][[]][][][][][][[]][][][[]][][[]][]][][[[]][][[]][][][[]] | |
| [][][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[ | |
| ]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][ | |
| []]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[] | |
| ][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][] | |
| [][[]][][[]][][][[[]]][][][][][[]][][[]][][][[[]][][[]][][][[]][][][][ | |
| ]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][] | |
| [[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][] | |
| [][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[] | |
| ][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[] | |
| ][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][] | |
| [[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[ | |
| ]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][ | |
| []]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[] | |
| ][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][] | |
| [][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]] | |
| [][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]] | |
| [[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[ | |
| []][][[]][][][[]][][][][]][[[]][][]][[[]][][][]][][][][[]][][][][][][[ | |
| ]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[] | |
| ][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][ | |
| ][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][] | |
| [][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][] | |
| [][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[ | |
| []][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][ | |
| []][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][ | |
| ][][[]]][[][][[]][][][[]][][[]][]][][][][][[]][][][[]][][[]][][][[[]][ | |
| ][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[ | |
| ]][][][[]][][[]][][][[[]][][[]][][][[]][][[]][][][[[]][][[]][][][[]][] | |
| [][][]][[[]][][[]]][[[]][][[]][]][][][][[]]][[][][[]][][][[]][][[]][]] | |
| [][][][][[]][][][[]][][[]]][[][][[]][][][[]][][[]][][][][][][[]][][][[ | |
| ]][][[]][]][][[[]][][[]][][][[]][][][][][[[]][][[]][][][[]][][][][]][[ | |
| []][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[] | |
| ][][[]][][][[]][][][][]][[[]][][]][[[]][][][]][][][][[]][][][][][][[]] | |
| [][][[]][][[]][][][[[]]][][][][][[]][][[]][][][[[]][][[]][][][[]][][][ | |
| ][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][] | |
| [][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][] | |
| [][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[ | |
| []][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][ | |
| []][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]] | |
| [][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][] | |
| [[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][ | |
| ][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][ | |
| []][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]] | |
| [][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][ | |
| ]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][ | |
| ]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][] | |
| [[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][] | |
| [][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[] | |
| ][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[] | |
| ][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][] | |
| [[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[ | |
| ]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][ | |
| []]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[] | |
| ][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][] | |
| [][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]] | |
| [][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]] | |
| [[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[ | |
| []][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][] | |
| [][[]][][][[]][][[]]][[][][[]][][][[]][][[]][][][][][][[]][][][[]][][[ | |
| ]][]][][[[]][][[]][][][[]][][][][][[[]][][[]][][][[]][][][][]][[[]][][ | |
| []]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]]][][] | |
| [][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][ | |
| ]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][ | |
| ]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][] | |
| [[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][] | |
| [][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[] | |
| ][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[] | |
| ][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][] | |
| [[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[ | |
| ]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][ | |
| []]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[] | |
| ][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][] | |
| [][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]] | |
| [][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]] | |
| [[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[ | |
| []][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][] | |
| [][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][ | |
| ][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][ | |
| ][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[ | |
| ]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]] | |
| [][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[] | |
| ]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][ | |
| ][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][] | |
| [[]][][[]][][][[[]][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][] | |
| [][][[]][][][][][][[]][][][[]][][[]][][][[[]][][[]][][][[]][][][][]][[ | |
| []][][[]]][[[]][][[]][]][][][][[]][][][][][][[]][][][[]][][[]][][][[[] | |
| ][][[]][][][[]][][][][]][[[]][][[]]][[[]][][[]][]][][][][[]][][][][][] | |
| [[]][][][[]][][[]]][[][][[]][][][[]][][[]][][][][][][[]][][][[]][][[]] | |
| []][]] | |
| </pre> | |
| <h2><span class="mw-headline" id="See_also">See also</span></h2> | |
| <ul><li><a href="/wiki/Etre" title="Etre">Etre</a> - The author's earlier minimal loop-based language (parentheses + one instruction).</li></ul> | |
| <h2><span class="mw-headline" id="External_resources">External resources</span></h2> | |
| <ul><li><a class="external text" href="http://yiap.nfshost.com/esoteric/exoshell/exoshell.html" rel="nofollow">Exoshell information</a> (more detailed explanations of the language, translator program, interpreter in Python)</li></ul> | |
| <!-- | |
| NewPP limit report | |
| Cached time: 20251201164647 | |
| Cache expiry: 86400 | |
| Reduced expiry: false | |
| Complications: [show‐toc] | |
| CPU time usage: 0.116 seconds | |
| Real time usage: 0.117 seconds | |
| Preprocessor visited node count: 4469/1000000 | |
| Post‐expand include size: 0/2097152 bytes | |
| Template argument size: 0/2097152 bytes | |
| Highest expansion depth: 2/100 | |
| Expensive parser function count: 0/100 | |
| Unstrip recursion depth: 0/20 | |
| Unstrip post‐expand size: 0/5000000 bytes | |
| --> | |
| <!-- | |
| Transclusion expansion time report (%,ms,calls,template) | |
| 100.00% 0.000 1 -total | |
| --> | |
| <!-- Saved in parser cache with key esolang_wiki:pcache:idhash:24242-0!canonical and timestamp 20251201164647 and revision id 169712. Rendering was triggered because: page-view | |
| --> | |
| </div> | |
| <div class="mw-content-ltr mw-parser-output" dir="ltr" lang="en"><p><b>Execode</b> is an <a href="/wiki/Esoteric_programming_language" title="Esoteric programming language">esoteric programming language</a> created in 2024 by <a href="/wiki/User:Iddi01" title="User:Iddi01">User:iddi01</a> carefully designed to be easy to program in, easy to implement, easy to read, and to have ability in <a class="mw-redirect" href="/wiki/Code_golf" title="Code golf">code golfing</a>. Those are, of course, only relative, since maximizing one of them means losing the others. Execode is <a href="/wiki/Stack-based" title="Stack-based">stack-based</a>, although it can be considered as <a href="/wiki/Deque" title="Deque">deque</a>-based due to the reversing command. | |
| </p> | |
| <table style="float:right;border:1px solid silver;background-color:rgb(249, 249, 249);max-width:256px;padding:5px;"> | |
| <caption><b>Execode</b></caption> | |
| <tbody><tr> | |
| <th style="text-align: left;vertical-align: top;"><a href="/wiki/Esolang:Categorization#Paradigm" title="Esolang:Categorization">Paradigm(s)</a></th> | |
| <td>functional</td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;">Designed by</th> | |
| <td><a href="/wiki/User:Iddi01" title="User:Iddi01">User:iddi01</a></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;"><a href="/wiki/Category:Years" title="Category:Years">Appeared in</a></th> | |
| <td><a href="/wiki/Category:2024" title="Category:2024">2024</a></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;"><a href="/wiki/Esolang:Categorization#Memory" title="Esolang:Categorization">Memory system</a></th> | |
| <td>stack-based or deque-based</td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;"><a href="/wiki/Esolang:Categorization#Dimensions" title="Esolang:Categorization">Dimensions</a></th> | |
| <td>one-dimensional</td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;"><a href="/wiki/Computational_class" title="Computational class">Computational class</a></th> | |
| <td><a class="mw-redirect" href="/wiki/Turing_complete" title="Turing complete">Turing complete</a></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;">Reference implementation</th> | |
| <td><a class="external text" href="https://esolangs.org/wiki/Execode/Original_implementation" rel="nofollow">Original implementation</a></td> | |
| </tr> | |
| <tr> | |
| <th style="text-align: left;vertical-align: top;">File extension(s)</th> | |
| <td><code>.ec</code></td> | |
| </tr> | |
| </tbody></table><p>Unlike most other languages, Execode focuses on functions for control flow, for the purpose of reusable code, such that, Execode programs will become shorter and shorter compared to other languages of similar complexity as the programs gets more complex. | |
| </p><p>The character of Execode is <i>controlled minimization</i>: It does not include any unnecessary commands and commands that don't give it more advantage over languages of similar complexity. For example, instead of having a push and pop command for both sides of the stack/deque, it uses a reversing command to reduce it to three commands. And, it has a <code>gt</code> but no <code>lt</code>, for < is basically > in reverse! Also, it has no arithmetic commands except for increment/decrement by 1 since they can be implemented easily using <code>rep</code>eats and functions (see <a class="mw-selflink-fragment" href="#Techniques">Techniques</a>). | |
| </p><p>Arbitrary number of stacks, variables, and functions can be defined using the <code>def</code> command. Variables and functions are essential, and you can do next to nothing without them. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment