esolang

Mmmm()

A language spelled with the letter m. Even the numbers have to be counted up from nothing.

SuperJedi224, 2014 · Turing complete: unknown · ●●○ moderate · esolangs.org

Tested with 5 known programs · Test method

Run it

Expected: 1

The idea

SuperJedi224 made Mmmm() in 2014, in part after brainfuck. Only M, m and nine signs count, with ; between statements. Digits are dropped, so no number can be written down. Every number is made by calling methods. m.m() gives 0, m[m.m()].m(y) gives y+1, and a counter counts up by one each time it is called. Variables are runs of m, so a program holds mm, mmm and mmmm side by side.

Read the story

Even the index in m[...] has to be counted up first. m[5].m(1) does not print 1, because without its digits it is m[].m().

The machine

CodeDoes
m.m()Give 0
m[0].m(y)Give y+1
m[1].m()Give a new counter at 0; c.m() counts it up and gives the new value
m[2].m(y) m[3].m()Push y; pop, or null on an empty stack
m[4].m()Read a number
m[5].m(y) m[6].m(y)Print y as a number, or the character with code y
m[7].m(a,f)Call f when a is neither 0 nor null, else give 0
m[8].m(y)Give y-1 if y is above 1, else 0
m[9].m()Give a number from 0 up to 1
Mmm=...Declare the variable mm and set it
< ... >Loop while the value popped from the stack is neither 0 nor null

A number n gives n%10 for n.m(). A method can be kept in a variable and called later, which is how the specification prints 1 in the fewest characters.

Example

mm holds the method that adds 1.

mm holds the method that adds 1. Five calls on 0 give 5, which picks the method that prints a number, and one call on 0 gives the 1 it prints.

The square. A counter in mmm makes the 2, 4, 5 and 8 that pick the methods, the number read goes on the stack, and two loops add it to the accumulator mmmmmmmmm n times.

Expected: 49

The Hello World is 60 lines long. One counter climbs from 0 to 114, and on the way each code it needs goes into its own variable, 6 for the method that prints a character, then 87, 100, 108, 111 and 114. A second counter climbs to 44 for the comma, the space and the exclamation mark. It prints Hello, World!.

Patterns it teaches

Further

Also in Hostile

Write your own in Run Convert a program from Mmmm()

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run mmmm -e 'mm=m[m.m()].m;m[mm(mm(mm(mm(mm(m.m())))))].m(mm(m.m()))'
shib manual mmmm

Source

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

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

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