ABCR
Three queues and a register, and each queue has its own idea of what an empty queue holds.
Steven Hewitt, 2016 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
Steven Hewitt made ABCR in 2016. It has three first in, first out queues, A, B and C, which hold integers of any size, and a register R that holds the result of the last operation. Most commands come in threes, one character for each queue. An empty queue is never an error. A gives 0, B gives 1, and C reads input when it is popped and gives R when it is peeked.
The machine
| A | B | C | R | Does |
|---|---|---|---|---|
a | b | c | Dequeue into R | |
A | B | C | Enqueue R | |
1 | 2 | 3 | Copy the front into R | |
! | @ | # | Set R to the length | |
* | + | , | Dequeue and add to R | |
- | . | / | Dequeue and take from R | |
o | p | q | Print the front as a number | |
O | P | Q | Print the front as a character | |
4 | 5 | 6 | 7 | Start a loop, and skip past its x when the front is 0 |
( ) | Take 1 from R, add 1 to R | |||
i | Read a signed number into R |
x ends a loop and goes back to its start. R starts at 0. Popping an empty C takes the next input character and queues the rest of the input in C.
Example
The Hello World.
The Hello World. R counts to 10 and A gets 30 tens, then R drops to 5 and B gets 9 fives. Each line adds and takes tens and fives and puts the next letter in C. The last line puts a 0 behind the letters and prints C until it reaches the 0.
The truth machine reads a number into A. On 0 the loop is skipped and the last o prints 0 once; on 1 the loop prints 1 forever.
Six times seven. A counts 7 down while C adds 6 each time round.
Under these rules the specification's cat, cC6QcCx, does not echo. Its first c reads the first character and queues the rest in C, and the loop then turns C round and round from the second character on.
Patterns it teaches
- Counter machines: unbounded counts in queues, a test for 0 and a loop.
Further
See also
Queue-based
Write your own in Run Convert a program from ABCR
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: abcr.
Command line
shib run abcr -e 'iA4oxo' --input '0'shib manual abcrSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/abcr.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org