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 | Candle | Clojure | C++ | C# | Delphi | Dylan | E | Eiffel | Erlang | Forth | FORTRAN | Fortress | Go | Groovy | Haskell | Hume | IBM PC bootstrap | Inform 7 | Java | Java, Swing | JavaScript | LaTeX | Lisp | Logo | Lua | 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 | Standard ML | SVG | Tcl | Tcl Tk | Visual Basic | Visual Basic .NET | XSL
(Common Lisp)
There are a lot of ways to print "Hello World" on the console. All of the following 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 form understandable by the READ function) 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 in a form understood by the READ function:
<<hello.lisp>>= (prin1 "Hello World")
Other possibilities include WRITE and FORMAT, the latter being LISP's equivalent to the C function printf (but more powerful). In the following example (which uses FORMAT), T means, that the output should go to *STANDARD-OUTPUT*, which is usually the listener. Other streams may be used. If it were NIL, the string would just be returned without being printed at all. The ~% in the format-string is shorthand for carriage return.
<<hello.lisp>>= (format t "Hello World~%")
Download code |