Here are your vocabulary words for today:
The visual patterns are how Lisp should be indented to be human-readable. For instance if can be written either all on one line or on multiple lines.
or(if (= 5 6) (print 'no) (print 'yes))
If works by conditionally executing its second argument if the first argument is true. Otherwise the third argument is executed. When reading Lisp code the second pattern is easier to recognize. Many of the built-in functions have indenting patterns that make it easy to read lisp code.
(if (= 5 6)
(print 'no)
(print 'yes))
Typing out examples is the best way to learn to write and read Lisp code. The book On Lisp by Paul Graham is full of excellent examples for the intermediate Lisp programmer. On Lisp is a good sequel to ANSI Common Lisp. On Lisp is also free to download.
Another route to learning Lisp is to work through the examples in Paradigms of Artificial Intelligence by Peter Norvig. This book is an excellent source of Lisp examples. Norvig's book is good for learning recursion and solving problems with Lisp. Graham's books are good for learning to extend Lisp through higher-order functions and macros.
Working through examples is these books is really the best way to learn Lisp on your own. Just reading the examples or just executing code downloaded from the website does not allow for full comprehension that does typing, running, debugging, and changing the examples.
More about lisp in the next post...
No comments:
Post a Comment