esolang

Momema

Every statement is an assignment. A jump is a label too, and it only listens to labels with its own name.

Challenger5, 2018 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 5 known programs · Hello World on Try It Online: identical · Test method

Run it

Expected: Hi

The idea

Challenger5 made Momema in 2018 as a plain imperative language with one twist. A program is a list of statements a b, each storing the value of b in tape cell a. Input and output are cells as well; cell -9 reads and writes characters, cell -8 numbers.

Read the story

The twist is control flow. A lowercase word with a number after it, such as j 2, is a label and a jump at once. It jumps past that many labels with the same word, forward or backward, and wraps around the end of the program. j 0 does nothing and only marks a place.

The machine

The tape is unbounded both ways and holds unbounded integers, all 0 at the start. Expressions are written prefix, so they need no brackets.

CodeMeans
5The number 5
*eThe value in cell e
+ e fThe sum
-eThe negation; -9 is the number minus nine
=e0 if e is 0, else 1
a bStore b in cell a
w nJump past n labels named w

Reading cell -9 gives the next character, or -1 at the end of the input. Reading -8 at the end of the input stops the program. Since = turns any number into 0 or 1, it is the way to make a jump that happens only sometimes; c = *0 jumps to the next c only when cell 0 is not 0.

Example

The countdown keeps its digit in cell 0.
Expected: Az
Expected: 9876543210

The countdown keeps its digit in cell 0. While the digit is not yet 47, one below 0, the c jump skips the exit x 1 and l -1 goes back to the top.

Further

Ideas it shows

Also in Turing tarpits

Write your own in Run Convert a program from Momema

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run momema -e 'j 0
r *5
5 1
j 1
r 0'
shib manual momema

Source

Module
langs/tio/ports.js
Interpreter
langs/tio/momema.js

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

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