[Skip Navigation] [CSUSB] / [CNS] / [CSE] / [R J Botting] /[CS320 Course Materials] /13q.html [13q.txt(Text)] [Search ]
Tue May 14 16:01:22 PDT 2013
[Schedule] [Syllabi] [Text] [Labs] [Projects] [Resources] [Grading] [Contact]
Notes: [01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20]

Contents


    CS320/13 Questions on Functional Programming in LISP

      Warm up questions - (too easy for the final!)

      Suppose that X is a variable with the simple linked-list value (A B C).

      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 ]

      Warm Up -- Define a function

      From the first programming exercise at the end of the chapter (Page 724) write LISP function which has the radius of a sphere as a parameter and returns the volume of the sphere.

      [ class13c.txt ] [ class13b.txt ]

      Questions

      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 ]

      Laboratory LISP 103

      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.

    Review

( End of document ) <<Contents | Top