Random-ass Turing Complete Language

From Esolang
Jump to navigation Jump to search

You can abbreviate the title to Ratcl if the title is too long. Also, the title is always capitalized like that.

This is still a work in progress. It may be changed in the future.

Ratcl is a stack-based language, so it uses stacks. And "stacks" because you can have multiple.

Code execution

Commands in Ratcl all technically single characters, but they (mostly) use the characters to the left and right side as modifiers. Every command (including modifiers) are separated by either spaces or newlines. Let's take the example abc. Say a had a right side modifier, b used both sides as modifiers, and c did nothing (these aren't what they actually do). When the code is executed, a would first run, but it uses a modifier on the right side. When this happens, that character is skipped. So it will run a and then skip b, so it does nothing. Then c runs, but it does nothing, so nothing happens. So only a will run (and use b).

Note: The - command is VERY useful. Check the miscellaneous section for what it does.


Note: Any time "pop x and y" is said, x is the topmost item and y is the second item.

Stack manipulation

Left modifier Command Right modifier Description
c stack name Create a stack under the name <stack name>.
r stack name Remove stack <stack name>.
stack p value (0-f) Push <value> (0-f or 0-15) to stack <stack>.
" stack Push the entirety of the next line onto <stack> from left to right.
stack s sub-command (s, q, d, or r) Runs <sub-command> on <stack>. s swaps the top two items, q removes the top item, d duplicates the top item, and r reverses the entire stack.
stack A > stack B Moves the top item from <stack A> to <stack B>.
' stack Push a space (32) to <stack>.

Arithmetic and logic

Left modifier Command Right modifier Description
stack a sub-command (+, +, -, * or /) Pops x and y, and pushes y <sub-command> x to <stack>.
stack l sub-command (>, =, < Pops x and y, and pushes 1 if x <sub-command> y is true, 0 otherwise.
! stack Pop x and push 1 if x is 0, and push 0 otherwise.
R stack Pop x and y, and push a random number (inclusive) between y and x


Left modifier Command Right modifier Description
stack i sub-command (c or i) Takes either one character or number, and pushes it to <stack>.
stack o sub-command (c or i) Pops the top item off of <stack>, and outputs it as a character or number.

Control flow

Left modifier Command Right modifier Description
u stack Pop a number from <stack> (x) and jump to line x unconditionally (so no matter what).
b Binary jump; pop x and y off <stack>, and jump to line y if x is non-zero.
name WIP: Add labels + creating them (unconditional and conditional) stack (for conditinoal only)


Left modifier Command Right modifier Description
- Skips the next command. When dealing with left side modifiers, this becomes very helpful. Try it for yourself and you will understand.
~ Comment. Using this will ignore the rest of the line. So far in my python implementation of this, comments aren't supported.


A+B Problem

ca ~ Create a stack
-aii -aii ~ Take 2 inputs from the user as numbers
-aa+ ~ Add them
-aoi ~ Output as number

Input: 2 3 >> Output: 5

Input 2: 30 72 >> Output: 102

Hello, world!

ca ~ Create stack
"a ~ Push "Hello," followed by a space and "world!"
Hello, 'a "a
-asr ~ Reverse the stack so it's the same way it was pushed on
~ As of now I didn't think of a way to generalize outputting strings, so we have this.
-aoc -aoc -aoc -aoc -aoc -aoc -aoc -aoc -aoc -aoc -aoc -aoc -aoc ~ Lol

Output: Hello, world!