Cork
Brainfuck without brackets. A loop is a jump back to a numbered command.
Imaginer1, 2014 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
Imaginer1 made Cork in 2014, after brainfuck and the Wang B-machine. It keeps the tape, the pointer and the plus and minus, but drops the pair of brackets. The only control flow is !n, which jumps to command number n when the cell under the pointer is not 0.
Read the story
Commands are counted from 0, and !12 is one command. So every loop is a jump to an absolute place in the program, and adding one command in front moves every target after it.
The machine
| Command | Does |
|---|---|
> < | Move the pointer right or left |
+ - | Add or take away 1 |
!n | Jump to command n if the cell is not 0 |
. a | Print the cell as a number or as a character |
, i | Read a number or a character into the cell |
Every other character is skipped and not counted, and . prints a line feed after the number.
Example
The adder.
The adder. Commands 4 to 10 move the first number into the third cell, one at a time, and !4 jumps back until it is 0. Commands 12 to 16 do the same for the second number.
The multiplier. It adds the second number to the third cell once for every unit of the first, and copies it back from a fourth cell each time.
Both programs count down before they test, so they need inputs of 1 or more.
Patterns it teaches
- Turing tarpit: brainfuck's tape with a numbered jump for its loop.
Further
See also
Cork builds on Brainfuck.
Brainfuck derivatives
Cell-based
Write your own in Run Convert a program from Cork
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: cork.
Command line
shib run cork -e ',>,<->>+<<!4>->+<!12>.' --input '3 4'shib manual corkSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/cork.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org