ABC
One accumulator, a handful of letters, and a loop that can only go back to the very start.
Orange, 2008 · Turing complete: no · ●○○ easy · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
Orange made ABC in 2008, and the specification calls it very simple and easy to implement. It has one accumulator. a and b count it up and down, and c prints it. $ switches c between printing a number and printing a character, so text is spelled by counting from one code to the next. The only control flow is l, which jumps back to the start without resetting anything. A program runs straight through once, or forever.
Read the story
The specification says ABC has nothing to do with the real programming language of that name.
The machine
| Char | Does |
|---|---|
a b | Add 1, take 1 away |
c | Print the accumulator, as a number or in ASCII mode as a character |
d | Negate it |
r | Set it to a random number from 0 to itself |
n | Set it to 0 |
$ | Switch ASCII mode on or off |
l | Go back to the start of the program |
; | Print it as a number, a space and a character |
Every other character does nothing. The specification gives two interpreters that differ. This implementation follows the Java one, because the specification's 1337 example prints 1337 only there. The Python one puts a space after each number.
Example
The accumulator goes to 1, 3, 3 and 7, and c prints it each time with nothing in between.
The accumulator goes to 1, 3, 3 and 7, and c prints it each time with nothing in between.
The Hello World switches to ASCII mode, counts 72 for the H and walks up and down from letter to letter. Twice n starts again from 0, for the comma and for the closing 33. The line breaks are characters it ignores.
Further
See also
Also in Turing tarpits
Write your own in Run Convert a program from ABC
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: abc.
Command line
shib run abc -e 'acaaccaaaac'shib manual abcSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/abc.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org