a. Draw a picture of the value of X as a data structure.
What are the values of these expressions when X has value (A B C):
b. (CAR X)
c. (CDR X)
d. (CAR (CDR X))
e. (CDR (CDR X))
f. (CAR (CDR (CDR X)))
g. Define a function SECOND with one parameter X. If X has value (A B C) then (SECOND X) has value B.
The parameter X will be a simple list like X with two or more elements. Ignore possible other kinds of arguments! The function returns the 2nd item in X.
Answer: [ 13a.txt ]
Another warm up -- the Member function (memb x y) is true if and only if x is one of the items in list y.
(memb 'B '(A B C))is T.
(memb 'X '(A B C))is NIL.
Second + the Member function [ class13a.txt ]
Warm Up -- Define a function
From the first programming exercise at the end of the chapter (Page 681)
write LISP function which has the radius of a sphere as a parameter
and returns the volume of the sphere.
[ class13c.txt ] [ class13b.txt ]
We will now do some of the simpler Scheme programming exercises from the end of chapter 15 (pages 681...) starting with problem 4. We will code them for our own XLISP and debug them remotely using the PC as a terminal.
Note. Question 1 is too easy, and questions 2 and 3 are like an example in the handout!
Question 4 Attempt: [ 13zero.lsp ]
You must make your own version of one XLISP functions done in class or in the book that uses conditionals and cars and cdrs and recursion to do something to a list. Link it to your CS302 web site. You should have a page with comments on what you have learned about LISP with the function as an example.