Lightswitch

From Esolang
Jump to navigation Jump to search

Lightswitch is an esolang created by User:Infinitehexagon about Light switches and the state of light switches. It only uses one keyword; toggle.

Syntax

Light switches cannot have a custom name. When giving a value to a lightswitch, it's name must be a p followed by the lightswitch number. The lightbulb number always starts at 0 and it should be in a numerical order for each new lightbulb called. eg
p0 toggle p0
toggle p0

This program calls lightswitch p0 and gives it a value of I , or 1.

Built-In Keywords

These keywords store binary data into a lightswitch. They are:
@in [lightswitch]: Gets input into a lightswitch
@out [lightswitch]: Outputs the lightswitch as a bit
@p [lightswitch]: returns the state of the lightswitch

Command Description
[lightswitch 1] toggle [lightswitch 2] When lightswitch 1 is toggled, make it toggle another lightswitch with the state of I(1) or O(0).
toggle [lightswitch] Toggle the state of a lightswitch.

Programs

Cat program

p0 toggle p0
@in p0
p1 toggle p1
@in p1
p2 toggle p2
@in p2
p3 toggle p3
@in p3
@out @p p0
@out @p p1
@out @p p2
@out @p p3

Join 2 states

p0 toggle p0 
p1 toggle p1
@in p0 
@in p1 
@out @p p0
@out @p p1

NOT logic gate

p0 toggle p0
@in p0
toggle p0
@out @p p0

Computational class

This language is clearly Turing-incomplete as it can't simulate an infinite loop without an extension.

Interpreter

  • Common Lisp implementation of the Lightswitch programming language.