Functional Problem Solving (CSC 151 2016S) : EBoards

CSC151.02 2016S, Class 55: Recap


Overview

Preliminaries

Admin

Reminders

Upcoming Work:

Extra Credit

Academic / Artistic

Peer

Regular Peer

Misc

Questions

What's up with the final?

It replaces your lowest exam grade, provided it is higher than your lowest exam grade.

When is the final?

Thursday morning. You can take the other section's on Wednesday afternoon. Here.

Is there a review session for the final exam?

See above.

A few notes on project code

Example 1

Original code

(let ([petal-color
       (cond
         [(= (modulo n 10) 0)
          (color-name->irgb "blue")]
         [(= (modulo n 10) 1)
          (color-name->irgb "fuchsia")]
         [(= (modulo n 10) 2)
          (color-name->irgb "navy")]
         [(= (modulo n 10) 3)
          (color-name->irgb "red")]
         [(= (modulo n 10) 4)
          (color-name->irgb "indianred")]
         [(= (modulo n 10) 5)
          (color-name->irgb "lime")]
         [(= (modulo n 10) 6)
          (color-name->irgb "violet")]
         [(= (modulo n 10) 7)
         (color-name->irgb "orange")]
         [(= (modulo n 10) 8)
          (color-name->irgb "orchid")]
         [(= (modulo n 10) 9)
          (color-name->irgb "steelblue")])])
  ...)

Problems

Revised code

(let ([petal-color
       (color-name->irgb (vector-ref (vector "blue" "fuchsia" "navy" "red"
                                             "indianred" "lime" "violet"
                                             "orange" "orchid" "steelblue")
                                     (modulo n 10)))])
  ...)

More revised code

(let* ([petal-colors (vector "blue" "fuchsia" "navy" "red" "indianred" 
                             "lime" "violet" "orange" "orchid" "steelblue")]
       [num-colors (vector-length petal-colors)]
       [petal-color 
        (color-name->irgb (vector-ref petal-colors (modulo n num-colors)))])
  ...)

Example 2

Original code

(define choose-image
  (lambda (num)
    (cond
      [(= 0 (mod num 53))
       (image-load "/home/student/Desktop/CSC151/1charlie.jpeg")]
      [(= 1 (mod num 53))
       (image-load "/home/student/Desktop/CSC151/2sam.jpeg")]
      [(= 2 (mod num 53))
       (image-load "/home/student/Desktop/CSC151/3ritika.jpeg")]
      [(= 3 (mod num 53))
       (image-load "/home/student/Desktop/CSC151/4jessica.jpeg")]
      ...)))

Problems

Fixing

Improved code

(define choose-image
  (lambda (num)
    (image-load (string-append
                 "/home/student/Desktop/CSC151/"
                 (number->string (+ 1 (mod num 53)))
                 ".jpg"))))

Example 3

Original code

(pred (irgb (- 31 (* 31 (/ col left)))
            (- 95 (* 95 (/ col left)))
            (- 167 (* 167 (/ col left)))) 
      (irgb (* 31 (/ (- col left) right))
            (* 95 (/ (- col left) right))
            (* 167 (/ (- col left) right))) 
      (irgb (* 31 (/ (abs (- row top)) top))
            (* 95 (/ (abs (- row top)) top))
            (* 167 (/ (abs (- row top)) top))) 
      (irgb (* 31 (/ (abs (- row top)) top))
            (* 95 (/ (abs (- row top)) top))
            (* 167 (/ (abs (- row top)) top))))

Revised code

(let* ([rval 31]
       [gval 95]
       [bval 95]
       [mult1 (/ col left)]
       [mult2 (/ (- col left) right)]
       [mult3 (/ (abs (- row top)) top)]
       [color1 (irgb (- rval (* rval mult1))
                     (- gval (* gval mult1))
                     (- bval (* bval mult1)))]
       [color2 (irgb (* 31 mult2)
                     (* 95 mult2)
                     (* 167 mult2))]
       [color3 (irgb (* 31 mult3)
                     (* 95 mult3)
                     (* 167 mult3))])
  (pred color1 color2 color3 color3))

The subject matter(s) of the course

I consider it important to end the semester with an overview of the primary learning goals and outcomes of the course, which we often call "the subject matter of the course." I think of CSC 151 as having a broad range of subject matters. Here's the high-level overview.

Additional details

With your partner, come up with three or so issues for each category. I've started with an example or two of each.

Problem Solving

Computer Science: Algorithms and Data Structures

Scheme

Program and Software Design

General Thinking Skills

And Beyond

Other issues

Looking Beyond the Course

Where do you go from here?