(top, height)

From Esolang
Jump to navigation Jump to search

(top, height) is a two-dimensional language where the pointer's x-coordinate is based on the value at the top of the stack, while the y-coordinate is based on the height of the stack.


The program starts with a stack only containing the value 0. This means the program always starts at (0,0).

Version 0.1.0
Command Description
0-9 Push the number onto the stack.
A-Z,a-z Push the ASCII value of the character onto stack.
+ Pop two values a and b, then push the result of a+b.
- Pop two values a and b, then push the result of a-b.
* Pop two values a and b, then push the result of a*b.
/ Pop two values a and b, and check if b equals the number 0.

If so, end the program.
Else, push the result of a/b.

% Pop two values a and b, and check if b equals the number 0.

If so, end the program.
Else, push the remainder of a/b.

> Pop two values a and b, then push whichever one is greater.
< Pop two values a and b, then push whichever one is smaller.
: Duplicate top of stack.
\ Swap top stack values.
$ Pop top of stack and discard.
. Pop top of stack and output as integer.
, Pop top of stack, modulo 256, and output as ASCII character.
~ Get input from user.

If it is numeric, push the corresponding number onto the stack.
Else, push the ASCII value of the corresponding character.

Anything else End program

Every time an action is performed, the pointer's x-coordinate is reset to the absolute value of the value on top of the stack, and the y-coordinate is reset to the height of the stack - 1.

Any operation which uses two values, such as + or -, will end the program if the x-coordinate is less than 0 (meaning the stack height is one).

The program will also end if the stack height is equal to 0.


  • The duplicate command acts like pushing a pointer one space down.

Code Examples

Truth Machine

Version 0.1.0


Hello, World!

Version 0.1.0

This prints Hello, World! The space is written by multiplying 8 and 4, while the comma is written by taking the ASCII value of X, dividing it by 2, and taking the absolute value of subtracting that from 1. Finally, the exclamation mark is made by subtracting 1 from the ASCII value of A, then subtracting that from the ASCII value of a.

 e lloX8W orldA                                                         1
 \++++++4+++++                  1                                1      ,              21           12      1  1  1
 \\ *                           ,,          ,                   a1                     ,2           ,,      ,  ,  ,
 \\                                                              -                      /        -


I am very sure that Version 0.1.0, at least, is not Turing-complete. This is because the stack cannot have arbitrary elements, as only the elements near the front can be accessed. Therefore, I assume this is a push-down automaton. Please correct me if you feel this is wrong.

In the next update, I will change the swap command so that it is a random-access array, like the one in this language. Then I believe it will be Turing-complete.


There are going to be multiple versions of the language as I add new features. I did this so that people know what aspects of the language are included by any given interpreter.

Version 0.1.0

This is a Python 3 implementation of Version 0.1.0 of this language.

def run_top_height(code_string: str, text_file = False) -> None:
    stack = [0]
    code = []

    if text_file:
        with open(code_string, 'r') as file:
            # The newlines don't affect the outcome
            code = file.readlines()
        code = code_string.split('\n')

    while len(stack) > 0:

        # The pointer's next position is always x_coord, y_coord.
        x_coord = abs(stack[-1])
        y_coord = len(stack)-1

        if y_coord < len(code) and x_coord < len(code[y_coord]):
            instruction = code[y_coord][x_coord]

            # appends digits
            if instruction.isdigit():

            # appends the ASCII values of letters
            elif instruction.isalpha():

            # move down one space
            elif ':' == instruction:

            # arithmetic instructions
            elif instruction in {'+', '-', '*', '<', '>', '\\', '/', '%'}:
                if y_coord > 0:
                    a = stack.pop()
                    b = stack.pop()
                    if '+' == instruction:
                    elif '-' == instruction:
                    elif '*' == instruction:
                    elif '>' == instruction:
                    elif '<' == instruction:
                    elif '\\' == instruction:
                        if b == 0:
                        elif '/' == instruction:

            # popping instructions
            elif instruction in {'$', '.', ','}:
                new = stack.pop()
                if '.' == instruction:
                elif ',' == instruction:

            elif '~' == instruction:
                new = input()[0]
                if new.isdigit():