Hello World (Dylan)

From LiteratePrograms
Jump to: navigation, search
Other implementations: Alice ML | Amiga E | 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 | IBM PC bootstrap | Inform 7 | JavaScript | LaTeX | Logo | LOLCODE | Lua | MATLAB | OCaml/F Sharp | occam | Oz | Perl | PHP | PIR | PLI | Prolog | Python | Rexx | Ruby | Scheme | sh | SQL | Standard ML | Tcl | Tcl Tk | Visual Basic

This is a simple Dylan program that prints a string to the console, and then uses a for-loop to print the numbers 1 to 10. Dylan runs code at the top level of the startup module when the program starts, making this particularly simple.

<<hello-world.dylan>>=
module: hello-world

format-out("Hello World!\n");
for (i from 0 below 11)
  format-out("%d\n", i);
end for;

Using the Gwydion d2c tool, you can build this into a binary with the following command-line, where the "-s" denotes "single file":

d2c -s hello-world.dylan
Download code
hijacker
hijacker
hijacker
hijacker