esolang

Jormungandr

Brainfuck on a ring of cells that the program can grow and cut.

2026 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: Hello, world!

The idea

Jormungandr is a brainfuck from 2026 whose memory is a ring rather than a tape. The ring starts as one cell, and moving past either end comes round to the other. Four commands change the ring itself. ^ and = put new cells in before the pointer, X cuts cells out, and ? puts in the result of a comparison. Most commands take a count, so +72 adds 72 and >3 moves three cells.

Read the story

The specification says the language was first called Ouroboros, a name already taken, and was renamed after the Norse serpent that bites its own tail. Its nearest relative is Circlefuck.

The machine

CommandDoes
> < + - . , [ ]As in brainfuck
>n <n +n -nThe same n times
^ ^nPut 1 or n cells holding 0 before the pointer and move to the first
= =nThe same with copies of the current cell
X XnCut 1 or n cells from the pointer rightwards and move to the cell after them
ZSet the cell to 0
?Put 1 before the pointer if the current cell equals the next, else 0, and move to it

Cells hold 0 to 255 and wrap. X and ? on a ring of one cell are errors, and so are unmatched brackets.

Example

Each ^ puts a fresh cell before the last letter, so the letters pile up to the left.

Each ^ puts a fresh cell before the last letter, so the letters pile up to the left. >3 goes back to the o of Hello for world, and >2 to its l.

Expected: 4

The second line is the XKCD random number. The quine stores its second half as one ^+n per character. The second half then prints each stored number back as ^+n and after that the stored characters themselves.

Expected: ^+60^+50^+91^+61^+43^+61^+94^+43^+57^+52^+46^+45^+53^+49^+46^+43^+52^+62^+91^+63^+91^+45^+60^+43^+62^+51^+45^+49^+48^+60^+50^+93^+88^+45^+93^+60^+46^+88^+50^+43^+53^+55^+46^+60^+93^+60^+91^+46^+60^+50^+93<2[=+=^+94.-51.+4>[?[-<+>3-10<2]X-]<.X2+57.<]<[.<2]

Patterns it teaches

  • Turing tarpit: brainfuck's eight commands on memory that can grow.
  • Quine: data that is printed twice, once as code and once as text.

Further

Jormungandr builds on Brainfuck.

Brainfuck derivatives

Cell-based

Write your own in Run Convert a program from Jormungandr

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: jormungandr.

Command line

shib run jormungandr -e '+52.'
shib manual jormungandr

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/jormungandr.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org