pb
The terminal is a canvas, and a program is a paintbrush that has to walk to every letter it paints.
undergroundmonorail, 2015 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
undergroundmonorail made pb in 2015. The program does not run in two dimensions; its output does. A brush moves over an endless canvas and paints one character at a time where it stands. Printing a word means painting a letter, stepping right, painting the next. In exchange, text can go anywhere, in any order, without spaces and line feeds to push it there.
Read the story
There are no variables of your own. The palette holds six, the brush's X and Y, the colour P, the character B and colour C under the brush, and T to keep one number. The input is painted on the row above the visible canvas, at Y = -1, so reading means walking up to it.
The machine
| Command | Does |
|---|---|
^ v < > | Move the brush one cell, or [n] cells |
t[e] | Set T |
b[e] | Paint the character with code e in colour P |
c | Next colour, 0 to 7 and round |
w[a!b]{...} | Run while a and b differ |
w[a=b]{...} | Run while a and b are equal |
# | Comment to the end of the line |
An expression is numbers and the six variables with + - * / %. When the run ends the canvas from row 0 down is the output. Colour is not shown, since the output is plain text.
Example
The cat walks along the input row.
The cat walks along the input row. For each byte it steps down, paints it, and steps back up and right.
The reverse takes the last byte of the input, blanks it, walks down to the first free cell of row 0 and paints it there, until the input row is empty.
Painting in any order. The c goes on first, two cells to the right, then the a and the b.
The rainbow paints the first input byte eight times, once in each colour, the last in black.
Patterns it teaches
- Counter machines: the specification shows pb is Turing complete with the brush's X and Y as the two counters of a Minsky machine.
Further
See also
Also in Spatial (2D and up)
Write your own in Run Convert a program from pb
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: pb.
Command line
shib run pb -e '^w[B!0]{t[B]vb[T]^>}' --input 'abc'shib manual pbSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/pb.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org