HQ9+, H9+, KL esoterical languages and the beer song
Let's first sing a beer song (in R6RS Scheme):
-
span class="st0">"No more""no more"" bottle""" "s")
-
" of beer"" on the wall""Take one down and pass it around, "
-
"Go to the store and buy some more, ""\n"", "".\n"".\n"""))))
Then let's make an extra library:
-
span class="st0">""
... and we are ready to write yet-another HQ9+ interpreter:
-
span class="co1">; HQ9+ interpreter v0.1 (Ivan Lakhturov)
-
; http://esolangs.org/wiki/HQ9
-
"Hello, World!""") ; (number->string i))
-
"HQ9+"))
HQ9+ is a joke language, featuring "Hello world" command, quine command, beer-song command and a counter increment (counter cannot be accessed or printed out). Quine implementation here is the classical "quine-cheating", where a program has access to its source. To make the quine more 'honest' somebody designed H9+. This is the same as HQ9+, but without "Q" command, and additionally, all characters on input are ignored, except for H, 9 and +. Then, obviously, "Hello, World!" program will be a quine. Let's implement H9+:
-
span class="co1">; H9+ interpreter v0.1 (Ivan Lakhturov)
-
; http://esolangs.org/wiki/H9
-
"Hello, World!""") ; (number->string i))
-
"""Hello, World!"))
And let's implement also a variation of this theme, the esoterical language KL:
-
span class="co1">; KL interpreter v0.1 (Ivan Lakhturov)
-
; http://ivanguide.ru/kl/
-
"Привет, мир!""Я узнал, что у меня
-
Есть огpомная семья –
-
И тpопинка, и лесок,
-
В поле каждый колосок!
-
-
Речка, небо голубое –
-
Это все мое, pодное!
-
Это Родина моя!
-
Всех люблю на свете я!""\n""+/-/*/extras"))
The semantics is as following: + is printing "Hello, world!" in Russian, - is printing a program's source, / is making a newline, and * print outs a poem from Russian movie "Brother".
To complete the picture, we can mention other close related to HQ9+ joke languages: HQ9++, CHIQRSX9, HQ9+B, HQ9+2D. HQ9++ is 'an object-oriented extension of HQ9+'; not interesting. CHIQRSX9+ adds eval, ROT-13 and sorting of input lines. ROT-13 (Caesar cipher) is a nice exercise to implement, but let's leave it for later. HQ9+B adds Brainfuck: this is definitely a thing to implement, but I will deal with Brainfuck later. HQ9+2D is not properly specified (even for a joke language), but commands it adds remind me 2D Turing-machine, so called Langton's ant. I want to implement and play with different Turing-machines, but later.
Later I will also look through the list of joke languages. For example, the first there is a 'language' 99, which just prints out '99 bottles of beer' song. Anyways, I hope, there could be something exciting in the list.
-