The popular webcomic Homestuck makes use of a programming language called ~ATH
to destroy universes. While this code golf challenge is not to write a program to annihilate our existence, we will be destroying some more tame (albeit less interesting) entities: variables.
~ATH
(pronounced "til death," notice how ~ath
is "tilde ath") works by creating a variable called THIS
, executing a command with EXECUTE
, and finishing the program with THIS.DIE()
. A wiki page for the language's use in Homestuck can be found here. The goal of this challenge will be to create a ~ATH
interpreter.
For the sake of the challenge, I'm going to create some details of ~ATH
that don't really exist but make it (somewhat) useful.
- The language will only work with integers, which are declared with
import <variable name>;
. The variable will automatically be set to a value of 0. Only one variable at a time can be imported. - A variable
x
can be copied by writingbifurcate x[y,z];
, which will delete the variablex
and replace it with identical variablesy
andz
. Note that it cannot create a variable with the same name as the one deleted. Essentially, a variable is renamed, then a copy of the variable with a different name is created. This seems like a stupid feature, but stupidity is very deeply ingrained in Homestuck. - The syntax for writing a program that executes code on
x
is~ATH(x){EXECUTE(<code>)}
. If you want to execute code on two variables simultaneously, the code becomes nested, like this:~ATH(x){~ATH(y){EXECUTE(<code>)}}
. All commands in<code>
will be executed on bothx
andy
. - Now let's move onto commands.
+
increments relevant variable(s) by 1 and-
decrements them by 1. And... that's it. - The final feature of
~ATH
is that it kills whatever it works with. Variables are printed in the format<name>=<value>
(followed by a newline) at the command[<name>].DIE();
. Afterwards, the program prints the wordDIE <name>
and a newline a number of times equal to the absolute value of the value of the variable. When variables are killed simultaneously with[<name1>,<name2>].DIE();
(you can have as many variables killed as you want, so long as they exist), theDIE()
command is executed on the variables sequentially.
Example programs
Program 1:
import sollux; //calls variable "sollux"
import eridan; //calls variable "eridan"
~ATH(sollux){EXECUTE(--)} //sets the value of "sollux" to -2
~ATH(eridan){EXECUTE(+++++)} //sets the value of "eridan" to 5
[sollux].DIE(); //kills "sollux", prints "DIE sollux" twice
~ATH(eridan){EXECUTE(+)} //sets the value of "eridan" to 6
[eridan].DIE(); //kills "eridan", prints "DIE eridan" 6 times
Output:
sollux=-2
DIE sollux
DIE sollux
eridan=6
DIE eridan
DIE eridan
DIE eridan
DIE eridan
DIE eridan
DIE eridan
Program 2:
import THIS; //calls variable "THIS"
~ATH(THIS){EXECUTE(++++)} //sets the value of "THIS" to 4
bifurcate THIS[THIS1,THIS2]; //deletes "THIS", creates variables "THIS1" and "THIS2" both equal to 4
~ATH(THIS1){EXECUTE(++)} //sets the value of "THIS1" to 6
[THIS1,THIS2].DIE(); //kills "THIS1" and "THIS2", prints "DIE THIS1" 6 times then "DIE THIS2" 4 times
import THAT; //calls variable "THAT"
bifurcate THAT[THESE,THOSE]; //deletes "THAT", creates variables "THESE" and "THOSE"
~ATH(THESE){~ATH(THOSE){EXECUTE(+++)}EXECUTE(++)} //sets the value of "THESE" and "THOSE" to 3, then sets the value of "THESE" to 5
[THESE,THOSE].DIE(); //kills "THESE" and "THOSE", prints "DIE THESE" 5 times then "DIE THOSE" 3 times
Output:
THIS1=6
DIE THIS1
DIE THIS1
DIE THIS1
DIE THIS1
DIE THIS1
DIE THIS1
THIS2=4
DIE THIS2
DIE THIS2
DIE THIS2
DIE THIS2
THESE=5
DIE THESE
DIE THESE
DIE THESE
DIE THESE
DIE THESE
THOSE=3
DIE THOSE
DIE THOSE
DIE THOSE
This is code golf, so standard rules apply. Shortest code in bytes wins.
~ATH
uses semicolons as line-endings for theimport
,bifurcate
, andDIE
commands. Both REPL and files are fine. Case sensitivity is required in both the input and the output (I'm trying to match the actual~ATH
as much as possible). \$\endgroup\$