oxen

From Esolang
Jump to navigation Jump to search

oxen is an esolang invented by User:None1.

Memory

Three accumulators: A, B and C are used. They contain unbounded unsigned integers. At first, A is 1, B and C are 0.

Commands

oxen has the following 4 commands (case sensitive).

Command Meaning
o Bitwise or B and A and store the result into B. Then, cyclic shift all three accumulators (A,B,C=B,C,A).
x Bitwise xor B and A and store the result into B. Then, cyclic shift all three accumulators (A,B,C=B,C,A).
e Bitwise left shift A by 1 bit and store the result into B. Then, cyclic shift all three accumulators (A,B,C=B,C,A).
n Do nothing. Then, cyclic shift all three accumulators (A,B,C=B,C,A).

After the last command is executed, execution goes back to the first. Invalid commands raise an error.

As there's no output, the interpreter may choose to print debugging information.

Examples

Powers of 2

e

After each operation, the result is stored in the accumulator A.

Cellular automaton rule 30

eenox

Interpreter in Python

from time import *
c = input()
A, B, C = 1, 0, 0

while 1:
    for i in c:
        if i == "o":
            B |= A
        elif i == "x":
            B ^= A
        elif i == "e":
            B = A << 1
        elif i == "n":
            pass
        else:
            raise SyntaxError(f"Invalid command: {i}")
        A, B, C = B, C, A
        sleep(0.2)
        print(f"Executed command {i}: A={A} B={B} C={C}")
    print("=" * 10)

Computational class

Unknown, as there's currently no rigorous proof of the computational class of rule 30 (though it's suspected to be Turing-complete). If rule 30 is Turing-complete, then this esolang is Turing-complete (and a Turing tarpit) as well.