We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

1=0+1

From Esolang
Jump to navigation Jump to search

1=0+1 is an esolang invented by User:None1.

Variables

1=0+1 has n variables, where n is the number of lines. The variables are named 0 to n-1. Initially, the value of each variable is the same as its name.

Lines

Each line must be like this:

x=y1+y2+...+ym

x and yi are variable names. x must be equal to the line number (0-indexed).

This command makes variable x the sum of variables y1, y2,...,ym.

Control flow

All lines are executed simultaneously, meaning that they all read from the variables before any line is executed.

The lines are executed infinitely (i.e.: the control flow wraps around), so programs never terminate.

I/O

After each loop, all variables are printed.

Examples

Powers of 2

0=0
1=1+1

The result is stored in variable 1.

Fibonacci

0=1
1=0+1

The result is stored in variable 1.

Counting

0=0+1
1=1

The result is stored in variable 0.

Interpreter

Python

import sys
from time import sleep

code = sys.stdin.read().strip().split("\n")
n = len(code)
v = list(range(n))
z = []
for i, j in enumerate(code):
    x, y = j.split("=")
    if x != str(i):
        raise SyntaxError("Invalid code")
    z.append(list(map(int, y.split("+"))))
c = 0
while 1:
    c += 1
    tmpv, v = v[:], [0] * n
    for i, j in enumerate(z):
        for k in j:
            v[i] += tmpv[k]
    print(f"Cycle #{c}:", v)
    sleep(0.1)