Hourglass

From Esolang
Jump to navigation Jump to search

Hourglass is an esolang where all variables are hourglasses with two values: top,bottom. Each action 1 is subtracted from the top and add the the bottom unless the top is 0. By default all hourglasses start with 0,0.

(Note: no numbers allowed. Hourglass 0 is accessible via #() and all other commands referencing nothing as a value)

Commands:

#(x) the value at the bottom of the xth hourglass 
@(x) swap the values of the top and bottom of the xth hourglass 
$(x) print the bottom of the xth hourglass 
%(x) if the input is 1, flip hourglass x, if it is 0, don't 
!(x) add one the the top of hourglass x
[x|code] while the top of hourglass x is not 0 run code
?(x) 50% chance to flip hourglass x
* NOP

Actions:

Executing @(x)
Executing $(x)
Executing %(x)
Executing !(x)
Checking the conditional in [x|code]
Executing ?(x)
Executing *

Programs