Reversed

From Esolang
Jump to navigation Jump to search

Reversed is an esolang invented by User:None1. It doesn't have jumps, but its control flow can be reversed.

Commands

It has these commands:

R: reverse control flow direction
other characters: print the character

If the instruction pointer goes to the left of the first character, it moves to the last character, but not vice versa.

Examples

Hello, World!

Hello, World!

Quine

quine

Print 123321

123R

Interpreter in Python

a,p,d=input(),0,1
while 1:
 if p<0:
  p=len(a)-1
 if p>=len(a):
  break
 if a[p]=='R':
  d*=-1
 else:
  print(a[p],end='')
 p+=d