Number Factory
A robot carries one number at a time between twenty rooms, and the rooms do the arithmetic.
2017 · Turing complete: conjectured · ●●○ moderate · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
The program is a list of errands for a robot in a factory nobody orders from any more. The robot can walk one room in four directions and pick up or put down a number. It cannot add. Adding happens in the fusing machine, where two numbers put down become their sum. Comparing happens in quality control, which writes its verdict into the command center, and the command center decides the loops. So a program is a route, and the programmer has to keep track of where the robot is and what every room holds.
The machine
The factory is 4 rooms high and 5 wide, and walking off an edge comes back on the other side. The robot starts in X.
0 1 2 T %
- S P Q *
+ # @ C &
= / X ! ~
| Command | Does |
|---|---|
> < ^ V | Walk one room |
% | Put down the number held, or pick one up |
( | Skip past the matching ) if X holds 0 |
) | Go back to the matching ( unless X holds 0 |
| Room | Does |
|---|---|
0 1 2 T | Give 0, 1, 2 or 10, and never run out |
+ - | Add or subtract the second number put down |
# | Keep a number and drop a copy in @ |
S P Q | Two stacks and a queue |
C @ X | Keep one number; X starts with 1 |
= / | Compare two numbers and put 1 or 0 in X |
! | Keep 1 for 0 and 0 for anything else |
% | Read a number when the robot walks in |
* ~ & | Print a number, post a letter, or throw it away |
The post office ~ turns 1 to 26 into A to Z, 0 into a space and 27 into a line feed. Every other character is a comment. The specification leaves open how a printed number ends; it gets a line feed.
Example
The first line of the Hello world.
The first line of the Hello world. The robot takes a 10 from T and a 2 from 2, subtracts them in the carving machine and posts the 8, which is H.
The whole Hello world, without the notes of which letter each line posts.
The cat walks into the receiving dock, which reads a number, and carries it down to shipping. It loops while X still holds its 1, and ends when the input runs out.
The Fibonacci program prints 1, 1, 2, 3, 5 and so on for ever.
Further
See also
Queue-based
Stack-based
Write your own in Run Convert a program from Number Factory
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: number-factory.
Command line
shib run number-factory -e '>>^^^(%V%^)' --input '5
-12
'shib manual number-factorySource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/number-factory.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org