esolang

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

Expected: 7

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

CommandDoes
> <Move the pointer right or left
+ -Add or take away 1
!nJump to command n if the cell is not 0
. aPrint the cell as a number or as a character
, iRead 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.

Expected: 42

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

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 cork

Source

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