EBoard 07: Cut and compose (Section 2)

Today’s start-of-class procedure

  • Plan to sit with your partner from last class (in the same place).
  • Greet each other.
  • Log in.
  • Bring up the lab.

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

Approximate optimistic overview

  • Administrative stuff [10 min]
  • Some academic integrity issues [5 min]
  • About Wednesday’s quiz [5 min]
  • About reducing redundancy [5 min]
  • About MP3 [15 min]
  • Questions [5 min]
  • Lab [30 min]
  • Turn in lab [5 min]

Administrative stuff

Introductory notes

  • I’m running out of time on Otter.ai, so I’ll only be recording section 1.
  • Please try to avoid putting images and colors in the definitions pane. When you do so, your Racket file ends up saving in a strange format that doesn’t work with Gradescope. Yay computers!
  • I’d also recommend that you do without image-load and image-save in the definitions pane.

Upcoming activities

Scholarly

  • Thursday, 13 February 2025, 11:00 a.m.–Noon, JRC 101. Grinnell Lecture: Darrius Hills on “The Achievement of Identity: Soul Work, Salvation, and Black Manhood in the Religious Imagination of James Baldwin”.
  • Tuesday, 18 February 2025, Noon–12:50 p.m., PDR 224C (White Dining Room). CS Table: ???

Artistic

  • Friday, 7 February 2025, 3:00–5:00 p.m., Burling Digital Studio. Make a Fidget Workshop.
  • Tuesday, 11 February 2025, 4:00–5:00 p.m., Bucksbaum 131 (GCMoA). Gallery Talk with Chen, Kluber, and Tavares.
  • Friday, 14 February 2025, 5:00–6:30 p.m. (talk at 6:00), 926 Broad St (Stewart Arts Building). Opening Reception for Artist Salon: Works by Grinnell College Art Majors

Multicultural

  • Friday, 7 February 2025, 4:00-5:00 p.m., HSSC N1170 (Global Living Room) Middle of Everywhere: How to Order a Coffee in Singapore.

Peer

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

Wellness

  • Friday, 7 February 2025, 5:30–8:00 p.m., Downtown Grinnell. The Sweet Stroll.
  • Tuesday, 11 February 2025, 12:15–12:50 p.m., GCMoA. Yoga in the Museum.
  • Tuesday, 11 February 2025, 4:30–6:30 p.m., BRAC P103 (Multipurpose Dance Studio). Wellness Yoga.

Misc

Other good things

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

  • Saturday, 2025-02-08, 1:00–3:00 p.m., Natatorium. Swimming Last Chance Meet
  • Saturday, 2025-02-08, 1:00–3:00 p.m., Darby. Women’s Basketball vs. Lake Forest
  • Saturday, 2025-02-08, 3:00–5:00 p.m., Darby. Men’s Basketball vs. Lake Forest

Upcoming work

Friday PSA

  • You are awesome.
  • People care about you.
  • Please take care of yourself.
  • Please be moderate.
  • Choose what is right for you.
  • Consent is essential, but insufficient.

Academic Integrity

Example one: A student comment from mini-project 2.

For the pentagon, I did get a little bit of help from the programming assitant chatgpt, I was having trouble with knowing how to incorporate real-part, imag-part, and tying it all together.

  • Thanks for citing.
  • However, Do not use AI programming assistants!
  • Ask a human being. Don’t ask the computer.
  • There are (at least) two kinds of evening help
    • Evening tutors (Sunday through Thursday, 7-10 p.m.): Answer questions individually. (Also Sunday 3-5)
    • Mentor sessions (Sunday 7:30-8:30, Tuesday 7-8): Review sessions.

Example two: Some code from mini-project 2

(build-list sides (lambda (i) (make-point side-length (general-radius sides) (general-theta sides) (+ 2 i))))))
  • Hmmmm … I haven’t taught you build-list. So the student found it on the Interweb. (Hopefully not with ChatGPT.)
  • Let’s see where (of course, they cited it).
  • Nope.
  • Please cite!
  • In general, I’d prefer that you not go far beyond what we’ve learned in class.

Example three: Strange file uploaded

  • Be careful to upload the right file.

About Wednesday’s Quizzes

There are many goals and processes for decomposition. Not only are we breaking a big problem into smaller parts, we are also trying to avoid repeating ourselves.

In many cases, I saw that you did some decomposition well, but left some repeated code. My initial inclination was to mark all of those as “Redo”. After some reflection, I decided that talking about it in class would suffice. If there’s more than one case of repetition, you have a redo. If there’s only one, you have an S.

On to the problem itself …

About reducing redundancy

Sam, how do I reduce redundancy in my compute-pentagon-point procedure?

(define compute-pentagon-point
  (lambda (radius num)
    (pt (real-part (make-polar radius (* 2/5 num pi)))
        (imag-part (make-polar radius (* 2/5 num pi))))))
  • First of all, great job on using the radius, rather than the side length, so that you don’t have to duplicate the conversion of side length to radius!
  • Second, TPS!
(define that-point
  (lambda (radius num)
    (make-polar radius (* 2/5 num pi))))
 
(define compute-pentagon-point
  (lambda (radius num)
    (pt (real-part (that-point radius num)) 
        (imag-part (that-point radius num)))))

Another solution

(define polar->point
  (lambda (polar)
    (pt (real-part polar)
        (imag-part polar))))

(define compute-pentagon-point
  (lambda (radius num)
    (polar->point (make-polar radius (* 2/5 num pi)))))

A solution that I’d prefer you not use (yet).

(define compute-pentagon-point
  (lambda (radius num)
    (define polar (make-polar radius (* 2/5 num pi)))
    (pt (real-part polar)
        (imag-part polar))))

Sam doesn’t like this last version because

  • It uses define within define, which is known to cause weird behavior.
  • It avoids decomposing the procedure into subprocedures. More this.

Lessons:

  • When confronted with repeated code, you may be tempted to put the repeated code in a separate procedure (good temptation), but you should also put the enclosing code in a separate procedure (also a good temptation).
  • Think about the kinds of values you’re working with and how you change them to other kinds of values.
  • Break complicated things into smaller parts. (Aka, decompose)

About Mini-Project Three

Q&A

Administrative

Do I have to tell you when I’m spending a token to turn something in late?

No.

I got an I on MP1. Will you charge me tokens for redoing MP1?

No.

I got an I on MP2. Will you charge me tokens for redoing MP2?

Yes. Tokens are my way of encouraging you to make sure you make an appropriate start on mini-projects.

When do we make up quizzes?

Option 1: During the next quiz day, there will (usually) be make-ups for past quizzes. (They aren’t identical.)

Option 2: On the SoLA (take-home exams).

Can you tell us more about take-home exams?

Yes, when I distribute them. But not today.

Is it okay that I learned things from the Racket Web site and cited them?

Yes.

When redoing a mini-project do I have to start over?

Generally, no. Just fix the parts that we tell you need fixing.

What should documentation look like?

;;; (PROCEDURE PARAMS) -> type?
;;;   PARAM : type?
;;;   PARAM : type?
;;;   PARAM : type?
;;; SHORT DESCRIPTION OF WHAT THE PROCEDURE DOES.
;;; (compute-pentagon-point side num) -> point?
;;;   side : positive-real?
;;;   num : integer? (in the range 1 .. 4)
;;; Compute one point on a pentagon, numbering them clockwise.

If I used one semicolon rather than three, do I need to resubmit.

Nah.

Cool?

Of course. It’s winter in Iowa.

Readings

MP3

Lab

Same partners, new submission