Archive for April, 2011

HQ9+, H9+, KL esoterical languages and the beer song

April 4th, 2011 by Ivan Lakhturov | 0 Category: Programming | Tags: |

Let's first sing a beer song (in R6RS Scheme):

  1. span class="st0">"No more""no more"" bottle""" "s")
  2.               " of beer"" on the wall""Take one down and pass it around, "
  3.                  "Go to the store and buy some more, ""\n"", "".\n"".\n"""))))

Then let's make an extra library:

  1. span class="st0">""

... and we are ready to write yet-another HQ9+ interpreter:

  1. span class="co1">; HQ9+ interpreter v0.1 (Ivan Lakhturov)
  2. ; http://esolangs.org/wiki/HQ9
  3. "Hello, World!""") ; (number->string i))
  4. "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+:

  1. span class="co1">; H9+ interpreter v0.1 (Ivan Lakhturov)
  2. ; http://esolangs.org/wiki/H9
  3. "Hello, World!""") ; (number->string i))
  4. """Hello, World!"))

And let's implement also a variation of this theme, the esoterical language KL:

  1. span class="co1">; KL interpreter v0.1 (Ivan Lakhturov)
  2. ; http://ivanguide.ru/kl/
  3. "Привет, мир!""Я узнал, что у меня
  4. Есть огpомная семья –
  5. И тpопинка, и лесок,
  6. В поле каждый колосок!
  7.  
  8. Речка, небо голубое –
  9. Это все мое, pодное!
  10. Это Родина моя!
  11. Всех люблю на свете я!""\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.