esolang

Enwokenment

The program is a list of sums. Add the first one that keeps every count at 0 or above, and start over.

Hakerh400, 2024 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: 35z

The idea

Hakerh400 made Enwokenment in 2024. The input is a sum of terms such as 5x + 7y, each a name with a whole coefficient. Every line of the program is a sum too, and its negative terms are what it needs. The first line that can be added without driving any coefficient below 0 is added, and the search starts again at the top. When no line fits, the run ends and the sum is the output.

Read the story

It works like FRACTRAN with the prime factors given names. The specification shows how a FRACTRAN program turns into Enwokenment, which makes it Turing complete.

The machine

PartMeans
3x - 4y + zA line that adds 3 to x and 1 to z and takes 4 from y
a line fitsNo coefficient goes below 0 when it is added
no line fitsStop and print the sum
_A name for scratch counts, left out of the output

The specification does not fix how the output is written. In this implementation the names come in character order, joined by + , and a coefficient of 1 is just the name.

Example

The program multiplies.

The program multiplies. The line a - x takes one from x and raises the flag a. While a is up, the first two lines move y into b one at a time and add 1 to z for each. Then _ - a lowers the flag, y - b moves b back into y, and the next x starts. When x is gone, _ - y clears y into the scratch name.

Patterns it teaches

Further

Functional paradigm

Write your own in Run Convert a program from Enwokenment

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: enwokenment.

Command line

shib run enwokenment -e 'c - a - y
a + b + z - c
_ - a
y - b
a - x
_ - y' --input '5x + 7y'
shib manual enwokenment

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/enwokenment.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org