Baz
Three values, true, false and baz, where baz was meant to be a coin toss.
OriginalOldMan, 2013 · Turing complete: unknown · ●○○ easy · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
OriginalOldMan made Baz in 2013. A variable holds true, false or baz and nothing else. The specification says an if on a baz runs its body half the time. Every error reads YOU ARE WRONG!@ followed by the line number, and that error is the only quine, one that works by failing.
The machine
| Line | Does |
|---|---|
x = y | Copy the value of y; true, false and baz hold themselves |
show x | Print the value and a line feed |
get x | Read a line, which must be true, false or baz |
if x | Skip to the next endif when x is false |
if! x | Skip to the next endif when x is true |
goto n | Go to line n |
end | Stop |
This implementation follows the specification's interpreter, a short Ruby program. There a baz always skips the body of if and of if!. Ruby reads x = v == "baz" and rand(2) == 1 as the assignment x = v == "baz" and then a test whose answer is thrown away, so the coin is tossed but never looked at. An empty line in the middle of a program is an error too.
Example
The cat and the truth machine from the specification.
The cat and the truth machine from the specification. The truth machine uses the words false and true for 0 and 1, and on true it prints true forever.
A baz skips both kinds of if, so only the last line prints.
The quine by error. The first word is no command, so line 1 is wrong.
Patterns it teaches
- Quine: only by way of the error message.
Further
See also
Also in Jokes
Write your own in Run Convert a program from Baz
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: baz.
Command line
shib run baz -e 'get x
show x' --input 'true'shib manual bazSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/baz.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org