Mhm!

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

Mhm! is a Turing tarpit created by User:Aadenboy on April 1st, 2026.

Memory

Mhm!'s memory is an infinitely large tree. The root node can be seen as having infinite indexed set of children, and the node has a pointer which can point to one of its children. Each child has the same structure, bearing its own subchildren, subpointer, and so on for each descendant. Each node is able to be marked as "unusable", removing its children and making the node unable to perform any actions (however may still be pointed to).

Commands

Commands apply to the root node. Prepending a caret (^) before the command will scope the instruction to the currently pointed child of the node, with additional carets descending further downwards.

Command Description
) Move the node's pointer to the next child.
( Move the node's pointer to the rightmost child with a lower index that is unusable or whose own pointer is less than or equal to its index. If there is no such child, mark the current node as unusable.
[...] Repeat the contents of the block while the currently pointed child is not unusable. The child which is checked is allowed to change depending on the location of the pointers referenced.

If the root node is made unusable, execution halts.

Completeness

Mhm! is Turing-complete, as it is able to simulate Bitwise Cyclic Tag (see Mhm!/Turing-completeness proof).

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