Top-based turning

From Esolang
Jump to navigation Jump to search

Top-based turning is an esoteric programming language invented by User:A influenced by The Waterfall Model and Befunge.

The language

Imagine a cube with 6 faces. There is a clock on each face. Yes, that is how Top-based turning stores data. Not as you will probably expect, the clock does not have 3 hands. Instead, it only has 1 hand and can only show 4 times: Up-time (pointing to ↑) represented by 0, right-time (pointing to →) represented by 1, down-time (pointing to ↓) represented by 2, and left-time (pointing to ←) represented by 3. Note that every execution of a command results in an increment of the clock hand (similar to The Waterfall Model's waterclocks, but not decrementing) and 4 maps down to 0.

Original state

The cube is set to values in this net:

 0
000
 0
 0

(where the bolded number is the bottom of the cube)

Command execution

A program in Top-based turning starts at a specific location in the program (usually line 1, column 1). This is the process that a program is executed:

  • Execute the cell pointer by the instruction pointer in the program
  • Automatically rotate the clock hand on the top face of the cube clockwise.
  • Send program flow as 1 cell to the direction that the clock hand is pointing to.

Case-sensitiveness

By the way, note that Top-based turning is not case-sensitive.

Commands

*:stop the program
::input 2 numbers. Load the top face of the cube into the specified location in the code (inputting x and y specifies a line x and column y location).
;:Similar to :, yet it loads a specified place in the program into the top of the face.
^:Flip the cube up
v:Flip the cube down
<:Flip the cube left
>:Flip the cube right
a:If top is 0 then < else > (<:> afterwards)
b:>:<
c:^:v
d:v:^
e:^:>
f:>:^
g:>:v
h:v:>
i:v:<
j:<:v
k:<:^
l:^:<
,:input x, set the top face of the cube as x.
.:output the top face of the cube.
Any other character is a no-op.

Example program

Writing useful programs in Top-based turning is very difficult. Thus, these example programs are useless programs. (Maybe you could try Hello, world! programs or Cat programs if you want to experience it firsthand.)

Outputs "3"

The program flow starts at the bolded letter.

*zz
.z<

Counter from 0 to 4

..
..

Computational class

It seems that it is Turing-complete, but there is no proof for it. (What is does have is an infinite tape, conditional switching, looping, and input/output (I/O is unnecessary anyway).)