esolang

DeathScript

Three variables, seven commands and not a single jump. Every line runs once.

YourDeathIsComing · Turing complete: no · ●○○ easy · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: Hello, World!

The idea

YourDeathIsComing made DeathScript around three variables, A, B and C. Arithmetic only ever reads B and C and only ever writes A, so a calculation is a matter of moving values into place with switch. There are no loops and no conditions, so every program ends after its last line.

Read the story

The reference is a Windows batch file, and this implementation follows it. Where cmd itself gets in the way, as with a ! in the text, which echo drops there, this implementation prints what the specification means.

The machine

CommandDoes
output textPrint the text
outvar VPrint the value of V
input VRead a line into V
set V xSet V to x, or to a random number from 0 to 32767 with random
math opPut B and C worked by add, sub, mul, div or mod into A
switch VSwap A with B or C
clearClear the screen

Each value starts at 0 and the arithmetic is on 32 bit whole numbers, as the batch file's set /a does it. Every printed value ends its own line, as echo does.

Example

The Hello world and its cat.

The Hello world and its cat.

Expected: meow

To multiply, the two numbers go into B and C and the product comes out in A. Division cuts toward 0, and switch brings the 7 back from B.

Expected: 42
Expected: 3 1 7

Further

Also in Jokes

Write your own in Run Convert a program from DeathScript

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run deathscript -e 'input A
outvar A' --input 'meow'
shib manual deathscript

Source

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

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

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