RosettaCodeData/Task/Execute-HQ9+/PARI-GP/execute-hq9+.pari
Ingy döt Net d066446780 langs a-z
2013-04-10 22:43:41 -07:00

23 lines
647 B
Text

beer(n)={
if(n == 1,
print("1 bottle of beer on the wall");
print("1 bottle of beer");
print("Take one down and pass it around");
print("No bottles of beer on the wall")
,
print(n" bottles of beer on the wall");
print(n" bottles of beer");
print("Take one down and pass it around");
print(n-1," bottles of beer on the wall\n");
beer(n-1)
)
};
HQ9p(s)={
my(accum=0,v=Vec(s));
for(i=1,#s,
if(v[i] == "H" || v[i] == "h", print("Hello, world!"); next);
if(v[i] == "Q" || v[i] == "q", print(s); next);
if(v[i] == "9", beer(99); next);
if(v[i] == "+", accum++, error("Nasal demons"))
)
};