Functional Problem Solving (CSC 151 2016S) : EBoards
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] - [FAQ] [Teaching & Learning] [Grading] [Taking Notes] [Rubric]
Current: [Assignment] [EBoard] [Lab] [Outline] [Reading]
Sections: [Assignments] [EBoards] [Labs] [Outlines] [Readings] - [Examples] [Handouts]
Reference: [Setup] [Remote] [VM] [Errors] - [Functions A-Z] [Functions By Topic] - [Racket] [Scheme Report (R5RS)] [R6RS] [TSPL4]
Related Courses: [Curtsinger (2016S)] [Davis (2013F)] [Rebelsky (2015F)] [Weinman (2014F)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] - [Issue Tracker (Course)]
Overview
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.
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
let)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)))])
...)
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
mod once, either by using a let or by
using it in another expression.(define directory "/home/student/Desktop/CSC151/")</li>
<li>(image-load (string-append directory "2sam.jpg"))Improved code
(define choose-image
(lambda (num)
(image-load (string-append
"/home/student/Desktop/CSC151/"
(number->string (+ 1 (mod num 53)))
".jpg"))))
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))
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.
With your partner, come up with three or so issues for each category. I've started with an example or two of each.
definelambdaWhere do you go from here?