TwoStep
Jump to navigation
Jump to search
TwoStep is an esoteric programming language where each statement consists of two characters: a command character and a single digit (or other character). There are 12 commands, and it uses digits 0-9 and a single byte of memory.
Commands
Command | Function |
---|---|
+
|
Adds the given digit to the memory |
-
|
Subtracts the given digit from the memory |
/
|
Divide the memory by the given digit if the digit is not zero |
*
|
Multiply the memory by the given digit |
>
|
Do next statement if the given digit is less than the memory, otherwise skip over next statement |
<
|
Do next statement if the given digit is greater than the memory, otherwise skip over next statement |
)
|
Do previous statement if the given digit is less than the memory, otherwise skip over next statement |
(
|
Do previous statement if the given digit is greater than the memory, otherwise skip over next statement |
[
|
Output the ASCII character associated with the memory. Digit is ignored |
]
|
Input an ASCII character store its code in the memory. Digit is ignored |
.
|
Stop the program. Digit is ignored |
|
(space) No operation. Digit is ignored, so it can be used for comments |
Examples
This program prints out "Hello, World!" Notice the comment at the beginning.
H e l l o , W o r l d ! *0+6*2*6[ *0+5*5*4+1[ +7[ [ +3[ *0+5*9-1[ *0+8*4[ *0+9*9+6[ *0+5*5*4+9+2[ +3[ -6[ -8[ *0+8*4+1[ .
This program runs an infinite loop that prints out "x".
*0+6*4*5[ )0.
This cat program outputs its input.
] [ .
It may be possible to create a quine in TwoStep, if you can manage to run the following program using the same byte of the memory the program is stored in. However, this program only uses a single character, instead of the required two, for the statement.
[
Interpreter
- Common Lisp implementation of the TwoStep programming language.