TriTape
Brainfuck in base 3. Every cell holds 0, 1 or 2, and every test asks the accumulator.
Joaozin003, 2023 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
Joaozin003 made TriTape in 2023. The tape runs only to the right and each cell holds a trit, a base 3 digit. Beside it sits an accumulator of one trit. The cells cannot be tested directly. A program copies a cell into the accumulator with = and then loops on that.
Read the story
There are two kinds of loop. [ ] runs while the accumulator is not 0 and { } runs while it is 0. Moving left from the first cell does not fail. It writes the accumulator into that cell, which programs use as a second way to store.
The machine
| Char | Does |
|---|---|
^ v | Count the accumulator up or down, 2 wraps to 0 |
> < | Move right or left; < on the first cell copies the accumulator into it |
= | Copy the cell into the accumulator |
0 | Zero the cell |
+ | Add the accumulator into the cell, modulo 3 |
, . | Read a trit into the cell, print the cell as a digit |
[ ] | Skip past ] if the accumulator is 0; ] jumps back to [ |
{ } | Skip past } if the accumulator is not 0; } jumps back to { |
Input is read as the next 0, 1 or 2 in the text, and the end of the input reads 0. The specification shows that TriTape holds Boolfuck, so it is Turing complete.
Example
The numeric cat.
The numeric cat. It prints each trit it reads and stops at a 0.
The repeated printing. It puts a 1 in the first cell with <, walks five cells right and then back, adding a 1 into each cell and printing it, until = finds the 1 in the first cell.
The truth machine prints 0 and stops on 0. On 1 or 2 it prints that digit forever.
Patterns it teaches
- Turing tarpit: thirteen one-character commands on trits.
- Turing completeness: shown by translating Boolfuck into it.
Further
See also
Also in Turing tarpits
Write your own in Run Convert a program from TriTape
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: tritape.
Command line
shib run tritape -e ',=[.].' --input '0'shib manual tritapeSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/tritape.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org