Functional Problem Solving (CSC 151 2014F) : EBoards

CSC151.01 2014F, Class 21: Naming Local Values


Overview

Preliminaries

Admin

Upcoming Work

Extra Credit Opportunities

Academic

Peer Support

Quiz

Here are the problems, just in case you want to look at them later.

Q1.

> (map ___ (iota 12))
(1 1/2 1/3 1/4 1/5 1 1/2 1/3 1/4 1/5 1 1/2)

Q2.

(define image-stuff!
  (lambda (image x y)
    (context-set-fgcolor! "black")
    (if (< x (* 1/2 (image-width image)))
        (if (< y (* 1/2 (image-height image)))
            (image-select-rectangle! image REPLACE x y 10 10)
            (image-select-rectangle! image REPLACE x y 10 20))
        (if (< y (* 1/2 (image-height image)))
            (image-select-rectangle! image REPLACE x y 20 10)
            (image-select-rectangle! image REPLACE x y 20 20)))
    (image-fill! image)
    (image-select-nothing! image)))

Lab

Why would anyone ever redefine rgb-redder in this idiotic way?

They wouldn't. However, you will find that there are times that people accidentally redefine a procedure that you are counting on and that breaks your procedure. This exercise is intended to help you think about how you might ameliorate such issues.

No, you don't generally have to code this way. The point is that you can code this way.

Sam also has the "who will sue me because my code doesn't do what I claim" voice in the back of his head.

Can you tell us what's going on in problems 5 and 6?

Yes, but not until Monday, after you think about it a bit.