thaM

From Esolang
Jump to navigation Jump to search

thaM is an esoteric programming language created by poiuy_qwert. The name thaM is actually just the word Math scrambled. The reason its name is made from Math is that it is designed to look like a mathematical equation. When you program in thaM, you should always try and make it valid math.

Commands

Every command in thaM is an operator from math, a number, or letter. Every number is pushed onto the main stack, every letter is a secondary stack, and the operators do the work.

Variables

There are 2 types of variables in thaM, the function variables and the data variables. The function variables can be the characters A-Z, currently there are only a few. The function variables have special built in functions. The current function variables are:

B - A special NOP that can be used with certain commands (explained more later). It can also be used to make your program look like correct math.
I - When you move a value from the I stack to another, it gets a character from input and pushes it on stack I before the copy is done.
O - When you move a value from a data variable onto the O stack, it is output as a character. If you push a number higher than 255, it just prints character 255. The same thing with lower than 1.
N - When you move a value from a data variable onto the N stack, it outputs the number.

The other type of variable is the data variables. They are infinite stacks that are referenced with characters a-z. The main stack is a data variable with no character to represent it.

For example:

I^O=

This is the most simple cat program, it copies 1 character from input to output.

Calculation

thaM only contains basic calculation operators:

+ - Add
- - Subtract
/ - Divide
* - Multiply

Each command takes the first number on the main stack, and performs its operation to it with the second number.

For example:

1,001+B^N=

This would do 1+1 then output it as a number.

Commands

There are few commands in thaM, they are some of the advanced math operators that aren't used in thaM:

^ - Move the top value from the stack on the left of the ^, to the top of the stack on the right. If the same stack is on both sides, it duplicates the value. This also uses B to reference the main stack.
! - Pop the top value off the main stack.
, - Another NOP type command. This is used to separate numbers when you want to push 2 numbers in a row.
= - End the program.

For example:

I^a^a^a^ba^B!B=

This program will end with the user's input in stack a and b, with nothing on the main stack.

Flow Control

There are only 2 flow controls in thaM:

() - If the top value on the main stack is not 0, execute the code inside the brackets. If you have 2 sets of brackets one after the other, the second set is else.
[] - While the top value on the main stack is not 0, execute the code inside the brackets.

For example:

1[I^B^(B)(O)]=

A more advanced cat program. This will continue to get a character input then output it, until a null character.

Comments

Comments are included in the language, but should not be used because they are too obviously not correct math. Comments are encased in |s.


Examples

Hello, World!

This program prints "Hello, World!"

33,100,108,114,111,087,032,044,111,108,108,101,072[B^O]=

Cat

This takes 1 character from input and outputs it:

I^O=

This more complex one outputs its input till a null character:

1[I^B^(B)(O)]=

Brainfuck Interpreter

Since this language is unimplemented, it is unknown if this program is correct. For a more readable and commented version of this code, visit the Talk Page.

1[I^B][43-(43+44-(44+45-(45+46-(46+60-(60+91-(91+93-(B!B)(7^s))(6^s))(5^s))(4^s))(3^s))(2^s))
(1^s)]s^B[1-(1+2-(2+3-(3+4-(4+5-(5+6-(6+7-(0,063,102,116,119[B^O]0B^s)(c^B1+B^cr^B^B(e^B[6-
(6+B^s)(o^B1-B^B^oc^B^BB^c-(6B^e0)(6B^s))])))(o^B1+B^o6^e))(l^r5^e))(r^BO4^e))(r^B1-B^r3^e))
(I^Br^B!B^r2^e))(r^B1+B^r1^e)s^B]=

External resources