Hello World (Lisp)
From LiteratePrograms
- Other implementations: Ada | ALGOL 68 | Alice ML | Amiga E | Applescript | AspectJ | Assembly Intel x86 Linux | Assembly Intel x86 NetBSD | AWK | bash | BASIC | Batch files | C | C, Cairo | C, Xlib | C++ | C# | Delphi | Dylan | E | Eiffel | Erlang | Forth | Fortress | Groovy | Haskell | Hume | IBM PC bootstrap | Inform 7 | Java | Java, Swing | JavaScript | LaTeX | Lisp | Logo | Maple | MATLAB | Mercury | OCaml/F Sharp | occam | Oz | Pascal | Perl | PHP | Pic | PIR | PLI | PostScript | Prolog | Python | Rexx | Ruby | Scala | Scheme | Seed7 | sh | Smalltalk | SQL | SVG | Tcl | Tcl Tk | Visual Basic | Visual Basic .NET | XSL
(Common Lisp)
There are a lot of different ways to print "Hello World" on the console.
All functions print the same string to the console, but there are some minor differences:
The following function prints the string and appends a newline.
<<hello.lisp>>= (write-line "Hello World")
This function prints "Hello World" (which is the string in READable form) and appends one newline.
<<hello.lisp>>= (print "Hello World")
This function just prints the string.
<<hello.lisp>>= (princ "Hello World")
This function prints the string READably.
<<hello.lisp>>= (prin1 "Hello World")
Other possibilities include WRITE and FORMAT, the latter being lisps equivalent to C's printf (but on stereoids). In this example, T means, that the output should go to *STANDARD-OUTPUT*, which is usually the listener. Other strams may be used. If it were NIL, the string would just be returned without being printed at all. The ~% in the following format-string is format's \n.
<<hello.lisp>>= (format t "Hello World~%")
| Download code |
