Tutorial by Examples

What follows is an excerpt from a REPL session with Common Lisp in which a "Hello, World!" function is defined and executed. See the remarks at the bottom of this page for a more thorough description of a REPL. CL-USER> (defun hello () (format t "Hello, World!~%")...
This is a slightly more advanced example that shows a few more features of common lisp. We start with a simple Hello, World! function and demonstrate some interactive development at the REPL. Note that any text from a semicolon, ;, to the rest of the line is a comment. CL-USER> (defun hello () ...
Common Lisp REPL is an interactive environment. Every form written after the prompt is evaluated, and its value is afterwards printed as result of the evaluation. So the simplest possible “Hello, World!” program in Common Lisp is: CL-USER> "Hello, World!" "Hello, World!" CL...
Let’s try some basic expression in the REPL: CL-USER> (+ 1 2 3) 6 CL-USER> (- 3 1 1) 1 CL-USER> (- 3) -3 CL-USER> (+ 5.3 (- 3 2) (* 2 2)) 10.3 CL-USER> (concatenate 'string "Hello, " "World!") "Hello, World!" CL-USER> The basic building ...
(defun sum-list-integers (list) (reduce '+ list)) ; 10 (sum-list-integers '(1 2 3 4)) ; 55 (sum-list-integers '(1 2 3 4 5 6 7 8 9 10))
An anonymous function can be defined without a name through a Lambda Expression. For defining these type of functions, the keyword lambda is used instead of the keyword defun. The following lines are all equivalent and define anonymous functions which output the sum of two numbers: (lambda (x y) (...
Online Books These are books that are freely accessible online. Practical Common Lisp by Peter Seibel is a good introduction to CL for experienced programmers, which tries to highlight from the very beginning what makes CL different to other languages. Common Lisp: A Gentle Introduction to Symb...

Page 1 of 1