The Past

From Esolang
Jump to navigation Jump to search

The Past is a time-traveling esolang by User:PythonshellDebugwindow.

Memory model

The Past uses an arbitrary-size signed integer accumulator.

Output

The final value of the accumulator is output (if the program goes into an infinite loop, then nothing will be output).

Commands

Command Effect
+ Increment the accumulator
- Decrement the accumulator
. Wait a tenth of a second
< Go back one millisecond in the past

Implementation

Written in Python 3. A filename is read as a command line argument. Note that this implementation is somewhat slow and can take some time to start the program. If it is interrupted before the program starts, incorrect output may be produced.

import sys
import time

with open(sys.argv[1]) as f: code = f.read()
dt = 0.1*code.count('.') - 0.001*code.count('<')
acc = code.count('+') - code.count('-')
if dt >= 0:
    print('Starting program...')
    time.sleep(dt)
    print(f'Accumulator: {acc}')
else:
    print(f'Accumulator: {acc}')
    time.sleep(-dt)
    print('Starting program...')