Old page wikitext, before the edit (old_wikitext) | ''''HQ9+''' is a joke language with four instructions:
* '''H''': Print [[Hello, world!|"hello, world"]]
* '''Q''': [[Quine|Print the program's source code]]
* '''9''': Print the lyrics to [[99 bottles of beer|"99 Bottles of Beer"]]
* '''+''': Increment the accumulator
Although the language is not of serious interest by itself, it can be useful to implement HQ9+ in a new [[esoteric programming language]], since doing so proves that all the tasks above, except the quine, are possible. (Implementing '''Q''' proves instead that a [[cat program]] is possible.) HQ9+ was created in 2001 by [[Cliff L. Biffle]].
Given that the original description of the language includes an example program containing a lowercase "q", it seems reasonable to assume that instructions in HQ9+ are case-insensitive.
==Implementations==
[[User:Earthrulerr]] was here. I made a implementation in C++ with [[User:imcute]]!
<pre>
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
#ifdef _WIN32
#include <Windows.h>
#else
#include <unistd.h>
#endif
using namespace std;
int main() {
system("clear");
cout << "HQ9+ recreated in C++ by @earthrulerr and @imcute-aaaa" << endl;
sleep(4);
system("clear");
string input;
int acc=0;
int loop = 1;
while (loop == 1) {
cin>>input;
if (input == "h"){
cout << "Hello World" << endl;
}
else if(input == "q"){
cout<<"Q";
}
else if (input == "9"){
int bottle = 99;
while (bottle > 0){
cout << bottle << " bottles of beer on the wall,"
<< bottle << " bottles of beer." << endl;
bottle--;
cout << "Take one down and pass it around" << bottle << " " << "bottles of beer on the wall./n" << endl;
if (bottle == 1){
break;
}
}
cout << "1 bottle of beer on the wall, 1 bottle of bear." << endl;
cout << "Take one down and pass it around, no more bottles of beer on the wall./n" << endl;
cout << "No more bottles of beer on the wall, no more bottls of beer." << endl;
cout << "Go to the store and buy some more, 99 bottles of beer on the wall.";
return 0;
}
else if(input == "+"){
cout << ++acc << endl;
}
}
}
</pre>
[[User:Earthrulerr]] created a Bash implementation too:
<pre>
acc=0
loop=1
while [ $loop -eq 1 ]
do
read -p "> " input
if [ $input == "H" ]
then
echo "Hello World"
elif [ $input == "Q" ]
then
echo "q"
elif [ $input == "9" ]
then
bottle=99
while [ $bottle -gt 0 ]
do
echo "$bottle bottles of beer on the wall, $bottle bottles of beer."
bottle=$((bottle-1))
echo "Take one down and pass it around, $bottle bottles of beer on the wall."
if [ $bottle -eq 1 ]
then
break
fi
done
echo "1 bottle of beer on the wall, 1 bottle of bear."
echo "Take one down and pass it around, no more bottles of beer on the wall."
echo "No more bottles of beer on the wall, no more bottls of beer."
echo "Go to the store and buy some more, 99 bottles of beer on the wall."
elif [ $input == "+" ]
then
acc=$((acc+1))
echo "$acc"
fi
done
</pre>
[[User:A]] was here and here is an implementation (in C):
<pre>
#include <stdio.h>
int main()
{
unsigned long accumulator = 0;
char c[1000];
for(int i=0;;i++)
{
scanf("%c",&c[i]);
if(c[i]=='\n') break;
}
for(int i=0;c[i]!='\0';i++)
{
if(c[i]=='H') printf("Hello, World!\n");
else if(c[i]=='Q') printf("%.*s", (int)sizeof c, c);
else if(c[i]=='9')
{
for(int j=99;j>0;j--)
{
printf("%d bottles of beer on the wall,\n%d bottles of beer.\n", j, j);
printf("Take one down, pass it around,\n%d bottles of beer on the wall.\n", j-1);
}
printf("1 bottle of beer on the wall,\n1 bottle of beer.\nTake one down, pass it around,\nno more bottles of beer on the wall.\n");
}
else if(c[i]=='+') accumulator++;
}
return 0;
}
</pre>
Lanmonster fixed the Q instruction and added the + instruction. Qh4os fixed the 9 instruction. Chris Pressey also fixed the 9 instruction.
A python intepreter by [[User:Esolanger12345]]:
<pre>
accumulator=0
cmds=input(">>> ")
for cmd in cmds:
if cmd.lower() == "h":
print("Hello, world!")
elif cmd.lower() == "q":
print(cmds)
elif cmd == "9":
for i in range(99, 2, -1):
print(str(i)+" bottles of beer on the wall, "+str(i)+" bottles of beer.\nTake one down, pass it around, "+str(i-1)+" bottles of beer on the wall.")
print("2 bottles of beer on the wall, 2 bottles of beer.\nTake one down, pass it around, 1 bottle of beer on the wall.")
print("1 bottle of beer on the wall, 1 bottle of beer.\nTake one down, pass it around, No bottles of beer on the wall.")
print("No bottles of beer on the wall, No bottles of beer.\nGo to the store, buy some more, 99 bottles of beer on the wall.")
elif cmd == "+":
accumulator+=1
input()
</pre>
An interpreter made by [[User:Yes]] in BASIC
<pre>
10 PRINT "HQ9+ INTERPETER"
20 LET A=0
30 INPUT ">>>";A$
40 FOR X=1 TO LEN(A$)
50 IF MID$(A$,X,1)="H" THEN PRINT "HELLO, WORLD!"
60 IF MID$(A$,X,1)="Q" THEN PRINT A$
70 IF MID$(A$,X,1)="9" THEN GOTO 110
80 IF MID$(A$,X,1)="+" THEN LET A=A+1
90 NEXT X
100 END
110 FOR B=99 TO 1 STEP -1
120 PRINT B;" BOTTLES OF BEER ON THE WALL,":PRINT B;" BOTTLES OF BEER":PRINT "TAKE ONE DOWN,":PRINT "PASS IT AROUND":PRINT B-1;" BOTTLES OF BEER ON THE WALL"
130 NEXT B
140 PRINT "0 BOTTLES OF BEER ON THE WALL":PRINT "0 BOTTLES OF BEER": PRINT "GO TO THE STORE AND BUY SOME MORE,":PRINT "99 BOTTLES OF BEER ON THE WALL"
150 GOTO 90
</pre>
Note: This was made in an Applesoft BASIC interpeter here: [https://www.calormen.com/jsbasic/]
An interpreter made by [[User:Ohead]] for Node.js. Programs are entered using the argument after the JS file.
<pre>
function hq9(sourceCode) {
let sourceArray = sourceCode.split('');
let output = ``;
let accumulator = 0;
sourceArray.forEach(char=>{
switch (char) {
case 'H':
output += 'hello, world\n';
break;
case 'Q':
output += sourceCode + '\n';
break;
case '9':
let plural = (val) => {
if (val == 1)
return ''
else
return 's';
};
for (let i = 99; i > 0; i--) {
output += `${i} bottle${plural(i)} of beer on the wall, ${i} bottle${plural(i)} of beer
Take one down, pass it around ${i-1} bottle${plural(i-1)} of beer on the wall
`
};
break;
case '+':
accumulator++;
break;
};
});
return output;
};
console.log(hq9(process.argv[2]));
</pre>
An interpreter in Java maded by PSTF and his 文心一言:
<pre>
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class HQ9PlusInterpreter {
private static int counter = 0;
private static Map<String, Runnable> commands = new HashMap<>();
static {
commands.put("H", () -> System.out.println("Hello, world!"));
commands.put("Q", () -> System.out.println("Q"));
commands.put("9", () -> {
String s = "s";
for (int beers=99; beers>-1;){
System.out.print(beers + " bottle" + s + " of beer on the wall, ");
System.out.println(beers + " bottle" + s + " of beer, ");
if (beers==0){
System.out.print("Go to the store, buy some more, ");
System.out.println("99 bottles of beer on the wall.\n");
}
else{
System.out.print("Take one down, pass it around, ");
s = (--beers == 1)?"":"s";
System.out.println(beers + " bottle" + s + " of beer on the wall.\n");
}
}
});
commands.put("+", () -> counter++);
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("The HQ9+ interpreter by PrySigneToFry");
System.out.println("Enter HQ9+ commands (type 'exit' to quit):\n");
while (true) {
System.out.print("> ");
String command = scanner.nextLine();
if (command.equalsIgnoreCase("exit")) {
break;
}
Runnable action = commands.get(command);
if (action != null) {
action.run();
} else {
System.out.println("Unknown command: " + command);
}
// Print the current counter value after each command (except for '9' which is too verbose)
if (!command.equals("9")) {
System.out.println("Counter: " + counter);
}
}
scanner.close();
}
}
</pre>
[[User:MihaiEso]] has a interpreter in Batch, based on the [[FHC]]'s interpreter:
<pre>
@echo off
title HQ9+ Interpreter
:exe
cls
echo Type one of these characters (H, Q, 9, +) and we execute it...
set /p fhc=
if /i %fhc% EQU H goto hello
if /i %fhc% EQU Q goto quine
if /i %fhc% EQU 9 goto 99bottle
if /i %fhc% EQU + goto plus
cls
echo Error! You chose a wrong character. Only these are accepted: H, Q, 9 and +
pause >nul
goto exe
:quine
cls
echo Q
pause >nul
goto exe
:hello
cls
echo Hello, world!
pause >nul
goto exe
:99bottle
set x=99
set /a y=%x%-1
:loop
echo %x% bottles of beer on the wall,
echo %x% bottles of beer.
echo Take one down, pass it around,
echo %y% bottles of beer on the wall.
echo.
set /a x=%x%-1
set /a y=%x%-1
if %x% EQU 1 (
echo 1 bottle of beer on the wall,
echo 1 bottle of beer.
echo Take one down, pass it around,
echo No bottles of beer on the wall.
pause >nul
goto exe
)
goto loop
:plus
set acc=%acc%+1
goto exe
</pre>
An interpreter by Python made by PSTF:
<pre>
class HQ9PlusInterpreter:
def __init__(self):
self.counter = 0
def interpret(self, code):
lines = code.split('\n')
for line in lines:
line = line.strip()
if line == 'H':
print("Hello, world!")
elif line == 'Q':
print(code)
elif line == '9':
for i in range(99, -1, -1):
print(i) # This command is simply print a number sequence count from 99 to 0.
elif line == '+':
self.counter += 1
print(f"Counter is now: {self.counter}")
else:
print(f"Unknown command: {line}")
# Example usage:
print("HQ9+ interpreter by PSTF")
interpreter = HQ9PlusInterpreter()
while True:
code = input("Enter the command: ")
if code == "exit":
print("Thank you for using!")
break
else:
interpreter.interpret(code)
</pre>
im [[user:tommyaweosme]] heres my interpreter
<pre><script>
function run(){
var code = document.getElementById("code").value.split("");
var acc = 0;
var output = "";
var helloworld = "Hello, world!";
var source = document.getElementById("code").value;
var bottles = "99 bottles of beer on the wall, 99 bottles of beer.<br>Take one down and pass it around, 98 bottles of beer on the wall.<br><br>98 bottles of beer on the wall, 98 bottles of beer.<br>Take one down and pass it around, 97 bottles of beer on the wall.<br><br>97 bottles of beer on the wall, 97 bottles of beer.<br>Take one down and pass it around, 96 bottles of beer on the wall.<br><br>96 bottles of beer on the wall, 96 bottles of beer.<br>Take one down and pass it around, 95 bottles of beer on the wall.<br><br>95 bottles of beer on the wall, 95 bottles of beer.<br>Take one down and pass it around, 94 bottles of beer on the wall.<br><br>94 bottles of beer on the wall, 94 bottles of beer.<br>Take one down and pass it around, 93 bottles of beer on the wall.<br><br>93 bottles of beer on the wall, 93 bottles of beer.<br>Take one down and pass it around, 92 bottles of beer on the wall.<br><br>92 bottles of beer on the wall, 92 bottles of beer.<br>Take one down and pass it around, 91 bottles of beer on the wall.<br><br>91 bottles of beer on the wall, 91 bottles of beer.<br>Take one down and pass it around, 90 bottles of beer on the wall.<br><br>90 bottles of beer on the wall, 90 bottles of beer.<br>Take one down and pass it around, 89 bottles of beer on the wall.<br><br>89 bottles of beer on the wall, 89 bottles of beer.<br>Take one down and pass it around, 88 bottles of beer on the wall.<br><br>88 bottles of beer on the wall, 88 bottles of beer.<br>Take one down and pass it around, 87 bottles of beer on the wall.<br><br>87 bottles of beer on the wall, 87 bottles of beer.<br>Take one down and pass it around, 86 bottles of beer on the wall.<br><br>86 bottles of beer on the wall, 86 bottles of beer.<br>Take one down and pass it around, 85 bottles of beer on the wall.<br><br>85 bottles of beer on the wall, 85 bottles of beer.<br>Take one down and pass it around, 84 bottles of beer on the wall.<br><br>84 bottles of beer on the wall, 84 bottles of beer.<br>Take one down and pass it around, 83 bottles of beer on the wall.<br><br>83 bottles of beer on the wall, 83 bottles of beer.<br>Take one down and pass it around, 82 bottles of beer on the wall.<br><br>82 bottles of beer on the wall, 82 bottles of beer.<br>Take one down and pass it around, 81 bottles of beer on the wall.<br><br>81 bottles of beer on the wall, 81 bottles of beer.<br>Take one down and pass it around, 80 bottles of beer on the wall.<br><br>80 bottles of beer on the wall, 80 bottles of beer.<br>Take one down and pass it around, 79 bottles of beer on the wall.<br><br>79 bottles of beer on the wall, 79 bottles of beer.<br>Take one down and pass it around, 78 bottles of beer on the wall.<br><br>78 bottles of beer on the wall, 78 bottles of beer.<br>Take one down and pass it around, 77 bottles of beer on the wall.<br><br>77 bottles of beer on the wall, 77 bottles of beer.<br>Take one down and pass it around, 76 bottles of beer on the wall.<br><br>76 bottles of beer on the wall, 76 bottles of beer.<br>Take one down and pass it around, 75 bottles of beer on the wall.<br><br>75 bottles of beer on the wall, 75 bottles of beer.<br>Take one down and pass it around, 74 bottles of beer on the wall.<br><br>74 bottles of beer on the wall, 74 bottles of beer.<br>Take one down and pass it around, 73 bottles of beer on the wall.<br><br>73 bottles of beer on the wall, 73 bottles of beer.<br>Take one down and pass it around, 72 bottles of beer on the wall.<br><br>72 bottles of beer on the wall, 72 bottles of beer.<br>Take one down and pass it around, 71 bottles of beer on the wall.<br><br>71 bottles of beer on the wall, 71 bottles of beer.<br>Take one down and pass it around, 70 bottles of beer on the wall.<br><br>70 bottles of beer on the wall, 70 bottles of beer.<br>Take one down and pass it around, 69 bottles of beer on the wall.<br><br>69 bottles of beer on the wall, 69 bottles of beer.<br>Take one down and pass it around, 68 bottles of beer on the wall.<br><br>68 bottles of beer on the wall, 68 bottles of beer.<br>Take one down and pass it around, 67 bottles of beer on the wall.<br><br>67 bottles of beer on the wall, 67 bottles of beer.<br>Take one down and pass it around, 66 bottles of beer on the wall.<br><br>66 bottles of beer on the wall, 66 bottles of beer.<br>Take one down and pass it around, 65 bottles of beer on the wall.<br><br>65 bottles of beer on the wall, 65 bottles of beer.<br>Take one down and pass it around, 64 bottles of beer on the wall.<br><br>64 bottles of beer on the wall, 64 bottles of beer.<br>Take one down and pass it around, 63 bottles of beer on the wall.<br><br>63 bottles of beer on the wall, 63 bottles of beer.<br>Take one down and pass it around, 62 bottles of beer on the wall.<br><br>62 bottles of beer on the wall, 62 bottles of beer.<br>Take one down and pass it around, 61 bottles of beer on the wall.<br><br>61 bottles of beer on the wall, 61 bottles of beer.<br>Take one down and pass it around, 60 bottles of beer on the wall.<br><br>60 bottles of beer on the wall, 60 bottles of beer.<br>Take one down and pass it around, 59 bottles of beer on the wall.<br><br>59 bottles of beer on the wall, 59 bottles of beer.<br>Take one down and pass it around, 58 bottles of beer on the wall.<br><br>58 bottles of beer on the wall, 58 bottles of beer.<br>Take one down and pass it around, 57 bottles of beer on the wall.<br><br>57 bottles of beer on the wall, 57 bottles of beer.<br>Take one down and pass it around, 56 bottles of beer on the wall.<br><br>56 bottles of beer on the wall, 56 bottles of beer.<br>Take one down and pass it around, 55 bottles of beer on the wall.<br><br>55 bottles of beer on the wall, 55 bottles of beer.<br>Take one down and pass it around, 54 bottles of beer on the wall.<br><br>54 bottles of beer on the wall, 54 bottles of beer.<br>Take one down and pass it around, 53 bottles of beer on the wall.<br><br>53 bottles of beer on the wall, 53 bottles of beer.<br>Take one down and pass it around, 52 bottles of beer on the wall.<br><br>52 bottles of beer on the wall, 52 bottles of beer.<br>Take one down and pass it around, 51 bottles of beer on the wall.<br><br>51 bottles of beer on the wall, 51 bottles of beer.<br>Take one down and pass it around, 50 bottles of beer on the wall.<br><br>50 bottles of beer on the wall, 50 bottles of beer.<br>Take one down and pass it around, 49 bottles of beer on the wall.<br><br>49 bottles of beer on the wall, 49 bottles of beer.<br>Take one down and pass it around, 48 bottles of beer on the wall.<br><br>48 bottles of beer on the wall, 48 bottles of beer.<br>Take one down and pass it around, 47 bottles of beer on the wall.<br><br>47 bottles of beer on the wall, 47 bottles of beer.<br>Take one down and pass it around, 46 bottles of beer on the wall.<br><br>46 bottles of beer on the wall, 46 bottles of beer.<br>Take one down and pass it around, 45 bottles of beer on the wall.<br><br>45 bottles of beer on the wall, 45 bottles of beer.<br>Take one down and pass it around, 44 bottles of beer on the wall.<br><br>44 bottles of beer on the wall, 44 bottles of beer.<br>Take one down and pass it around, 43 bottles of beer on the wall.<br><br>43 bottles of beer on the wall, 43 bottles of beer.<br>Take one down and pass it around, 42 bottles of beer on the wall.<br><br>42 bottles of beer on the wall, 42 bottles of beer.<br>Take one down and pass it around, 41 bottles of beer on the wall.<br><br>41 bottles of beer on the wall, 41 bottles of beer.<br>Take one down and pass it around, 40 bottles of beer on the wall.<br><br>40 bottles of beer on the wall, 40 bottles of beer.<br>Take one down and pass it around, 39 bottles of beer on the wall.<br><br>39 bottles of beer on the wall, 39 bottles of beer.<br>Take one down and pass it around, 38 bottles of beer on the wall.<br><br>38 bottles of beer on the wall, 38 bottles of beer.<br>Take one down and pass it around, 37 bottles of beer on the wall.<br><br>37 bottles of beer on the wall, 37 bottles of beer.<br>Take one down and pass it around, 36 bottles of beer on the wall.<br><br>36 bottles of beer on the wall, 36 bottles of beer.<br>Take one down and pass it around, 35 bottles of beer on the wall.<br><br>35 bottles of beer on the wall, 35 bottles of beer.<br>Take one down and pass it around, 34 bottles of beer on the wall.<br><br>34 bottles of beer on the wall, 34 bottles of beer.<br>Take one down and pass it around, 33 bottles of beer on the wall.<br><br>33 bottles of beer on the wall, 33 bottles of beer.<br>Take one down and pass it around, 32 bottles of beer on the wall.<br><br>32 bottles of beer on the wall, 32 bottles of beer.<br>Take one down and pass it around, 31 bottles of beer on the wall.<br><br>31 bottles of beer on the wall, 31 bottles of beer.<br>Take one down and pass it around, 30 bottles of beer on the wall.<br><br>30 bottles of beer on the wall, 30 bottles of beer.<br>Take one down and pass it around, 29 bottles of beer on the wall.<br><br>29 bottles of beer on the wall, 29 bottles of beer.<br>Take one down and pass it around, 28 bottles of beer on the wall.<br><br>28 bottles of beer on the wall, 28 bottles of beer.<br>Take one down and pass it around, 27 bottles of beer on the wall.<br><br>27 bottles of beer on the wall, 27 bottles of beer.<br>Take one down and pass it around, 26 bottles of beer on the wall.<br><br>26 bottles of beer on the wall, 26 bottles of beer.<br>Take one down and pass it around, 25 bottles of beer on the wall.<br><br>25 bottles of beer on the wall, 25 bottles of beer.<br>Take one down and pass it around, 24 bottles of beer on the wall.<br><br>24 bottles of beer on the wall, 24 bottles of beer.<br>Take one down and pass it around, 23 bottles of beer on the wall.<br><br>23 bottles of beer on the wall, 23 bottles of beer.<br>Take one down and pass it around, 22 bottles of beer on the wall.<br><br>22 bottles of beer on the wall, 22 bottles of beer.<br>Take one down and pass it around, 21 bottles of beer on the wall.<br><br>21 bottles of beer on the wall, 21 bottles of beer.<br>Take one down and pass it around, 20 bottles of beer on the wall.<br><br>20 bottles of beer on the wall, 20 bottles of beer.<br>Take one down and pass it around, 19 bottles of beer on the wall.<br><br>19 bottles of beer on the wall, 19 bottles of beer.<br>Take one down and pass it around, 18 bottles of beer on the wall.<br><br>18 bottles of beer on the wall, 18 bottles of beer.<br>Take one down and pass it around, 17 bottles of beer on the wall.<br><br>17 bottles of beer on the wall, 17 bottles of beer.<br>Take one down and pass it around, 16 bottles of beer on the wall.<br><br>16 bottles of beer on the wall, 16 bottles of beer.<br>Take one down and pass it around, 15 bottles of beer on the wall.<br><br>15 bottles of beer on the wall, 15 bottles of beer.<br>Take one down and pass it around, 14 bottles of beer on the wall.<br><br>14 bottles of beer on the wall, 14 bottles of beer.<br>Take one down and pass it around, 13 bottles of beer on the wall.<br><br>13 bottles of beer on the wall, 13 bottles of beer.<br>Take one down and pass it around, 12 bottles of beer on the wall.<br><br>12 bottles of beer on the wall, 12 bottles of beer.<br>Take one down and pass it around, 11 bottles of beer on the wall.<br><br>11 bottles of beer on the wall, 11 bottles of beer.<br>Take one down and pass it around, 10 bottles of beer on the wall.<br><br>10 bottles of beer on the wall, 10 bottles of beer.<br>Take one down and pass it around, 9 bottles of beer on the wall.<br><br>9 bottles of beer on the wall, 9 bottles of beer.<br>Take one down and pass it around, 8 bottles of beer on the wall.<br><br>8 bottles of beer on the wall, 8 bottles of beer.<br>Take one down and pass it around, 7 bottles of beer on the wall.<br><br>7 bottles of beer on the wall, 7 bottles of beer.<br>Take one down and pass it around, 6 bottles of beer on the wall.<br><br>6 bottles of beer on the wall, 6 bottles of beer.<br>Take one down and pass it around, 5 bottles of beer on the wall.<br><br>5 bottles of beer on the wall, 5 bottles of beer.<br>Take one down and pass it around, 4 bottles of beer on the wall.<br><br>4 bottles of beer on the wall, 4 bottles of beer.<br>Take one down and pass it around, 3 bottles of beer on the wall.<br><br>3 bottles of beer on the wall, 3 bottles of beer.<br>Take one down and pass it around, 2 bottles of beer on the wall.<br><br>2 bottles of beer on the wall, 2 bottles of beer.<br>Take one down and pass it around, 1 bottle of beer on the wall.<br><br>1 bottle of beer on the wall, 1 bottle of beer.<br>Take one down and pass it around, no more bottles of beer on the wall.";
for (let i of code){
if (i == "h" || i == "H"){
var output = output + helloworld;
};
if (i == "q" || i == "Q"){
var output = output + source;
};
if (i == "9"){
var output = output + bottles;
};
if (i == "+"){
var acc = acc + 1;
};
};
document.getElementById("output").innerHTML = output
};
</script>
<h1>HQ9+ Interpreter</h1>
<p id="output"></p><br>
<input id="code"></input><button onclick="run()">run</button></pre>
==See also==
* [[HQ9++]], an [[object-oriented]] extension of HQ9+.
* [[HQ9+-]], an extension of HQ9++ with the - operator for debugging purposes.
* [[HQ9+~]], an extension of HQ9+ which is [[Turing-complete]].
* [[HQ9F+]], an extension of HQ9+ with the F operator for [[FizzBuzz]].
* [[FHQ9+-]], an extension of HQ9+- with the F operator for [[FizzBuzz]].
* [[CHIQRSX9+]], another HQ9+ extension supposedly Turing complete.
* [[HQ9+B]], an [[ℒ|ℒ-complete]] extension of HQ9+.
* [[HQ9+2D]], a 2-D extension of HQ9+.
* [[H9+]], with one fewer instruction but still capable of all of the tasks.
* [[FISHQ9+]], HQ9+ and deadfish combined.
* [[HI9+]], which replaces Q with an instruction that prints the interpreter's source code.
* [[+]], where there is only +, and other characters are ignored.
* [[Hq9eFuck]], HQ9+, brainfuck and Deep Thought combined.
* [[BrainfisHQ9+]], HQ9+, brainfuck and deadfish combined.
* [[ACHEQUEUENINETHOUSANDPLUS]], a more '''powerful''' derivative.
* [[AHQ9+-]], a derivative where the accumulator actually has a use. but
* [[HQ9~]] or HQ9Tilde, an extension of HQ9+ with a lot of new functions.
* [[Smasnug]] HQ9+ but good.
* [[🕳️Q9+]], HQ9+ and [[🕳️]] combined.
==External resources==
* {{Wayback|20090602074545|http://www.cliff.biffle.org/esoterica/hq9plus.html|HQ9+ home page}}
* [http://hackage.haskell.org/package/acme-hq9plus-0.1 HQ9+ as an embedded language in Haskell]
* {{Wayback|20060423042223|https://safalra.com/programming/interpreters/hq9plus/|Online HQ9+ interpreter in JavaScript}}
* [https://almnet.de/esolang/hq9plus.php Online HQ9+ interpreter realized with PHP]
* [http://github.com/mmphosis/hq9/blob/53ebcabe31894c5667d7c696ddf01acd5cf3e740/hq9.c HQ9+ interpreter in C] by [[User:mmphosis]]
* [http://www.fileupyours.com/files/309784/HQ9%2B.pas HQ9+ interpreter in Pascal] by [[User:GrandKeyboard]] {{deadlink}}
* [http://bschmalhofer.github.com/hq9plus/ hq9plus] - HQ9P implementation for [https://www.parrot.org/ Parrot]
* [https://github.com/timleg002/HQ9interpreter HQ9+ Interpreter] - HQ9+ interpreter written in Kotlin by [[User:Timleg002]]
[[Category:Joke languages]]
[[Category:Unusable for programming]]
[[Category:Languages]]
[[Category:Output only]]
[[Category:Implemented]]
[[Category:High-level]]
[[Category:2001]]
[[Category:Total]]
[[Category:Accumulator-based]]' |
New page wikitext, after the edit (new_wikitext) | '<!-- so? what? this is just a comment i made, i need to autocomfirm myself-->
'''HQ9+''' is a joke language with four instructions:
* '''H''': Print [[Hello, world!|"hello, world"]]
* '''Q''': [[Quine|Print the program's source code]]
* '''9''': Print the lyrics to [[99 bottles of beer|"99 Bottles of Beer"]]
* '''+''': Increment the accumulator
Although the language is not of serious interest by itself, it can be useful to implement HQ9+ in a new [[esoteric programming language]], since doing so proves that all the tasks above, except the quine, are possible. (Implementing '''Q''' proves instead that a [[cat program]] is possible.) HQ9+ was created in 2001 by [[Cliff L. Biffle]].
Given that the original description of the language includes an example program containing a lowercase "q", it seems reasonable to assume that instructions in HQ9+ are case-insensitive.
==Implementations==
[[User:Earthrulerr]] was here. I made a implementation in C++ with [[User:imcute]]!
<pre>
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
#ifdef _WIN32
#include <Windows.h>
#else
#include <unistd.h>
#endif
using namespace std;
int main() {
system("clear");
cout << "HQ9+ recreated in C++ by @earthrulerr and @imcute-aaaa" << endl;
sleep(4);
system("clear");
string input;
int acc=0;
int loop = 1;
while (loop == 1) {
cin>>input;
if (input == "h"){
cout << "Hello World" << endl;
}
else if(input == "q"){
cout<<"Q";
}
else if (input == "9"){
int bottle = 99;
while (bottle > 0){
cout << bottle << " bottles of beer on the wall,"
<< bottle << " bottles of beer." << endl;
bottle--;
cout << "Take one down and pass it around" << bottle << " " << "bottles of beer on the wall./n" << endl;
if (bottle == 1){
break;
}
}
cout << "1 bottle of beer on the wall, 1 bottle of bear." << endl;
cout << "Take one down and pass it around, no more bottles of beer on the wall./n" << endl;
cout << "No more bottles of beer on the wall, no more bottls of beer." << endl;
cout << "Go to the store and buy some more, 99 bottles of beer on the wall.";
return 0;
}
else if(input == "+"){
cout << ++acc << endl;
}
}
}
</pre>
[[User:Earthrulerr]] created a Bash implementation too:
<pre>
acc=0
loop=1
while [ $loop -eq 1 ]
do
read -p "> " input
if [ $input == "H" ]
then
echo "Hello World"
elif [ $input == "Q" ]
then
echo "q"
elif [ $input == "9" ]
then
bottle=99
while [ $bottle -gt 0 ]
do
echo "$bottle bottles of beer on the wall, $bottle bottles of beer."
bottle=$((bottle-1))
echo "Take one down and pass it around, $bottle bottles of beer on the wall."
if [ $bottle -eq 1 ]
then
break
fi
done
echo "1 bottle of beer on the wall, 1 bottle of bear."
echo "Take one down and pass it around, no more bottles of beer on the wall."
echo "No more bottles of beer on the wall, no more bottls of beer."
echo "Go to the store and buy some more, 99 bottles of beer on the wall."
elif [ $input == "+" ]
then
acc=$((acc+1))
echo "$acc"
fi
done
</pre>
[[User:A]] was here and here is an implementation (in C):
<pre>
#include <stdio.h>
int main()
{
unsigned long accumulator = 0;
char c[1000];
for(int i=0;;i++)
{
scanf("%c",&c[i]);
if(c[i]=='\n') break;
}
for(int i=0;c[i]!='\0';i++)
{
if(c[i]=='H') printf("Hello, World!\n");
else if(c[i]=='Q') printf("%.*s", (int)sizeof c, c);
else if(c[i]=='9')
{
for(int j=99;j>0;j--)
{
printf("%d bottles of beer on the wall,\n%d bottles of beer.\n", j, j);
printf("Take one down, pass it around,\n%d bottles of beer on the wall.\n", j-1);
}
printf("1 bottle of beer on the wall,\n1 bottle of beer.\nTake one down, pass it around,\nno more bottles of beer on the wall.\n");
}
else if(c[i]=='+') accumulator++;
}
return 0;
}
</pre>
Lanmonster fixed the Q instruction and added the + instruction. Qh4os fixed the 9 instruction. Chris Pressey also fixed the 9 instruction.
A python intepreter by [[User:Esolanger12345]]:
<pre>
accumulator=0
cmds=input(">>> ")
for cmd in cmds:
if cmd.lower() == "h":
print("Hello, world!")
elif cmd.lower() == "q":
print(cmds)
elif cmd == "9":
for i in range(99, 2, -1):
print(str(i)+" bottles of beer on the wall, "+str(i)+" bottles of beer.\nTake one down, pass it around, "+str(i-1)+" bottles of beer on the wall.")
print("2 bottles of beer on the wall, 2 bottles of beer.\nTake one down, pass it around, 1 bottle of beer on the wall.")
print("1 bottle of beer on the wall, 1 bottle of beer.\nTake one down, pass it around, No bottles of beer on the wall.")
print("No bottles of beer on the wall, No bottles of beer.\nGo to the store, buy some more, 99 bottles of beer on the wall.")
elif cmd == "+":
accumulator+=1
input()
</pre>
An interpreter made by [[User:Yes]] in BASIC
<pre>
10 PRINT "HQ9+ INTERPETER"
20 LET A=0
30 INPUT ">>>";A$
40 FOR X=1 TO LEN(A$)
50 IF MID$(A$,X,1)="H" THEN PRINT "HELLO, WORLD!"
60 IF MID$(A$,X,1)="Q" THEN PRINT A$
70 IF MID$(A$,X,1)="9" THEN GOTO 110
80 IF MID$(A$,X,1)="+" THEN LET A=A+1
90 NEXT X
100 END
110 FOR B=99 TO 1 STEP -1
120 PRINT B;" BOTTLES OF BEER ON THE WALL,":PRINT B;" BOTTLES OF BEER":PRINT "TAKE ONE DOWN,":PRINT "PASS IT AROUND":PRINT B-1;" BOTTLES OF BEER ON THE WALL"
130 NEXT B
140 PRINT "0 BOTTLES OF BEER ON THE WALL":PRINT "0 BOTTLES OF BEER": PRINT "GO TO THE STORE AND BUY SOME MORE,":PRINT "99 BOTTLES OF BEER ON THE WALL"
150 GOTO 90
</pre>
Note: This was made in an Applesoft BASIC interpeter here: [https://www.calormen.com/jsbasic/]
An interpreter made by [[User:Ohead]] for Node.js. Programs are entered using the argument after the JS file.
<pre>
function hq9(sourceCode) {
let sourceArray = sourceCode.split('');
let output = ``;
let accumulator = 0;
sourceArray.forEach(char=>{
switch (char) {
case 'H':
output += 'hello, world\n';
break;
case 'Q':
output += sourceCode + '\n';
break;
case '9':
let plural = (val) => {
if (val == 1)
return ''
else
return 's';
};
for (let i = 99; i > 0; i--) {
output += `${i} bottle${plural(i)} of beer on the wall, ${i} bottle${plural(i)} of beer
Take one down, pass it around ${i-1} bottle${plural(i-1)} of beer on the wall
`
};
break;
case '+':
accumulator++;
break;
};
});
return output;
};
console.log(hq9(process.argv[2]));
</pre>
An interpreter in Java maded by PSTF and his 文心一言:
<pre>
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class HQ9PlusInterpreter {
private static int counter = 0;
private static Map<String, Runnable> commands = new HashMap<>();
static {
commands.put("H", () -> System.out.println("Hello, world!"));
commands.put("Q", () -> System.out.println("Q"));
commands.put("9", () -> {
String s = "s";
for (int beers=99; beers>-1;){
System.out.print(beers + " bottle" + s + " of beer on the wall, ");
System.out.println(beers + " bottle" + s + " of beer, ");
if (beers==0){
System.out.print("Go to the store, buy some more, ");
System.out.println("99 bottles of beer on the wall.\n");
}
else{
System.out.print("Take one down, pass it around, ");
s = (--beers == 1)?"":"s";
System.out.println(beers + " bottle" + s + " of beer on the wall.\n");
}
}
});
commands.put("+", () -> counter++);
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("The HQ9+ interpreter by PrySigneToFry");
System.out.println("Enter HQ9+ commands (type 'exit' to quit):\n");
while (true) {
System.out.print("> ");
String command = scanner.nextLine();
if (command.equalsIgnoreCase("exit")) {
break;
}
Runnable action = commands.get(command);
if (action != null) {
action.run();
} else {
System.out.println("Unknown command: " + command);
}
// Print the current counter value after each command (except for '9' which is too verbose)
if (!command.equals("9")) {
System.out.println("Counter: " + counter);
}
}
scanner.close();
}
}
</pre>
[[User:MihaiEso]] has a interpreter in Batch, based on the [[FHC]]'s interpreter:
<pre>
@echo off
title HQ9+ Interpreter
:exe
cls
echo Type one of these characters (H, Q, 9, +) and we execute it...
set /p fhc=
if /i %fhc% EQU H goto hello
if /i %fhc% EQU Q goto quine
if /i %fhc% EQU 9 goto 99bottle
if /i %fhc% EQU + goto plus
cls
echo Error! You chose a wrong character. Only these are accepted: H, Q, 9 and +
pause >nul
goto exe
:quine
cls
echo Q
pause >nul
goto exe
:hello
cls
echo Hello, world!
pause >nul
goto exe
:99bottle
set x=99
set /a y=%x%-1
:loop
echo %x% bottles of beer on the wall,
echo %x% bottles of beer.
echo Take one down, pass it around,
echo %y% bottles of beer on the wall.
echo.
set /a x=%x%-1
set /a y=%x%-1
if %x% EQU 1 (
echo 1 bottle of beer on the wall,
echo 1 bottle of beer.
echo Take one down, pass it around,
echo No bottles of beer on the wall.
pause >nul
goto exe
)
goto loop
:plus
set acc=%acc%+1
goto exe
</pre>
An interpreter by Python made by PSTF:
<pre>
class HQ9PlusInterpreter:
def __init__(self):
self.counter = 0
def interpret(self, code):
lines = code.split('\n')
for line in lines:
line = line.strip()
if line == 'H':
print("Hello, world!")
elif line == 'Q':
print(code)
elif line == '9':
for i in range(99, -1, -1):
print(i) # This command is simply print a number sequence count from 99 to 0.
elif line == '+':
self.counter += 1
print(f"Counter is now: {self.counter}")
else:
print(f"Unknown command: {line}")
# Example usage:
print("HQ9+ interpreter by PSTF")
interpreter = HQ9PlusInterpreter()
while True:
code = input("Enter the command: ")
if code == "exit":
print("Thank you for using!")
break
else:
interpreter.interpret(code)
</pre>
im [[user:tommyaweosme]] heres my interpreter
<pre><script>
function run(){
var code = document.getElementById("code").value.split("");
var acc = 0;
var output = "";
var helloworld = "Hello, world!";
var source = document.getElementById("code").value;
var bottles = "99 bottles of beer on the wall, 99 bottles of beer.<br>Take one down and pass it around, 98 bottles of beer on the wall.<br><br>98 bottles of beer on the wall, 98 bottles of beer.<br>Take one down and pass it around, 97 bottles of beer on the wall.<br><br>97 bottles of beer on the wall, 97 bottles of beer.<br>Take one down and pass it around, 96 bottles of beer on the wall.<br><br>96 bottles of beer on the wall, 96 bottles of beer.<br>Take one down and pass it around, 95 bottles of beer on the wall.<br><br>95 bottles of beer on the wall, 95 bottles of beer.<br>Take one down and pass it around, 94 bottles of beer on the wall.<br><br>94 bottles of beer on the wall, 94 bottles of beer.<br>Take one down and pass it around, 93 bottles of beer on the wall.<br><br>93 bottles of beer on the wall, 93 bottles of beer.<br>Take one down and pass it around, 92 bottles of beer on the wall.<br><br>92 bottles of beer on the wall, 92 bottles of beer.<br>Take one down and pass it around, 91 bottles of beer on the wall.<br><br>91 bottles of beer on the wall, 91 bottles of beer.<br>Take one down and pass it around, 90 bottles of beer on the wall.<br><br>90 bottles of beer on the wall, 90 bottles of beer.<br>Take one down and pass it around, 89 bottles of beer on the wall.<br><br>89 bottles of beer on the wall, 89 bottles of beer.<br>Take one down and pass it around, 88 bottles of beer on the wall.<br><br>88 bottles of beer on the wall, 88 bottles of beer.<br>Take one down and pass it around, 87 bottles of beer on the wall.<br><br>87 bottles of beer on the wall, 87 bottles of beer.<br>Take one down and pass it around, 86 bottles of beer on the wall.<br><br>86 bottles of beer on the wall, 86 bottles of beer.<br>Take one down and pass it around, 85 bottles of beer on the wall.<br><br>85 bottles of beer on the wall, 85 bottles of beer.<br>Take one down and pass it around, 84 bottles of beer on the wall.<br><br>84 bottles of beer on the wall, 84 bottles of beer.<br>Take one down and pass it around, 83 bottles of beer on the wall.<br><br>83 bottles of beer on the wall, 83 bottles of beer.<br>Take one down and pass it around, 82 bottles of beer on the wall.<br><br>82 bottles of beer on the wall, 82 bottles of beer.<br>Take one down and pass it around, 81 bottles of beer on the wall.<br><br>81 bottles of beer on the wall, 81 bottles of beer.<br>Take one down and pass it around, 80 bottles of beer on the wall.<br><br>80 bottles of beer on the wall, 80 bottles of beer.<br>Take one down and pass it around, 79 bottles of beer on the wall.<br><br>79 bottles of beer on the wall, 79 bottles of beer.<br>Take one down and pass it around, 78 bottles of beer on the wall.<br><br>78 bottles of beer on the wall, 78 bottles of beer.<br>Take one down and pass it around, 77 bottles of beer on the wall.<br><br>77 bottles of beer on the wall, 77 bottles of beer.<br>Take one down and pass it around, 76 bottles of beer on the wall.<br><br>76 bottles of beer on the wall, 76 bottles of beer.<br>Take one down and pass it around, 75 bottles of beer on the wall.<br><br>75 bottles of beer on the wall, 75 bottles of beer.<br>Take one down and pass it around, 74 bottles of beer on the wall.<br><br>74 bottles of beer on the wall, 74 bottles of beer.<br>Take one down and pass it around, 73 bottles of beer on the wall.<br><br>73 bottles of beer on the wall, 73 bottles of beer.<br>Take one down and pass it around, 72 bottles of beer on the wall.<br><br>72 bottles of beer on the wall, 72 bottles of beer.<br>Take one down and pass it around, 71 bottles of beer on the wall.<br><br>71 bottles of beer on the wall, 71 bottles of beer.<br>Take one down and pass it around, 70 bottles of beer on the wall.<br><br>70 bottles of beer on the wall, 70 bottles of beer.<br>Take one down and pass it around, 69 bottles of beer on the wall.<br><br>69 bottles of beer on the wall, 69 bottles of beer.<br>Take one down and pass it around, 68 bottles of beer on the wall.<br><br>68 bottles of beer on the wall, 68 bottles of beer.<br>Take one down and pass it around, 67 bottles of beer on the wall.<br><br>67 bottles of beer on the wall, 67 bottles of beer.<br>Take one down and pass it around, 66 bottles of beer on the wall.<br><br>66 bottles of beer on the wall, 66 bottles of beer.<br>Take one down and pass it around, 65 bottles of beer on the wall.<br><br>65 bottles of beer on the wall, 65 bottles of beer.<br>Take one down and pass it around, 64 bottles of beer on the wall.<br><br>64 bottles of beer on the wall, 64 bottles of beer.<br>Take one down and pass it around, 63 bottles of beer on the wall.<br><br>63 bottles of beer on the wall, 63 bottles of beer.<br>Take one down and pass it around, 62 bottles of beer on the wall.<br><br>62 bottles of beer on the wall, 62 bottles of beer.<br>Take one down and pass it around, 61 bottles of beer on the wall.<br><br>61 bottles of beer on the wall, 61 bottles of beer.<br>Take one down and pass it around, 60 bottles of beer on the wall.<br><br>60 bottles of beer on the wall, 60 bottles of beer.<br>Take one down and pass it around, 59 bottles of beer on the wall.<br><br>59 bottles of beer on the wall, 59 bottles of beer.<br>Take one down and pass it around, 58 bottles of beer on the wall.<br><br>58 bottles of beer on the wall, 58 bottles of beer.<br>Take one down and pass it around, 57 bottles of beer on the wall.<br><br>57 bottles of beer on the wall, 57 bottles of beer.<br>Take one down and pass it around, 56 bottles of beer on the wall.<br><br>56 bottles of beer on the wall, 56 bottles of beer.<br>Take one down and pass it around, 55 bottles of beer on the wall.<br><br>55 bottles of beer on the wall, 55 bottles of beer.<br>Take one down and pass it around, 54 bottles of beer on the wall.<br><br>54 bottles of beer on the wall, 54 bottles of beer.<br>Take one down and pass it around, 53 bottles of beer on the wall.<br><br>53 bottles of beer on the wall, 53 bottles of beer.<br>Take one down and pass it around, 52 bottles of beer on the wall.<br><br>52 bottles of beer on the wall, 52 bottles of beer.<br>Take one down and pass it around, 51 bottles of beer on the wall.<br><br>51 bottles of beer on the wall, 51 bottles of beer.<br>Take one down and pass it around, 50 bottles of beer on the wall.<br><br>50 bottles of beer on the wall, 50 bottles of beer.<br>Take one down and pass it around, 49 bottles of beer on the wall.<br><br>49 bottles of beer on the wall, 49 bottles of beer.<br>Take one down and pass it around, 48 bottles of beer on the wall.<br><br>48 bottles of beer on the wall, 48 bottles of beer.<br>Take one down and pass it around, 47 bottles of beer on the wall.<br><br>47 bottles of beer on the wall, 47 bottles of beer.<br>Take one down and pass it around, 46 bottles of beer on the wall.<br><br>46 bottles of beer on the wall, 46 bottles of beer.<br>Take one down and pass it around, 45 bottles of beer on the wall.<br><br>45 bottles of beer on the wall, 45 bottles of beer.<br>Take one down and pass it around, 44 bottles of beer on the wall.<br><br>44 bottles of beer on the wall, 44 bottles of beer.<br>Take one down and pass it around, 43 bottles of beer on the wall.<br><br>43 bottles of beer on the wall, 43 bottles of beer.<br>Take one down and pass it around, 42 bottles of beer on the wall.<br><br>42 bottles of beer on the wall, 42 bottles of beer.<br>Take one down and pass it around, 41 bottles of beer on the wall.<br><br>41 bottles of beer on the wall, 41 bottles of beer.<br>Take one down and pass it around, 40 bottles of beer on the wall.<br><br>40 bottles of beer on the wall, 40 bottles of beer.<br>Take one down and pass it around, 39 bottles of beer on the wall.<br><br>39 bottles of beer on the wall, 39 bottles of beer.<br>Take one down and pass it around, 38 bottles of beer on the wall.<br><br>38 bottles of beer on the wall, 38 bottles of beer.<br>Take one down and pass it around, 37 bottles of beer on the wall.<br><br>37 bottles of beer on the wall, 37 bottles of beer.<br>Take one down and pass it around, 36 bottles of beer on the wall.<br><br>36 bottles of beer on the wall, 36 bottles of beer.<br>Take one down and pass it around, 35 bottles of beer on the wall.<br><br>35 bottles of beer on the wall, 35 bottles of beer.<br>Take one down and pass it around, 34 bottles of beer on the wall.<br><br>34 bottles of beer on the wall, 34 bottles of beer.<br>Take one down and pass it around, 33 bottles of beer on the wall.<br><br>33 bottles of beer on the wall, 33 bottles of beer.<br>Take one down and pass it around, 32 bottles of beer on the wall.<br><br>32 bottles of beer on the wall, 32 bottles of beer.<br>Take one down and pass it around, 31 bottles of beer on the wall.<br><br>31 bottles of beer on the wall, 31 bottles of beer.<br>Take one down and pass it around, 30 bottles of beer on the wall.<br><br>30 bottles of beer on the wall, 30 bottles of beer.<br>Take one down and pass it around, 29 bottles of beer on the wall.<br><br>29 bottles of beer on the wall, 29 bottles of beer.<br>Take one down and pass it around, 28 bottles of beer on the wall.<br><br>28 bottles of beer on the wall, 28 bottles of beer.<br>Take one down and pass it around, 27 bottles of beer on the wall.<br><br>27 bottles of beer on the wall, 27 bottles of beer.<br>Take one down and pass it around, 26 bottles of beer on the wall.<br><br>26 bottles of beer on the wall, 26 bottles of beer.<br>Take one down and pass it around, 25 bottles of beer on the wall.<br><br>25 bottles of beer on the wall, 25 bottles of beer.<br>Take one down and pass it around, 24 bottles of beer on the wall.<br><br>24 bottles of beer on the wall, 24 bottles of beer.<br>Take one down and pass it around, 23 bottles of beer on the wall.<br><br>23 bottles of beer on the wall, 23 bottles of beer.<br>Take one down and pass it around, 22 bottles of beer on the wall.<br><br>22 bottles of beer on the wall, 22 bottles of beer.<br>Take one down and pass it around, 21 bottles of beer on the wall.<br><br>21 bottles of beer on the wall, 21 bottles of beer.<br>Take one down and pass it around, 20 bottles of beer on the wall.<br><br>20 bottles of beer on the wall, 20 bottles of beer.<br>Take one down and pass it around, 19 bottles of beer on the wall.<br><br>19 bottles of beer on the wall, 19 bottles of beer.<br>Take one down and pass it around, 18 bottles of beer on the wall.<br><br>18 bottles of beer on the wall, 18 bottles of beer.<br>Take one down and pass it around, 17 bottles of beer on the wall.<br><br>17 bottles of beer on the wall, 17 bottles of beer.<br>Take one down and pass it around, 16 bottles of beer on the wall.<br><br>16 bottles of beer on the wall, 16 bottles of beer.<br>Take one down and pass it around, 15 bottles of beer on the wall.<br><br>15 bottles of beer on the wall, 15 bottles of beer.<br>Take one down and pass it around, 14 bottles of beer on the wall.<br><br>14 bottles of beer on the wall, 14 bottles of beer.<br>Take one down and pass it around, 13 bottles of beer on the wall.<br><br>13 bottles of beer on the wall, 13 bottles of beer.<br>Take one down and pass it around, 12 bottles of beer on the wall.<br><br>12 bottles of beer on the wall, 12 bottles of beer.<br>Take one down and pass it around, 11 bottles of beer on the wall.<br><br>11 bottles of beer on the wall, 11 bottles of beer.<br>Take one down and pass it around, 10 bottles of beer on the wall.<br><br>10 bottles of beer on the wall, 10 bottles of beer.<br>Take one down and pass it around, 9 bottles of beer on the wall.<br><br>9 bottles of beer on the wall, 9 bottles of beer.<br>Take one down and pass it around, 8 bottles of beer on the wall.<br><br>8 bottles of beer on the wall, 8 bottles of beer.<br>Take one down and pass it around, 7 bottles of beer on the wall.<br><br>7 bottles of beer on the wall, 7 bottles of beer.<br>Take one down and pass it around, 6 bottles of beer on the wall.<br><br>6 bottles of beer on the wall, 6 bottles of beer.<br>Take one down and pass it around, 5 bottles of beer on the wall.<br><br>5 bottles of beer on the wall, 5 bottles of beer.<br>Take one down and pass it around, 4 bottles of beer on the wall.<br><br>4 bottles of beer on the wall, 4 bottles of beer.<br>Take one down and pass it around, 3 bottles of beer on the wall.<br><br>3 bottles of beer on the wall, 3 bottles of beer.<br>Take one down and pass it around, 2 bottles of beer on the wall.<br><br>2 bottles of beer on the wall, 2 bottles of beer.<br>Take one down and pass it around, 1 bottle of beer on the wall.<br><br>1 bottle of beer on the wall, 1 bottle of beer.<br>Take one down and pass it around, no more bottles of beer on the wall.";
for (let i of code){
if (i == "h" || i == "H"){
var output = output + helloworld;
};
if (i == "q" || i == "Q"){
var output = output + source;
};
if (i == "9"){
var output = output + bottles;
};
if (i == "+"){
var acc = acc + 1;
};
};
document.getElementById("output").innerHTML = output
};
</script>
<h1>HQ9+ Interpreter</h1>
<p id="output"></p><br>
<input id="code"></input><button onclick="run()">run</button></pre>
==See also==
* [[HQ9++]], an [[object-oriented]] extension of HQ9+.
* [[HQ9+-]], an extension of HQ9++ with the - operator for debugging purposes.
* [[HQ9+~]], an extension of HQ9+ which is [[Turing-complete]].
* [[HQ9F+]], an extension of HQ9+ with the F operator for [[FizzBuzz]].
* [[FHQ9+-]], an extension of HQ9+- with the F operator for [[FizzBuzz]].
* [[CHIQRSX9+]], another HQ9+ extension supposedly Turing complete.
* [[HQ9+B]], an [[ℒ|ℒ-complete]] extension of HQ9+.
* [[HQ9+2D]], a 2-D extension of HQ9+.
* [[H9+]], with one fewer instruction but still capable of all of the tasks.
* [[FISHQ9+]], HQ9+ and deadfish combined.
* [[HI9+]], which replaces Q with an instruction that prints the interpreter's source code.
* [[+]], where there is only +, and other characters are ignored.
* [[Hq9eFuck]], HQ9+, brainfuck and Deep Thought combined.
* [[BrainfisHQ9+]], HQ9+, brainfuck and deadfish combined.
* [[ACHEQUEUENINETHOUSANDPLUS]], a more '''powerful''' derivative.
* [[AHQ9+-]], a derivative where the accumulator actually has a use. but
* [[HQ9~]] or HQ9Tilde, an extension of HQ9+ with a lot of new functions.
* [[Smasnug]] HQ9+ but good.
* [[🕳️Q9+]], HQ9+ and [[🕳️]] combined.
==External resources==
* {{Wayback|20090602074545|http://www.cliff.biffle.org/esoterica/hq9plus.html|HQ9+ home page}}
* [http://hackage.haskell.org/package/acme-hq9plus-0.1 HQ9+ as an embedded language in Haskell]
* {{Wayback|20060423042223|https://safalra.com/programming/interpreters/hq9plus/|Online HQ9+ interpreter in JavaScript}}
* [https://almnet.de/esolang/hq9plus.php Online HQ9+ interpreter realized with PHP]
* [http://github.com/mmphosis/hq9/blob/53ebcabe31894c5667d7c696ddf01acd5cf3e740/hq9.c HQ9+ interpreter in C] by [[User:mmphosis]]
* [http://www.fileupyours.com/files/309784/HQ9%2B.pas HQ9+ interpreter in Pascal] by [[User:GrandKeyboard]] {{deadlink}}
* [http://bschmalhofer.github.com/hq9plus/ hq9plus] - HQ9P implementation for [https://www.parrot.org/ Parrot]
* [https://github.com/timleg002/HQ9interpreter HQ9+ Interpreter] - HQ9+ interpreter written in Kotlin by [[User:Timleg002]]
[[Category:Joke languages]]
[[Category:Unusable for programming]]
[[Category:Languages]]
[[Category:Output only]]
[[Category:Implemented]]
[[Category:High-level]]
[[Category:2001]]
[[Category:Total]]
[[Category:Accumulator-based]]' |