Random
Random, standing for R and O Machine(temporarily R & O refers to Regenerating & Overrunning, but subjects to change looking forward any better idea) is a minimalistic esoteric programming language in string-rewriting paradigm, assuming the source code itself as a double-ended stack. First proposed by User:Gs30ng, the specification is under development yet.
Overview
Based on a linear memory space which is the source code itself, a Random program deals with six kinds of instruction:
< > [ ] >< And all other characters
Interpretation starts from the left side of the code.
- All characters except for <, >, [, ] and >< are simple instructions: Add itself to the back(right side) of the code. Therefore a simple infinite loop can be written as an anonymous one character:
A AA AAA AAAA AAAAA ...
- Instruction < pops an element from the back of the code, and pushes it onto the front of the code.
A<<B A<<BA AA<<B BAA<<
- Instruction > pops a element from the front of the code, and pushes it onto the back of the code.
- [...] can be written as "Do ... while the front element and the back element are different" in pseudo-code. [ transfers the control to corresponding ] if the front element of the code and the back element are same. ] transfers the control to corresponding [ if the front and back element are different. If there is no corresponding [ or ], the program terminates.
- Since >< is NOP, making it another instruction does not cause any collide. In Random this instruction pops an element from the back and prints it out.
Example codes
!dlroW ,olleH[><]><
prints "Hello, World!".
Computational class
Since a Random program can push/pop items onto/from the both sides of the code, it can simulate a machine with 2 stacks. At this time it is not sure but it is guessed that Random can simulate the Turing machine.
External resources
- Interpreter in Python (dead link)
- Common Lisp implementation of the Random programming language which employs a double-ended queue (deque).