4cell
Four cells named a to d, and a loop that knows before it starts how many times it will run.
Legoninjaenoch, 2022 · Turing complete: no · ●○○ easy · esolangs.org
Tested with 5 known programs · Test method
Run it
The idea
Legoninjaenoch made 4cell in 2022. The name says what it has, four cells called a, b, c and d. A lowercase letter adds 1 to its cell and the uppercase letter takes 1 away. The other commands copy, clear, add, subtract and print, and each one names its cells right after it, with no space.
Read the story
The one loop runs a block a set number of times. (a{...} reads cell a once, when the loop begins, and runs the block that many times, even when the block changes a. So every program ends, and the specification files 4cell as total.
The machine
| Command | Does |
|---|---|
a b c d | Add 1 to the cell |
A B C D | Take 1 from the cell |
>xy | Copy x into y |
!x | Set x to 0 |
?x | Set x to a random number from 1 to 144 |
+xyz -xyz | Set z to x plus y, or to x minus y |
.x ,x | Print x as a number, or as a character |
(x{...} | Run the block as many times as x says |
Spaces may stand between commands but not inside one, so >ab a b +abc runs and + a bc does not. The specification does not say how a number is printed. This implementation prints the digits alone with ..
Example
A Hello world.
A Hello world. Cell a counts to 8, and the loop adds 8 to it eight times, which makes 72, an H. Then b copies a, and the two walk up and down to the next letters. The space is c, 4 plus 7 four times, and d starts as a copy of the O and climbs 8 to the W.
The addition and copy programs leave their results in cells. With a print added they show them.
Further
See also
Cell-based
Write your own in Run Convert a program from 4cell
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: 4cell.
Command line
shib run 4cell -e 'ccc>cd'shib manual 4cellSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/4cell.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org