esolang

Where

No addresses at all. You pick cells by what they hold, and every cell that fits gets the same treatment.

Ketok, 2021 · Turing complete: no · ●●○ moderate · esolangs.org

Tested with 4 known programs · Test method

Run it

Expected: 0

The idea

Ketok made Where in 2021. There are four cells, and they start as 1, 2, 3 and 4. A statement never names a cell. It names a condition, like =1 or >2, and acts on every cell that meets it, the way SQL updates every row its WHERE clause matches.

Read the story

So the values are the only way to tell the cells apart, and a program has to keep them apart itself. With four cells of 0 to 255, the machine has a fixed number of states.

The machine

StatementDoes
WHERE c SET vEvery cell that meets c becomes v
WHERE c ADD v WHERE c SUB vAdd v to every such cell, or take it away, wrapping at 0 and 255
WHERE c INPUTRead a number into every such cell
WHERE c OUTPUTPrint every such cell
WHILE ANY c ... ENDRepeat while at least one cell meets c
WHILE ALL c ... ENDRepeat while every cell meets c
RESETPut the cells back to 1, 2, 3, 4

A condition is =n, <n or >n. A # starts a comment. The specification does not say how numbers come in and go out. Its truth machine needs INPUT to read the number 0 and not the character 0, so this implementation reads whole numbers, and OUTPUT prints each one on its own line.

Example

The truth machine.

The truth machine. Input 0 replaces the 1 and is printed once. Input 1 would print 1 forever.

The adder. It first moves 2, 3 and 4 up to 253, 254 and 255 so that the inputs land in known places. The first number is kept with 128 added and counts down to 128. Each step adds 1 to the second number.

Expected: 42

Further

Cell-based

Write your own in Run Convert a program from Where

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run where -e '# Truth machine
WHERE =1 INPUT
WHERE =0 OUTPUT
WHILE ANY =1
    WHERE =1 OUTPUT
END' --input '0'
shib manual where

Source

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

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

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