Material to Understand
- The definition of an atom. Example: 1
- The definition of a list. Example: '(1 2 3)
- The definition of an s-expression: an atom or a list.
- The function first. Example: (first '(1 2 3))
- The functions second, third, ... , tenth.
- The function rest. Example: (rest '(1 2 3))
- The function '. Example: '(1 2 3) or (quote (1 2 3))
- The function setf. Example: (setf a 10)
- The function cons. Example: (cons 1 '(2 3))
- The function append. Example: (append '(1 2) '(3 4))
- The function list. Example: (list 1 2 3)
- The function length. Example: (length '(1 2 3))
- The function reverse. Example: (reverse '(1 2 3))
- The function assoc. Example: (assoc 5 '((1 2)(5 3)(3 4))
- The function nthcdr. Example: (nthcdr 2 '(1 2 3 4))
- The function butlast. Example: (butlast '(1 2 3 4) 2)
- The function last. Example: (last '(1 2 3))
- Mathematical operators: +, -, *, /. Example: (/ 6 2)
- Mathematical functions: round, float, max,
min, expt, sqrt, abs.
Exercises
Exercises do not need to be submitted and will not be graded.
The purpose of the exercises is for you to be able to check you
comprehension of the ability.
- How do you invoke CLISP on our system?
- How do you exit CLISP?
- What happens when you type in 5? Why?
- What happens when you type in 'notorious? Why?
- What happens when you type in notorious? Why?
- What happens when you type '(notorious vertigo)? Why?
Bonus: What do these movies have in common?
- What happens when you type (notorious vertigo)? Why?
- Give the variable movies the value '(notorious vertigo psycho).
- How can you access the first element of movies?
- How can you access the second element of movies?
- How can you access everything but the first element of movies?
- What is t? What is nil?
- How can you add spellbound to the front of movies?
- How can you add spellbound to the end of movies?
- Use the function list to build the list '(1 2 3).
- Use the function cons to build the list '(1 2 3).
- Use the function append to build the list '(1 2 3).
- Is cons or append more efficient? Explain.
- Use a lisp function that determines how many top-level items
are in the variable movies.
- Print out the top-level items in the variable movies
in reverse without changing the value of the variable.
- Calculate the sum of 2 plus 3.
- Calculate the sum of 2 plus 3 plus 4 (as simply as possible).
- Write an expression that uses the quadratic formula to
calculate one of the roots of x^2 + x - 6 = 0.
- What happens if you make an error in the CLISP interpreter?
- How do you recover from an error in the CLISP interpreter?