esolang

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

Expected: Hello world!

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

ABCRDoes
abcDequeue into R
ABCEnqueue R
123Copy the front into R
!@#Set R to the length
*+,Dequeue and add to R
-./Dequeue and take from R
opqPrint the front as a number
OPQPrint the front as a character
4567Start a loop, and skip past its x when the front is 0
( )Take 1 from R, add 1 to R
iRead 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.

Expected: 0

Six times seven. A counts 7 down while C adds 6 each time round.

Expected: 42

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

Further

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 abcr

Source

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