esolang

Stoplight

Two characters. One counts up, the other prints. A letter costs about a hundred keystrokes.

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

Tested with 2 known programs · Test method

Run it

Expected: 0

The idea

Stoplight has one cell and two commands. To print a character you press % as many times as its code and then #. The specification calls it a joke, since it has no purpose and is really inefficient, and it only prints. It cannot read, branch or loop, so every program stops.

Read the story

The specification also gives three short interpreters, in JavaScript, in Free2Edit and in Python.

The machine

CharDoes
%Add 1 to the cell
#Print the cell as a character, then set it to 0

Every other character is passed over, so a program may be split over lines.

Example

0 is character 48, so Print 0 is 48 signs and a #.

0 is character 48, so Print 0 is 48 signs and a #.

H is 72 and i is 105.

Expected: Hi

Counting is the hard part. Print ABC has 125, 126 and 127 signs on its three lines, 60 too many each, so it prints }, ~ and the delete character. Its Print Hi makes 132 and 170. The Python interpreter gives the same once the lines are joined, since it reads a single line, and its JavaScript one stops with an error at the first #.

Further

Ideas it shows

Also in Jokes

Write your own in Run Convert a program from Stoplight

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run stoplight -e '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#'
shib manual stoplight

Source

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

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

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