Briefscript
Made to be as short as possible. Hello World is H, a factorial is iF and a truth machine is ios.
2015 · Turing complete: unknown · ●○○ easy · esolangs.org
Tested with 9 known programs · Test method
Run it
The idea
Briefscript wins at code golf the way HQ9+ does. The common exercises are built in, one character each. The specification lists Hello World, the quine, factorial, roman numerals, a coin, a palindrome test, the 99 bottles of beer, Underload and the strange numbers. It says Briefscript always had shorter code than Microscript.
Read the story
Around the built ins sit two registers, CX and BX, input and output of numbers, a counted loop and two jumps. Those are enough for the cat, the sum of two inputs and the truth machine.
The machine
| Command | Does |
|---|---|
H Q | Print Hello, world! or Q |
z O | Print 0 or 1 |
i I | Read a number into CX, or two into CX and BX |
o | Print CX |
2 F | Square CX, or take its factorial, and print it |
a | Add BX to CX and print it |
R | Read roman numerals and print their value |
[ ] | Skip past ] if CX is 0; take 1 from CX and go back while it is not 0 |
1 | Jump to the first character |
s | Jump to the second character if the register is 1, else stop |
The specification lists C twice, for the coin and for the palindrome test, gives no text for the bottles of 9 and does not say what U and S do, so this implementation leaves those four out. Its s tests an AX that nothing sets; this implementation tests CX, which the truth machine needs.
Example
iO[z] reads 3, prints a 1 and then a 0 for each count of the loop.
iO[z] reads 3, prints a 1 and then a 0 for each count of the loop. The truth machine prints its input and stops on 0; on 1 it jumps back to o forever.
Patterns it teaches
Further
See also
Stack-based
Write your own in Run Convert a program from Briefscript
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: briefscript.
Command line
shib run briefscript -e 'H'shib manual briefscriptSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/briefscript.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org