From Esolang
Jump to: navigation, search

Switchy is an esoteric programming language created by User:Poolala, which changes an instruction's operation every program cycle.

The program stack is also reversed every cycle.

There is a binary variable called flip, which starts out at 0, and flips its value every cycle.


Instruction Description
(foo) Creates a label called foo (doesn't trigger a cycle)
[foo] Jumps to the label foo if the top stack element is nonzero if flip is 0, else jump if zero (doesn't trigger a cycle)
# Adds the top two stack elements, pops them, and pushes the sum if flip is 0, else subtract if flip is 1
* Pushes a 1 onto the stack if flip is 0, else pop a value from the stack
' Inputs a character and pushes it onto the stack if flip is 0, else output the top stack value

Interpreter notes

Any unprintable ASCII characters (nul, soh, etc.) should not register anything on output. This is the only way to make programming possible. (I think)


An implementation in Ruby by User:OriginalOldMan can be found on Talk:Switchy.