C311 Lisp Introduction



C311 Lisp Introduction
C311 Lisp Introduction
Dana Vrajitoru
C311 Programming Languages
Introduction to Lisp
Lisp - A Brief Introduction
Lisp - LISt Processing.
Invented in 1958 by J. McCarthy.
Declarative, functional, interpreted.
Based on the idea of using the same data structure - the list - both for the code and for the data.
A good platform for AI, in particular for natural language processing (NLP) and expert systems.
Traditional output for genetic programming is in Lisp.
Features of Lisp
First language to implement functions as data types, recursion, garbage collection.
First language to be interpreted.
Introduced the idea of building the whole language on itself starting from some basic code.
Introduced the symbolic type and makes the symbolic computation easier.
Forms of Lisp
Dialects: MacLisp(MIT, ~70s), Interlisp (~66, Teitelman), Conversational Lisp (70s), PSL
(Portable Standard Lisp, late 70s), Franz Lisp (Foderaro, 82), Scheme (Sussman, Steele, 75).
Lisp machines: first proposal: Deutsch 73, MIT machines: 74-78 (CONS, CADR), Xerox:
Most popular dialect: Common Lisp, started in 1981, officially released in 84. The ANSI
standard was adopted in 1986.
An object-oriented version: Common Lisp Object System.
Emacs Lisp.
Based on MacLisp and Common Lisp.
The emacs editor was written with Elisp.
Lisp Program
Lisp doesn't make a distinction between expressions and statements.
Everything is an expression in Lisp.
Every expression can be evaluated to a value and can have side effects.
Executing a piece of code means evaluating all of the expressions it contains.
A program is usually a tree of expressions. Expressions can be nested.
1 of 2
1/13/12 4:54 PM
C311 Lisp Introduction
General form: (expr expr expr ...)
Symbolic lists: starting with a simple quote, are interpreted as themselves:
'(monday tuesday wednesday thursday friday saturday sunday)
For any other list, the first symbol is a function to be invoked, or an operand. The remainder of
the list is composed of parameters:
(+ 1 2 3 4)
(min 4 3 2 1)
Any valid expression can be an element of a list.
Empty list: '(). Equivalent to nil/false.
2 of 2
1/13/12 4:54 PM