Lamp
Every value is on or off. There is no if, only circuits that run when a lamp powers them.
2021 · Turing complete: unknown · ●○○ easy · esolangs.org
Tested with 5 known programs · Test method
Run it
The idea
Lamp is an imperative language from 2021 in which every value is on or off. A lamp holds one of them. A switch has exactly two positions, called off and on, and each position holds a lamp value or another switch, so switches nest into lists and trees.
Read the story
Code is split into circuits, which end with ground. A circuit runs when it is powered, and power c x powers it only when x is on. That is the whole conditional. A circuit may power itself, and it can be defined anywhere in the file, even after the line that powers it.
The machine
| Statement | Does |
|---|---|
lamp x on | Make a lamp |
switch s (on (off on)) | Make a switch; s.off is on, s.on.off is off |
switch t s.on | Copy part of a switch |
display x | Write on or off for each lamp |
display block x | Write a block for on and a space for off |
circuit c ... ground | Define a circuit |
power c x | Run c when x is on; -x is not x |
delete switch s | Remove a switch |
Names may carry a namespace, as in ns:x. A lamp without one lives in lamp: and a switch in switch:. Circuits have no scope of their own, so a namespace is how a circuit keeps its lamps apart.
Example
An if and an else are two circuits, one powered by a lamp and one by its negation.
An if and an else are two circuits, one powered by a lamp and one by its negation.
A program for the word lamp keeps one switch of 19 lamps per row and displays the five rows in blocks.
█ ██ █ █ ████
█ █ █ ████ █ █
█ █ █ █ █ ████
█ ████ █ █ █
████ █ █ █ █ █
Further
See also
Also in Turing tarpits
Write your own in Run Convert a program from Lamp
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: lamp.
Command line
shib run lamp -e 'lamp example on
display example'shib manual lampSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/lamp.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org