Replay

From Esolang
Jump to navigation Jump to search

Replay is an esoteric programming language.

Syntax

A Replay program consists of a series of lines of code, and on each line there is a string of characters which is referred to as a state-name. With the exception of the last line, which may be a duplicate, the state-names on each line must be distinct.

Execution

Execution starts at the first line of code, and proceeds step-by-step. With each step, the starting and ending state-names are recorded, and output to the console. In a Replay program the state-name on the last line may be the same as one of the prior lines, in which case execution jumps to that line, creating a loop. If the state-names on every line are distinct, then the program terminates when it gets to the last line.

Example Programs

Program

   A
   B
   C
   D

Output

   A -> B
   B -> C
   C -> D

Program

   A
   B
   C
   D
   B

Output

   A -> B
   B -> C
   C -> D
   D -> B
   B -> C
   C -> D
   D -> B
   etc. (non-terminating)

Program Size

In a Replay program, the maximum number of lines of code, and the maximum size of the strings representing state-names are both theoretically infinite. In practise, a program running on a computer will limit both of these due to limits in available memory and integer representation.

Turing Completeness

Replay is Turing Complete. To see why, consider its relationship to Jumpy. Jumpy is considered Turing Complete. We can map a Jumpy program onto an equivalent Replay program as follows. First we identify all the numbers that are actually used when executing the Jumpy program, and re-arrange these states into execution order. If there is a loop, then we identify the number that jumps us back into the loop, and write that as the last line of the Replay program.

Example

Jumpy program

   3
   2
   1
   4
   5

Output

   0 -> 3
   3 -> 4
   4 -> 5

Replay program

   0
   3
   4
   5

Output

   0 -> 3
   3 -> 4
   4 -> 5