esolang

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

Expected: baz

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

LineDoes
x = yCopy the value of y; true, false and baz hold themselves
show xPrint the value and a line feed
get xRead a line, which must be true, false or baz
if xSkip to the next endif when x is false
if! xSkip to the next endif when x is true
goto nGo to line n
endStop

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.

Expected: false

A baz skips both kinds of if, so only the last line prints.

Expected: baz

The quine by error. The first word is no command, so line 1 is wrong.

Expected: YOU ARE WRONG!@1

Patterns it teaches

  • Quine: only by way of the error message.

Further

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 baz

Source

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