Fit
A brainfuck cousin in balanced base 5, where every cell holds a digit from -2 to 2.
Madk, 2011 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
Madk made Fit in 2011. Its cells are fits, base 5 digits that run from -2 to 2. Adding 1 to 2 goes round to -2. With only five values in a cell there is no room to hold a character, so output goes through a separate byte counter. It starts at 59, the code of ;, which makes ; a quine.
Read the story
Fit has four kinds of loop, one for each test against 0. The specification shows it is Turing complete by translating Boolfuck into it, a bit flip being [--]+.
The machine
| Command | Does |
|---|---|
+ - | Turn the fit up or down, round from 2 to -2 |
~ | Negate the fit |
< > | Move left or right |
= | Delete the cell; the cells to its right move one place left |
( ) | Loop while the fit is not 0 |
{ } | Loop while the fit is negative |
[ ] | Loop while the fit is positive |
/ \ | Loop while the fit is 0 |
? ! ^ v | Pass over the next command if the fit is 0, not 0, positive, negative |
_ , ; | Clear the byte counter, add the fit to it, print it |
n . : | Print a line feed, print the fit as a number, read a number |
# | Start or end a comment |
The Hello World also uses ', which its table leaves out. The program only prints Hello, world! if ' doubles the counter, so this implementation does. That makes text cheap to write in binary, one doubling and one add per bit.
Example
The first H is built from 59, adding 2 six times and then 1.
The first H is built from 59, adding 2 six times and then 1. The e starts again from 0 and gets 2, doubled three times to 16.
Boolfuck's bit flip, twice. The first + sets the cell to 1. Then [--] takes it below 0 and + brings it to 0; on 0 the loop is passed over and + makes it 1 again.
Patterns it teaches
- Turing tarpit: a cell of five values and a byte counter are enough.
Further
See also
Cell-based
Write your own in Run Convert a program from Fit
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: fit.
Command line
shib run fit -e ';'shib manual fitSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/fit.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org