Mhm!

From Esolang
Jump to navigation Jump to search
Mhm!
Paradigm(s) procedural, imperative
Designed by User:Aadenboy
Appeared in 2026
Memory system tape-based
Dimensions one-dimensional
Computational class Unknown
Major implementations [1]
Influenced by Countable
File extension(s) .mhm

Mhm! is an esoteric programming language created by User:Aadenboy on April 1st, 2026.

Memory

The memory of Mhm! is an infinite tape to the right, with each cell being instances of Mhm! memory. That is, each cell is infinitely recursive, holding a tape within itself. The cell pointer starts on the cell with index 0, and cells below that cannot be moved onto. A cell may be marked as unusable, in which it can't be nested into.

Commands

In general, commands only apply to the first instance. To nest deeper into a cell (into its tape instance), prepend a caret (^) before the command.

Command Description
) Move the current pointer one cell rightwards.
( Move the current pointer leftwards infinitely until an unusable cell or a cell with a lesser or equal index is found. If no cell is encountered before the pointer travels past index 0, the cell is marked as unusable.
[...] If the pointer of the current cell is usable, run the contents of the loop until the current cell can no longer be used.

Examples

A+B Problem

) ^) ^) ^) A is set to equal 3 by moving it to the right that many times
) ^) ^) same process for B, but with 2
^( simulate a decrement early so that it exits at 0 rather than at -1
[ addition loop, done by decrementing B and incrementing A until B equals zero
  ( back to start
  ) ^) increment A just by moving it right
  ) ^( since B's pointer has two cells with a higher index behind it, it can safely travel leftwards that many times
  on the last decrement, it will have an index lesser than zero, thus no longer able to decrement
]

Subtraction can be intuitively done by decrementing A instead of B.

Multiplication

^( start off with a safety net to guarantee a return to the start
) ^^( ^) ^) ^) A is set to equal 3 by index, with an unusable cell at the start to denote zero
) ^^( ^) ^) same process as above for B, but with 2
^) ^^( B will also end with a final unusable cell to mark the end of the number
[(] back to start
) ^[ multiplication loop, done by adding B to C until A decrements to zero
  ^( decrement A
  ) ^( skip the ending padding for B
  ^[ since there are N usable cells to the left in B, we can move C by that many times
    ^( move B left
    ) ^) increment C
    [(] ) ) back to B
  ]
  ^) ^[^)] move B back to the end
  [(] ) move back to A for conditional
]

Division

^( start off with a safety net to guarantee a return to the start
) ^^( ^) ^) ^) ^) ^) ^) A is set to equal 6 by index, with an unusable cell at the start to denote zero
) ^^( ^) ^) same process as above for B, but with 2
^) ^^( ^( B will also end with a final unusable cell to mark the end of the number
) ^^( ^) ^^( ^( also set another safety net
[(] back to start
) ^[ division loop
  ) ^[ repeatedly decrement A and B until B is zero
    [(] ) back to A
    ^[ if A is greater than 0
      ^( decrement A
      ) ^( decrement B
      [(] back to start to exit
    ]
    ) ) back to B or forced exit cell if A is zero
  ]
  ^) ^[ if we ended on B, there will be a usable cell to the right and A÷B is whole, otherwise there won't be and A÷B is not whole
    ^[^)] ^( move B back to the end
    ) ) ^) increment C
    ( ^) exit
  ]
  ^( move back
  [(] ) back to A for conditional
]
) ^) ^[ calculating mod by incrementing B until it reaches the end
  ^) increment B
  ) ) ) ^) increment D
  [(] ) ) back to B for conditional
]

Interpreters