esolang

thaM

Math with its letters scrambled. A program should read as an equation, and the power sign moves values between stacks.

poiuy_qwert, 2006 · Turing complete: unknown · ●●○ moderate · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: Hello, World!

The idea

poiuy_qwert made thaM in 2006. The name is Math scrambled, and the specification asks that every program should look like valid math. Numbers push themselves, the four operators do arithmetic, and ^ moves a value from the stack named on its left to the stack named on its right.

Read the story

Capital letters are special stacks. A value moved onto O prints as a character, onto N as a number, and a move from I reads a character first. B stands for the main stack and does nothing on its own, so 1,001+B^N= adds 1 and 1, prints 2 and still looks like a formula.

The machine

CommandDoes
72Push a number; , separates two numbers
+ - * /Pop the top and the one below, push below op top
x^yMove the top of stack x onto stack y, or copy it when x and y are the same
!Pop the main stack
(...)(...)Run the first part if the top is not 0, else the second
[...]Repeat while the top is not 0
=End the program

The stacks a to z hold data. I, O and N are input, character output and number output. Any other character beside ^, B included, means the main stack. An empty stack reads as 0. Text between two | is a comment.

Example

The Hello World pushes its 13 letters backwards and moves them to O one by one.
Expected: 2
Expected: t

The Hello World pushes its 13 letters backwards and moves them to O one by one. When the main stack is empty its top reads as 0 and the loop ends.

The second cat, 1[I^B^(B)(O)]=, prints nothing. Its second ^ has a bracket on its right, so it copies the character on the main stack, and neither branch moves anything to O. The specification also says nobody knows whether its brainfuck interpreter is correct; it has no case for >.

Patterns it teaches

  • Stack machines: one main stack and 26 more, with moves between them as the only way to print.
  • Camouflage: a program is meant to pass for an equation.

Further

Stack-based

Write your own in Run Convert a program from thaM

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run tham -e 'I^O=' --input 'thaM'
shib manual tham

Source

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

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

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