Common Lisp John Paxton Montana State University Summer
- Slides: 26
Common Lisp! John Paxton Montana State University Summer 2003
Textbook Lisp, 3 rd Edition Winston, Horn Addison-Wesley 1989
Where is Montana?
Where is Bozeman?
Why Lisp? • • Interpreted environment Editing and debugging tools Built on many years of experience Code and data have same form • Lisp = List Processing
Lisp Myths • • • It’s slow Programs are large Requires expensive computers Hard to read Hard to learn
Terminology • atom, e. g. 1 • list, e. g. ‘(1 2 3) • s-expression
Comment ; ; Line comments start with two semicolons.
first > (first '(1 2 3)) 1 • second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth
rest > (rest '(1 2 3)) (2 3) > (rest 'apple) *** - REST: APPLE is not a list
setf > (setf location 'san-salvador) SAN-SALVADOR > location SAN-SALVADOR
cons > (cons 1 '(2 3)) (1 2 3) > (cons '(1) '(2 3)) ((1) 2 3)
append > (append '(1) '(2 3)) (1 2 3) > (append 1 '(2 3)) *** - APPEND: 1 is not a list (append '(1) 2) (1. 2)
list > (list 1) (1) > (list 1 2 3 4) (1 2 3 4)
length > (length 'apple) *** - LENGTH: APPLE is not a sequence > (length '(1 2 3 4)) 4
reverse > (reverse '(1 2 3)) (3 2 1) > (reverse '((1 2) 3)) (3 (1 2))
assoc > (assoc 'mister '((miss senorita) (mister senor))) (MISTER SENOR)
nthcdr (nthcdr 0 '(1 2 3)) (1 2 3) > (nthcdr 1 '(1 2 3)) (2 3) > (nthcdr 4 '(1 2 3)) NIL
butlast > (butlast '(1 2 3) 0) (1 2 3) > (butlast '(1 2 3) 1) (1 2) > (butlast '(1 2 3) 4) NIL
last > (last '(1 2 3)) (3)
Mathematical Operators • • + * / > (+ 2 (* 3 4)) 14
Mathematical Functions • • round float max min expt sqrt abs
Questions 1. 2. 3. 4. 5. 6. How do you invoke CLISP? How do you exit CLISP? What happens when you enter 5? What happens when you enter ‘vertigo? What happens when you enter ‘(vertigo notorious).
Questions 7. What happens when you enter (vertigo notorious) ? 8. Give the variable movies the value ‘(vertigo notorious). 9. Access the first element of movies. 10. Access all of the elements of movies except for the first element. 11. What is t? What is nil?
Questions 12. Add spellbound to the front of movies. 13. Add spellbound to the end of movies. 14. Use list, append, and cons to build the list ‘(plantain guava). 15. Determine how many items are in movies. 16. Change movies so that the movies are listed in reverse order.
Questions 17. Calculate the sum of 2 plus 3. 18. Calculate the sum of 2 plus 3 plus 4. 19. Write an expression that uses the quadratic formula to calculate one of the roots of x 2 + x – 6 = 0. 20. What happens when you make an error? 21. How do you recover from an error?
- Avery paxton
- Taylor paxton
- Donna paxton
- Montana state uit
- Common lisp assoc
- Auto lisp
- Lisp car
- Common lisp: a gentle introduction to symbolic computation
- Allegro write program
- Positive list scheme
- University of montana cyberbear
- University of montana mph
- Montana state fish
- Distortion
- Montanas state flag
- Amy jenks state of montana
- Uit montana state
- State of montana emacs
- Lisp cond
- Cond in lisp
- Scheme implementation
- Lisp and prolog
- Lisp polish notation
- Lisp talude
- Lisp cisco
- Scheme append to list
- Cons in lisp