You should be automatically redirected . If not, visit
and update your bookmarks.


The basic rules of LISP

LISP is surprisingly simple. There are only a few things you should know to get started. LISP works with lists of items. Each list is enclosed in parentheses. LISP tries to use the first item of the list as a function or method, unless you tell it not to. Here's some LISP code
(+ 2 2)
LISP sees the first item, the + sign, and tries to apply it to the other items in the list. This works out nicely, and gives the answer 4. The next thing you have to know is how to stop LISP trying to evaluate lists like this. Put a single quote before the list:
'(+ 2 2)
LISP sees the quote and doesn't apply it to the list, so the result is (+ 2 2), which is a list. This use of quotation marks is similar to written English, where we use quotation marks to indicate words and phrases that we don't want interpreted in the usual way. LISP doesn't mind you putting lists inside other lists:
(+ 2 (* 3 2))
The inside list tells LISP to multiply 3 and 2, which simplifies the list to:
(+ 2 6)
and this then evaluates to 8. So LISP is easy!


Post a Comment

Links to this post:

Create a Link

<< Home