#!/usr/bin/env mars # Ten Green Bottles (CGI) # # This is intended as a demonstration of writing a CGI program (web app) in # the Mars programming language. # # Algorithmically generates the lyrics to "Ten Green Bottles", and prints it # out as a CGI/HTML page. # # Run by dropping this file into a web server's cgi-bin directory, and # visiting in a browser. import prelude def main() :: io Num: var i :: Num print_string("Content-Type: text/html\n") print_string("\n") print_string("
")
print_value(i)
print_string(" green bottles, hanging on the wall.
\n")
print_value(i)
print_string(" green bottles, hanging on the wall.
\n")
print_string("But if one green bottle should accidentally fall,
\n")
print_string("There'll be ")
i = i - 1
if i > 0:
print_value(i)
else:
print_string("no")
print_string(" green bottles, hanging on the wall.