Eitherf*ck

From Esolang
Jump to navigation Jump to search

Eitherf*ck is a Brainfuck variant in which code is executed in both directions, starting at the center of the code.

The idea for the language was posted by User:80.213.159.15 who didn’t leave any identification.

Commands:
0	Center of code (only to clarify)	
#	Does nothing(used only to make sure that the number of commands is an odd number)	
> 	Move the pointer to the right
< 	Move the pointer to the left
+ 	Increment the memory cell under the pointer
- 	Decrement the memory cell under the pointer
. 	Output the character signified by the cell at the pointer
, 	Input a character and store it in the cell at the pointer

However, these commands are reversed when they're on the left side of the code. This means that > will move the pointer to the left instead of to the right; that is, if it's on the left side. Same goes for the other commands; "+" becomes "-", "," becomes "." etc. when they're placed on the left side of the "0" sign.

The code is executed one by one character, in both directions; however, the right side always starts.

Brainfuck example:
1 2 3 4 5 6 7 8
+ + + + + > > +
Eitherf*ck example:
8 6 4 2 0 1 3 5 7
- < - - 0 + + + >

An implementation of an Eitherf*ck interpreter written in Python can be found in this Github repo.