TPPL
The Toilet Paper Programming Language. Pull, wipe, rip and flush, and a character comes out.
Saka, 2018 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Saka made TPPL in 2018. A program starts by entering the restroom or the bathroom. The memory is a roll of toilet paper, a stack of sheets, and since the paper is 2-ply each sheet holds 0, 1 or 2. Only one sheet is visible at a time.
Read the story
Output is in base 3. To print a character you build its code on the roll, one digit a sheet, rip the sheets off into HOLD and flush them. Ripped paper can also go in the trash and come back later to be compared, which is the only way to branch on data.
The machine
| Instruction | Does |
|---|---|
ADD | Put a sheet worth 0 on top |
PULL | Show the next sheet up, back to the bottom past the top |
WIPE CLEAN | Add 1 to the shown sheet, or take 1 off |
RIP | Tear off the shown sheet and all below it into HOLD, top first |
FLUSH | Print HOLD, read in base 3, as a character |
TRASH DISCARD | Throw HOLD in the trash, or away for good |
TAKE n COPY n | Take trash item n back into HOLD, or a copy of it |
APPEND | Put HOLD back under the roll |
SET GET | Read a number into the shown sheet; read a character onto the roll in base 3 |
CHECK s YES? n | Go to line n if HOLD is the sequence s |
JUMP n SPIN n | Go to line n; move n lines |
EXIT | Leave the restroom |
Lines count from 0 at the ENTER line, which the truth machine needs. A line that starts with # is a comment.
Example
After the first, each character of the Hello, World! program starts on an empty roll.
After the first, each character of the Hello, World! program starts on an empty roll. For the H, three ADDs on the starting sheet make four sheets, PULL and WIPE make the top two worth 2, and RIP takes all four, top first, as 2200 in base 3. That is 72.
The cat rips off and discards the first sheet, so the roll holds only the digits GET puts there. A is 65, 2102 in base 3.
The truth machine reads its input onto the sheet, rips it into HOLD and checks it against the sequence 1. On 0 it prints 1210 in base 3, a 0, and leaves. On 1 it jumps to line 19 and prints 1211, a 1, for ever.
Patterns it teaches
- Stack machines: a roll of sheets, a hold slot and a trash stack.
Further
See also
Stack-based
Write your own in Run Convert a program from TPPL
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: tppl.
Command line
shib run tppl -e 'ENTER BATHROOM
RIP
DISCARD
GET
RIP
FLUSH
EXIT' --input 'A'shib manual tpplSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/tppl.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org