The Department of Computer Science & Engineering
 STUART C. SHAPIRO: CSE 202

# CSE202:Programming in Lisp

 Course Grades Email Welcome Policies     Grades     Inc     Intgrty Preface Part I   Chap 1   Chap 2   Chap 3   XEmacs   Chap 4   Chap 5   Chap 6   Chap 7   Chap 8   Chap 9 Part II   Chap 10   Chap 11   Chap 12   Chap 13   Chap 14   Chap 15   Chap 16   Chap 17   Chap 18   Chap 19   Chap 20   Chap 21   Chap 22   Chap 23 Part III   Chap 24   Chap 25   Chap 26   Chap 27   Chap 28   Chap 29   Chap 30   Chap 31   Chap 32 CHAPTER 21: MAPPING FUNCTIONS Corrections Page 153, lines 8 - 16: Change the indentation from ``` (defun scalar-add1 (vector) "VECTOR is a list of numbers. Returns a list just like it, except that each number in it is incremented by 1." (check-type vector list) (typecase vector (null '()) (cons (cons (1+ (first vector)) (scalar-add1 (rest vector)))))) ``` to ``` (defun scalar-add1 (vector) "VECTOR is a list of numbers. Returns a list just like it, except that each number in it is incremented by 1." (check-type vector list) (typecase vector (null '()) (cons (cons (1+ (first vector)) (scalar-add1 (rest vector)))))) ``` Page 154, line -8: Change scalar-add1, then, is to scalar-add1 is. Notes Read Chapter 21. There are three important concepts in this chapter: the function `mapcar`; `lambda` expressions; the concept of closures. Do Exercises 21.1 - 21.4 as you need to in order to understand the material. Do Exercise 21.5, and then compare your definition to the one in Appendix A. Create and submit a file named `ch21.cl` with code in the `ch21` package to define the function `vector-product` as described in Exercise 21.8. As the text says, the product of the column vector ``` (3) (4) ``` represented by the list `(3 4)` times the row vector ``` (5 6 7) ``` represented by the list `(5 6 7)` is the matrix ``` (15 18 21) (20 24 28) ``` represented by the list `((15 18 21) (20 24 28))`. When this is done by Common Lisp it is ```CH21(134): (vector-product '(3 4) '(5 6 7)) ((15 18 21) (20 24 28)) ``` Do not use recursion on any list for this exercise. Instead, you will use `mapcar` twice. If it's too confusing to have two `mapcar`s in one function, write `vector-product` to make use of `scalar-times`. When you have submitted correct exercises through this chapter, you will have earned a grade of B-.