Pipe
One number that can only go up or back to 0, a stack beside it, and loops that never end by themselves.
RedwolfPrograms, 2019 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 5 known programs · Test method
Run it
The idea
RedwolfPrograms, a user of Programming Puzzles and Code Golf, made Pipe in 2019. All arithmetic happens in the pipe, a single number that starts at 0. It can be raised by 1 or reset to 0, never lowered. A stack holds the values the pipe is not using.
Read the story
A loop [...] runs forever. The only ways out are to skip its ] or to end the program, and the usual tool is ?, which skips the next command when the pipe is 0. Parentheses make scopes, and each scope has a stack of its own.
The machine
| Command | Does |
|---|---|
+ - | Add 1 to the pipe; set it to 0 |
# ^ | Push the pipe; pop into the pipe (0 from an empty stack) |
: | Set the pipe to the stack's length |
= | Set the pipe to 1 if it equals the top of the stack, else 0 |
< > | Read a character into the pipe; print the pipe unless it is 0 |
! ? | Skip the next command; skip it when the pipe is 0 |
[ ] | Loop forever |
( ) | A scope with its own stack |
~ | The next command uses the stack one scope further out |
; | End the program |
Skipping a [ or ( skips the whole loop or scope. Skipping a ) leaves the scope but keeps its stack for the next scope opened beside it. All 16 commands are in the table; every other character is whitespace.
Example
The cat reads until < finds no input and sets the pipe to 0.
The cat reads until < finds no input and sets the pipe to 0. Then > prints nothing and ? skips the ].
The scope example stores a character on the global stack and prints it from two scopes down.
This prints the ten digits. The 58 on the global stack is the end mark, the character code after 9, and the counter lives in a scope. ~= compares the counter with the mark, and ?!] loops while the comparison gives 0.
The Hello, world! pushes 13 characters backwards with 1,161 + and prints them with [^>:?].
Further
Ideas it shows
See also
Stack-based
Write your own in Run Convert a program from Pipe
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: pipe.
Command line
shib run pipe -e '[<>?]' --input 'Hello, cat!'shib manual pipeSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/pipe.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org