Gearbox
A train of gears turned by the first one. The output is whatever the counters show when the machine stops.
Vizdun, 2022 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
Vizdun made Gearbox in 2022. A program declares gears and how they connect, and nothing else. The first gear, the original gear, is turned, and it turns all the others. There are no commands, no variables and no input. What a program prints depends only on tooth counts.
Read the story
A counter is a gear with symbols painted evenly around it. It shows the symbol it has reached in its current turn. An ender stops the machine once it has turned all the way round. So a program is a set of gear ratios, chosen so that every counter shows the right symbol at the moment the ender stops.
The machine
| Written | Is |
|---|---|
g12 | A gear with 12 teeth |
c10{"0","1",...} | A counter with 10 teeth and its symbols, with an optional label l"text" after them |
e60 | An ender with 60 teeth |
g6g12 | The g12 meshes with the g6 and turns the other way, at 6/12 of its speed |
g6[g12] | The g12 sits on the g6's axle and turns with it |
In this implementation the original gear turns one tooth per step. The run ends on the step an ender completes a turn, and then this implementation prints the counters in the order they are written, with counters that share a label on one line after it. A counter that turns backwards counts down. The specification puts a g1 before every counter, so each one is two meshes from the gear before it and turns forward.
Example
The counter turns once every 10 steps and the ender once every 3, so the machine stops three tenths of…
The counter turns once every 10 steps and the ender once every 3, so the machine stops three tenths of the way round the dial, on the 3.
The Hello World. The ender stops it after 60 steps. By then c214 has turned 60/214 of the way round and passed 7 of its 26 letters, so it shows H.
The clock has no ender, so it never stops, and each step is one second on its dial. With an ender added after it, such as e3725, it stops at 3,725 seconds, which is one hour, 2 minutes and 5 seconds.
The six-digit counter stops after 999,999 steps showing 999999.
Further
See also
Reversible computing
Concurrent programming
Write your own in Run Convert a program from Gearbox
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: gearbox.
Command line
shib run gearbox program.txtThe program is long; save it as program.txt first.
shib manual gearboxSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/gearbox.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org