EBoard 26: Vectors, continued (Section 3)

Warning! You are being recorded and transcribed, provided the technology is working correctly.

Approximate optimistic overview

  • Administrative stuff
  • Quick notes on pairs and pair structures
  • Q&A
  • Quick notes on vectors (maybe)
  • Lab

Administrative stuff

Introductory notes

  • Quizzes returned (I hope). One was unidentified.
  • I sent out grade reports yesterday. Let me know if you have questions or concerns.
  • For those who need yet another redo for MP1, MP2, or MP3, I’ve set final redos due at the end of the semester.
  • I know that you have not yet received MP4 and MP5 redos back. Nonetheless, I’ve set redos for Sunday, April 20.
  • There are whiteboards and markers placed neatly next to your workstation. Please replace them at the end of class.

Upcoming activities

Scholarly

  • Thursday, 10 April 2025, 11am–noon, HSSC A1231. Scholars’ Convocation: Jen Shook: Instead of RedFace: Relational Trails in “Indian Country,” Onstage, Online, and IRL
  • Thursday, 10 April 2025, 4:00–5:30pm, the Kernel (HSSC Multipurpose Room). CS Poster Session
  • Tuesday, 15 April 2025, noon–1pm, Some PDR. CS Table: ???

Artistic

Multicultural

  • Friday, 11 April 2025, 4:00–5:00 p.m., HSSC N1170 (Global Living Room). Middle of Everywhere:???

Artistic / Multicultural

  • Thursday, 10 April 2025, 7:00–9:00 p.m., HSSC A2231. Superfest Disability Film Festival: Opening
  • Saturday, 12 April 2025, 10:30–11:30 a.m., Drake Library. Superfest Disability Film Festival: Family-Friendly Shorts
  • Saturday, 12 April 2025, 10:00 a.m.–noon, HSSC A2231. Superfest Disability Film Festival: Feature Film
  • Saturday, 12 April 2025, 1:30 p.m.–3:45 p.m., HSSC A2231. Superfest Disability Film Festival: Chronic Pain Shorts
  • Sunday, 12 April 2025, 10:00 a.m.–noon, HSSC A2231. Superfest Disability Film Festival: Feature Film
  • Sunday, 12 April 2025, 1:30 p.m.–3:45 p.m., HSSC A2231. Superfest Disability Film Festival: Assorted Shorts and Panel

Peer

Musical, theatric, sporting, and academic events involving this section’s students are welcome.

  • Read articles by your fellow CSC-151 students and comment on them online.
  • Rumors the play this coming weekend.
    • If you want to go, Sam will pay.

Wellness

  • Tuesday, 8 April 2025, 12:15–12:50 p.m., GCMoA. Yoga in the Museum.
  • Tuesday, 8 April 2025, 4:30–6:30 p.m., BRAC P103 (Multipurpose Dance Studio). Wellness Yoga.
  • Thursday, 10 April 2025. ???. ???. Forest Bathing.
  • Friday, 11 April 2025, 6:00 p.m.–8:00 p.m., Aux Gym. Badminton Club (Smash that bird!)
  • Friday, 11 April 2025, 9:00 p.m., Noyce Elbow. Nerf at Noyce.
  • Saturday, 12 April 2025, 4:00 p.m.–6:00 p.m., Aux Gym. Badminton Club (Smash that bird!)
  • Tuesday, 15 April 2025, 5:00–6:00 p.m., HSSC Atrium. Therapy Dogs.
  • Tuesday, 15 April 2025, 7:15–8:15 p.m., HSSC Atrium. Therapy Dogs.

Misc

  • Tuesday, 8 April 2025, 7:00–8:00 p.m., Science 3820. Mentor Session
  • Wednesday, 9 April 2025, Noon–1:00 p.m., HSSC A2231 (Auditorium) Community Forum
    • “Weekly discussion on legal protections and recourse on issues that higher education and Grinnell College face.”
    • Also online.
    • This week: Karen Edwards on Immigration Regulations.
  • Sunday, 13 April 2025, 7:30–8:30 p.m., Science 3819. Mentor Session

Other good things

These do not earn tokens, but are worth your consideration.

  • Track and Field Home Meet this weekend.

Upcoming work

Pairs and pair structures

The mentors asked me to give you a quick summary.

Some basic principles.

  • Any time you have a cons, draw a cons cell (pair).
    • Each box in the cons cell can hold ONE thing (a null or an arrow)
  • Any time you have a list of length n, draw n cons cells in sequence, with a null at the end. Draw downward arrows to each value. in the list (except for nulls).
  • For any explict nulls, draw a slash.

Example,

  • '((a b ()) c (d e) () ((f)))
  • I might this more like (list (list 'a 'b null) (cons 'c 'd) ...). (Not the same expression)

Questions

Questions

Administrative

Will we have another chance after the final redo for a mini project?

Nope. Original. First redo. Second redo. Ultimate redo.

Will we have a redo for MP9?

Nope. It’s all or nothing. But it has a very clear rubric which focuses primarily on “do this minimal stuff in this amount of time”.

It’s also a (self-formed) group project.

Mini-project 7

In mini-project 6, we needed to use local bindings to avoid identical recursion, which makes things VERY slow. Do we have the same issue on mini-project 7. If so, can you give an example?

I don’t believe so. We’ll mostly use direct recursion here.

How should we implement enhance-color?

For each position, find the neighboring pixels (including the pixel at that position), find their average, call (enhance-color pixel average).

Vectors

Other

Vectors

;;; (vector-increment-odd! vec) -> void
;;;   vec : (vector-of exact-integer?)
;;; Add two to all the odd numbers in the vector.
;;;
;;; E.g.,
;;;   > (define vec (vector 1 2 3 4 5))
;;;   > (vector-increment-odd! vec)
;;;   > vec
;;;   > #(3 2 5 4 7)
(define vector-increment-odd!
  (lambda (vec)
    (vector-increment-odd-helper! vec 0)))
  • Because vectors are mutable, we can actually write this procedure. For lists, we’d need to return a new list. (vector-set! vec index elt).
  • When we write procedures that try to manipulate some or all of the values in a vector, we will need a helper procedure that keeps track of the current index.
    • We’ll count from 0 to length in our version.
  • When we’re using vector-set!, we don’t usually sequence by nesting, since vector-set! returns void (nothing).

We’re writing a recursive helper.

  • Base case: Check if the index is equal to the length of the vector.
  • Base value: Nothing. It’s ! procedure, so our default is to return nothing.
  • Recursive call (and what do we change for the recursive call): (vector-increment-odd-helper! vec (+ index))
  • Pre-processing / Post-processing: Check to see if “it” is odd. If so, add two. (“It” is the next element: (vector-ref vec index).
  • Recursive case (inverse of the base case); when should we continue? (< index (vector-length vec)).
(define vector-increment-odd!
  (lambda (vec)
    (vector-increment-odd-helper! vec 0)))
;;; Add TWO to all the odd numbers in the vector that appear at or
;;; after the given index.
(define vector-increment-odd-helper! 
  (lambda (vec index)
    (cond
      [(< index (vector-length vec))
       (if (odd? (vector-ref vec index))
           (vector-set! vec index (+ 2 (vector-ref vec index) ))
           "nothing")
       (vector-increment-odd-helper! vec (+ index))])))

Fixed

(define vector-increment-odd-helper!
  (lambda (vec index)
    (cond
      [(< index (vector-length vec))
       (when (odd? (vector-ref vec index))
         (vector-set! vec index (+ 2 (vector-ref vec index) )))
       (vector-increment-odd-helper! vec (+ index 1))])))

Lab

Today’s lab is Vectors, continued.