Where

From Esolang
Jump to navigation Jump to search

Where is an esoteric programming language created by User:Ketok.

Language overview

Where operates on 4 memory cells, initially set to 1, 2, 3, 4. Each cell can have value ranging from 0 to 255.

Where statement

Syntax:

WHERE condition action

Where statement executes action on all cells fulfilling given condition.

For example:

WHERE >2 SET 255

will set all memory cells with value higher than 2 to 255.


Condition can be one of:

  • =n
  • <n
  • >n

with n being any numerical value ranging from 0 to 255.


Action can be one of:

  • SET value
  • ADD value
  • SUB value
  • INPUT
  • OUTPUT

with value also being any numerical value ranging from 0 to 255.

While statement

Syntax:

WHILE [ANY|ALL] condition
    ...
END

While statements executes its contents while all/any cells fulfill given condition.

Examples

Truth machine

# Truth machine
WHERE =1 INPUT
WHERE =0 OUTPUT
WHILE ANY =1
    WHERE =1 OUTPUT
END

Adder

# A simple program that adds two numbers toghether
WHERE >1 ADD 251
WHERE =1 INPUT
WHERE <253 ADD 128
WHERE =253 INPUT
WHERE >253 SET 0
WHILE ANY >128
    WHERE >128 SUB 2
    WHERE >0 ADD 1
END

WHERE =0 SET 255
WHERE <128 OUTPUT

Interpreter

Interpreter for Where is written in F# with FParsec. It can be downloaded from github.