EBoard 26: Vectors, continued (Section 2)

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.
  • Women’s Tennis Sunday

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)))

Questions

How do we represent the empty list?

A slash.

Do we draw an arrow to the f?

Yes. We draw arrows to everything that’s not null.

What is ((f))?

A single-element list containing a single-element list that contains f.

Are all lists made of pairs?

No. The empty list is not made of pairs.

Will we have pair structures that aren’t lists on the quiz?

Probably.

(a . b) looks like one pair with an arrow to a from the left cell and an arrow to b from the right cell.

Note that I will probably write that more explicitly as (cons 'a 'b).

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.

When will tokens be tallied?

Before the end of the semester.

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).

How do we add variables within a procedure?

Generally, using let. Put the let at the appropriate place.

You can ask me.

Vectors

Other

Vectors

;;; (vector-increment-odd! vec) -> void
;;;   vec : (vector-of exact-integer?)
;;; Add one to all the odd numbers in the vector.
;;;
;;; E.g.,
;;;   > (define vec (vector 1 2 3 4 5))
;;;   > (vector-increment-odd! vec)
;;;   > vec
;;;   > #(2 2 4 4 6)
(define vector-increment-odd!
  (lambda (vec)
    (vector-increment-odd-helper! vec 0)))

What do you remember about writing recursive procedures over vectorss?

  • You could turn the vector into a list and do recursion. Sam emphatically discourages that.
  • We probably need a helper to keep track of the index.
  • (Our change will have to be to elements; we can’t make it longer or shorter.)
  • We sequence differently when using vector-set!. Instead of nesting, we write operations one after the other.

How should we write vector-increment-odd-helper!.

  • Base case test: If index = length of vector (Sam prefers >= for safety)
  • Base case value: Stop. Maybe return the vector. Return NOTHING (void)
  • Recursive call: (vector-increment-odd-helper! vec (+ 1 index))
  • Pre-processing/post-processing: We have to a vector-set (inside a conditional)
  • Recursive case test (Alternate to base case test): When do we continue? (< index length-of-vector).
;;; Increment all the odd values in the vector starting at the given index.
(define vector-increment-odd-helper!
  (lambda (vec index)
    (cond
      [(< index (vector-length vector))
       (vector-set! vec index (+ 1 (vector-ref vec index)))
       (vector-increment-odd-helper! vec (+ 1 index))])))

Finalized

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

Lab

Today’s lab is Vectors, continued.