esolang

If a==1:

One number, three commands, and a program that only ends well when the number is 1.

Turing complete: no · ●○○ easy · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: 4 ERR: 4

The idea

If a==1: is a joke language with a single accumulator. A program ends quietly only when the accumulator is exactly 1. When it is anything else, the last thing the program prints is ERR: and the value. The specification files it under languages that are unusable for programming.

The machine

CommandDoes
+Add 1 to the accumulator
-Take 1 from it
.Print it as a number and a line feed

The accumulator starts at 0 and has no bounds. Every other character does nothing, line breaks too. The interpreter is 13 lines of Python that would not run as written, as they use break outside a loop; this implementation does what its text says.

Example

The XKCD random number prints 4, and as 4 is not 1, the error follows.

The XKCD random number prints 4, and as 4 is not 1, the error follows. Three - at the end bring the accumulator back to 1 and the error goes away.

Expected: 4

The specification also suggests reading the numbers as ASCII. Its Hello World prints 72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100 and 33, which spell Hello, world!, and its last 32 - bring the accumulator down from 33 to 1 so it ends without an error.

Further

Also in Jokes

Write your own in Run Convert a program from If a==1:

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: if-a-1.

Command line

shib run if-a-1 -e '++++.'
shib manual if-a-1

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/if-a-1.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org