Lisp

Patrick Henry Winston, Berthold Horn

Mentioned 3

This third edition is a revised and expanded version of Winston and Horn's best-selling introduction to the Lisp programming language and to Lisp-based applications, many of which are possible as a result of advances in Artificial Intelligence technology. The Knowledge You Need The new edition retains the broad coverage of previous editions that has made this book popular both with beginners and with more advanced readers -- coverage ranging from the basics of the language to detailed examples showing Lisp in practice. Based on the CommonLisp standard, this book also introduces CommonLisp's object system, CLOS, and the productivity-promoting techniques enabled by object-oriented programming. Application examples drawn from expert systems, natural language interfaces, and symbolic mathematics are featured, and new applications dealing with probability bounds, project simulation, and visual object recognition are introduced. Special Features of this Edition Based on extensive teaching experience Explains key problem solving paradigms, such as search, forward chaining, and problem reduction Discusses constraint propagation, backward chaining, and key ideas in Prolog Emphasizes procedure and data abstraction, and other points of programming style and practice Covers cliches, mapping, streams, delayed evaluation, and techniques for better and faster procedure definition 0201083191B04062001

More on Amazon.com

Mentioned in questions and answers.

What is a good book or tutorial to learn Lisp?

Lisp (3rd Ed) by Winston and Horn is actually a pretty good textbook. I picked it up for a steal (plenty of $2 used copies on Amazon) and I've found it to be a decent learning tool. it is sometimes easier to read than ANSI Common Lisp by Paul Graham, although some of the advanced stuff is a bit weird or out-of-date.

I'm now studying Emacs Lisp from the reference manual and Common Lisp from a LISP Book.

from the Common Lisp book

>> (setf power-of-two
     (let ((previous-power-of-two 1))
       #'(lambda ()
           (setf previous-power-of-two
             (* previous-power-of-two 2)))))

>> (funcall power-of-two)
2

>> (funcall power-of-two)
4

>> (funcall power-of-two)
8

The function won't work in Emacs Lisp because of its dynamic binding behavior.

I wonder if it is possible to implement the same function in Emacs Lisp without introducing a global variable ?

Update:

By now, Emacs 24 has been officially released, and it supports lexical binding without using lexical-let, when the buffer-local variable lexical-binding is non-nil. See also M-: (info "(elisp) using lexical binding") and pokita's answer.


You can use lexical-let from the Common Lisp Extensions (the "CL package"):

elisp> (require 'cl)
cl
elisp> (setf power-of-two
             (lexical-let ((previous-power-of-two 1))
               #'(lambda ()
                   (setf previous-power-of-two
                         (* previous-power-of-two 2)))))
(lambda
  (&rest --cl-rest--)
  (apply
   (lambda
     (G175638)
     (set G175638
          (*
           (symbol-value G175638)
           2)))
   '--previous-power-of-two-- --cl-rest--))

elisp> (funcall power-of-two)
2
elisp> (funcall power-of-two)
4
elisp> (funcall power-of-two)
8

I've also heard about a lexbind branch of GNU Emacs.

This semester at college I have a course for Artificial Intelligence and we are studying Lisp. The problem is that I don't have any functional programming background, but I do know OOP programming (Java, Javascript, PHP).

Can you recommend some good books to get me up to speed on Lisp and artificial intelligence?