TwoStep

From Esolang
Jump to: navigation, 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[edit]

Command Function
+ Adds the given digit to memory
- Subtracts the given digit from memory
/ Divide memory by the given digit if the digit is not zero
* Multiply memory by the given digit
> Do next statement if the given digit is less than memory, otherwise skip over next statement
< Do next statement if the given digit is greater than memory, otherwise skip over next statement
) Do previous statement if the given digit is less than memory, otherwise skip over next statement
( Do previous statement if the given digit is greater than memory, otherwise skip over next statement
[ Output memory as a single byte. Digit is ignored
] Input a single byte to memory. Digit is ignored
. Stop the program. Digit is ignored
(space) No operation. Digit is ignored, so it can be used for comments

Examples[edit]

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+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 memory the program is stored in. However, this program only uses a single character, instead of the required two, for the statement.

[