- CS320/13 Questions on Functional Programming in LISP
- : Warm up questions - (too easy for the final!)
- : Warm Up -- Define a function
- : Questions
- : Laboratory LISP 103
- Review

a. Draw an accurate 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 ]

[ class13c.txt ] [ class13b.txt ]

We will now do some of the simpler Scheme programming exercises from the end of chapter 15 (pages 724...) 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 -- power using multiplication only [ 13pow.lsp ]

Question 5 Attempt: [ 13zero.lsp ]

Question 6 -- max and min [ 13maxmin.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 CS320 web site. You should have a page with comments on what you have learned about LISP with the function as an example.