Hello World (Alice ML)

From LiteratePrograms
Jump to: navigation, search
Other implementations: Alice ML | Amiga E | AspectJ | Assembly Intel x86 Linux | Assembly Intel x86 NetBSD | AWK | bash | BASIC | Batch files | C | C, Cairo | C, Xlib | Candle | C++ | C# | Dylan | E | Forth | FORTRAN | Fortress | Go | Groovy | Haskell | IBM PC bootstrap | Inform 7 | Java | JavaScript | LaTeX | Logo | Lua | MATLAB | Mercury | OCaml/F Sharp | occam | Oz | Perl | PHP | PIR | PLI | Prolog | Python | Rexx | Ruby | Scala | Scheme | Seed7 | sh | SQL | Standard ML | Tcl | Tcl Tk | Visual Basic | XSL

This is a simple Alice ML program that prints "Hello, World!" to the console, and then prints the numbers 1 through 10.

<<Helloworld.aml>>=
structure Helloworld = 
struct
   fun printnums _ 0   = ()
     | printnums x n = (TextIO.print (Int.toString x^"\n"); printnums (x+1) (n-1))
  
   val _ = (TextIO.print "Hello, World!\n"; printnums 1 10; OS.Process.exit(OS.Process.success)) 
end 

If you have the Alice ML runtime installed, this program can be compiled and executed by typing the following at the OS command line:

alicec Helloworld.aml
alicerun Helloworld.alc
Download code
hijacker
hijacker
hijacker
hijacker