esolang

Mentos

Say a label's name anywhere, in the code or at the prompt, and the program jumps there.

not without text, 2022 · Turing complete: no · ●●○ moderate · esolangs.org

Tested with 4 known programs · Test method

Run it

Expected: Hello, world!

The idea

not without text made Mentos in 2022. Its only control flow is the mention goto, or mento. The line tomato:5 ties the label tomato to line 5, counted from 0. From then on any line that holds the text tomato jumps there, and so does any input that holds it. A mention need not be a whole word, so cellular automaton mentions tomato too. When one line mentions two labels, one of them is picked at random.

Read the story

The specification puts Mentos with the finite state automata. The only memory is which label points where.

The machine

LineDoes
label:5Tie the label to line 5
label:Clear the label
label:textNothing; an index that is not a number makes a comment
:textPrint the text
:Read a line and jump to a label it mentions
anything elseJump to a label it mentions

A line that mentions nothing runs on to the next, and running past the last line ends the program. Labels are case sensitive. Each print ends with a line feed.

Example

The truth machine.

The truth machine. prompt jumps to the : on line 9, which reads the input. An input of 0 mentions the label 0 and jumps to line 5, which prints 0. Then end jumps to line 10, past the end.

Expected: 0

On 1 it jumps to line 7 and prints 1, and line 8 mentions 1 again, so it prints 1 forever.

The specification's interpreter for InterpretMe asks for code, and any input with a * in it sends it back to line 1 to ask again.

Expected: Please type your InterpretMe code: Please type your InterpretMe code:

The specification also has rock, paper, scissors. Its line chooseRock choosePaper chooseScissors mentions three labels at once, and the random pick among them is the computer's move.

Patterns it teaches

  • Nondeterminism: a line that mentions several labels jumps to any one of them.

Further

Also in Strange time

Write your own in Run Convert a program from Mentos

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run mentos -e ':Hello, world!'
shib manual mentos

Source

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

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

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