Mars sample program (Download)
#!/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("<h1>Ten Green Bottles</h1>\n")
i = 10
while i > 0:
print_string("<p>")
print_value(i)
print_string(" green bottles, hanging on the wall.<br />\n")
print_value(i)
print_string(" green bottles, hanging on the wall.<br />\n")
print_string("But if one green bottle should accidentally fall,<br />\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.</p>\n\n")
return 0