+-.%*
Jump to navigation
Jump to search
+-.%* is an esoteric programming language created by User:3xcpy. It is (kind of) pretty similar to Brainfuck.
Overview
Just like Brainfuck, +-.%* operates on a tape of memory cells. These cells can hold any value between (including) 0 and 255. When a value exceeds these bounds, it wraps around to the opposite end. There is a pointer pointing to the current cell on the tape. The instruction pointer is moved forward by 2 every time an instruction is executed, effectively skipping one character every time. The %
command uses this for conditional flow control, as it can essentially switch between the two halves.
Command | Description |
---|---|
+ |
Increase the value held by the current cell (the one the pointer points to) by 1 |
- |
Decrease the value held by the current cell by 1 |
> |
Move the pointer one cell to the right (increase the pointer) |
< |
Move the pointer one cell to the left (decrease the pointer) |
% |
Move execution forward by 1 character (instead of 2), if the current cell's value is 0 |
* |
Move execution back to the start of the file |
. |
Print the current cell's value as an ASCII character |
, |
Read a byte from stdin and put it into the current cell |
Notes
- This idea came to my mind when I was thinking about languages that have only one means of looping: going back to the start of the program. Probably the most famous example of this is Fractran. This kind of language needs some kind of state that carries through the boundary of resetting the instruction pointer. Also, they probably need some way to only go back to the start conditionally (actually, if I think about it, this is not necessary. But it seems like the most natural way to do flow control). I also liked the idea of only evaluating half of the commands (skipping one every time) and having a way to switch between these two. Now that I think about it, this was not really necessary for this language. I could've just added a conditional looping command that resets to the start if the current cell's value is 0. (Edit: That exists now: +.*) 3cxpy (talk)
Examples
+-.%*
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + . + + . + . - - - - - - - - - . + + + + + . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - .
This prints +-.%*
and a newline. (The spaces are necessary)