Mmmm()

From Esolang
Jump to navigation Jump to search

Mmmm() is an esoteric "microlanguage" by SuperJedi224, inspired in part by Brainf***.

The only characters the interpreter actually pays any attention to are M, m, <, >, (, ), ,, =, [, ., and ].

Because all number literals are simply ignored, the most succinct known way to output the number 1 is mm=m[m.m()].m;m[mm(mm(mm(mm(mm(m.m())))))].m(mm(m.m())). (If number literals were not ignored, you could express this much more simply as m[5].m(1).)

An interpreter can be found here.

M denotes a variable declaration

<...> denotes a loop while a value popped of the stack is neither 0 or null

m.m() returns 0

m[0].m(y) returns y+1

m[1].m() initializes a counter (which is initially 0)

m[2].m(y) pushes y to the stack

m[3].m() pops a value from the stack and returns it; returns null if the stack is already empty

m[4].m() takes a number from the input stream and returns it

m[5].m(y) appends y to the output stream

m[6].m(y) appends the character whose unicode id is y to the output stream

m[7].m(a,f) calls f and returns its return value if a is neither 0 nor null; otherwise returns 0

m[8].m(y) returns y-1 if y>1, or 0 otherwise

m[9].m() returns a random number on [0,1).

Of course, because the language has no number literals, you have to construct these numbers

If mm contains a number, mm.m() returns mm%10. If mm contains a counter object, mm.m() increments the counter and returns the new value.

Example Program

This program takes a number from input, and outputs the square (comments should be removed):

Mmmm=m[m[m.m()].m(m.m())].m();         //mmm = counter(0)
Mmmmmmmmmm=m.m();                      //mmmmmmmmm = 0  (the accumulator)
mmm.m();
Mmm=mmm.m();                           //mm = 2
mmm.m();
Mmmmm=m[mmm.m()].m();                  //mmmm = input
Mmmmmm= mmm.m();mmm.m();mmm.m();       //mmmmm = 5
Mmmmmmmmm=mmm.m();                     //mmmmmmmm = 8
m[mm].m(mmmm);                          //push input to stack
Mmmmmmm=m[mmmmmmmm].m(mmmm);           //mmmmmmm = input - 1
Mmmmmmmm=mmmm;
<                                       //Begin loop
    m[mm].m(mmmmmm);                    //push input copy - 1 to stack
    mmmmmmm=mmmm;                       //mmmmmmm=input
    mmmmmm=m[mmmmmmmm].m(mmmmmm);       //mmmmmm-=1
    m[mm].m(mmmmmmm);                   //push mmmmmmm
    <
        mmmmmmmmm=m[m.m()].m(mmmmmmmmm);//increment accumulator
        mmmmmmm=m[mmmmmmmm].m(mmmmmmm); //decrement mmmmmmm
        m[mm].m(mmmmmmm);               //push decremented value
    >
>
m[mmmmm].m(mmmmmmmmm);                  //output accumulator

Without comments, this becomes:

Mmmm=m[m[m.m()].m(m.m())].m();Mmmmmmmmmm=m.m();mmm.m();Mmm=mmm.m();mmm.m();Mmmmm=m[mmm.m()].m();Mmmmmm=  mmm.m();mmm.m();mmm.m();Mmmmmmmmm=mmm.m();m[mm].m(mmmm);Mmmmmmm=m[mmmmmmmm].m(mmmm);Mmmmmmmm=mmmm;<m[mm].m(mmmmmm);mmmmmmm=mmmm;mmmmmm=m[mmmmmmmm].m(mmmmmm);m[mm].m(mmmmmmm);<mmmmmmmmm=m[m.m()].m(mmmmmmmmm);mmmmmmm=m[mmmmmmmm].m(mmmmmmm);m[mm].m(mmmmmmm);>>m[mmmmm].m(mmmmmmmmm);

This is the "Hello, World!" program:

Mmm=m[m.m()].m(m.m());
Mmmm=m[mm].m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();Mmmmm=mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();m[mmmm].m(mmm.m());
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();Mmmmmm=mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
Mmmmmmmmm=mmm.m();
m[mmmm].m(mmm.m());
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();Mmmmmmm=mmm.m();
m[mmmm].m(mmmmmm);m[mmmm].m(mmmmmm);
mmm.m();mmm.m();
Mmmmmmmm=mmm.m();
m[mmmm].m(mmmmmmm);
mmm.m();mmm.m();
Mmmmmmmmmm=mmm.m();
Mmmm=m[mm].m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();
Mmmmmmmmmmm=mmm.m();
Mmmmmmmmmmmm=mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();mmm.m();mmm.m();
mmm.m();mmm.m();
m[mmmm].m(mmm.m());
m[mmmm].m(mmmmmmmmmm);
m[mmmm].m(mmmmm);
m[mmmm].m(mmmmmmm);
m[mmmm].m(mmmmmmmmm);
m[mmmm].m(mmmmmm);
m[mmmm].m(mmmmmmmm);
m[mmmm].m(mmmmmmmmmmm);