EBoard 10: Strings (Section 1)

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

We are back to the standard start-of-class procedure.

Approximate optimistic overview

  • Quiz [15 min]
  • Administrative stuff [10 min]
  • About the SoLA [5 min]
  • Questions [5 min]
  • Lab [40 min]
  • Turn in lab [5 min]

Administrative stuff

Introductory notes

  • Happy Valentine’s Day! (Or Galentine’s Day or whatever you choose to celebrate.)
  • I hope you enjoyed your snow day.
  • I hope you stay safe and warm over the next few days.
  • Beware! The flu is going around campus.
  • Note that your odds of me answering questions go down significantly at about 8pm. Don’t forget that you can use the evening tutors (which does require you to work in Noyce).

Upcoming activities

Scholarly

Artistic

  • 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, 14 February 2025, 4:00–5:00 p.m., HSSC N1170 (Global Living Room). Middle of Everywhere: Japan and Bento Boxes
  • Friday, 14 February 2025, 6:30–9:00 p.m., Harris Center. Chinese New Year & Lantern Festival

Peer

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

  • Friday, 14 February 2025, 4:00 p.m.–?. Field House. Darren Young Classic.
  • Saturday, 15 February 2025, 10:00 a.m.–?. Field House. Darren Young Classic, Continued.

Wellness

  • Tuesday, 18 February 2025, 12:15–12:50 p.m., GCMoA. Yoga in the Museum.
  • Tuesday, 18 February 2025, 5:00–6:00 p.m., HSSC S1003 (Atrium). Therapy Dogs.
  • Tuesday, 18 February 2025, 4:30–6:30 p.m., BRAC P103 (Multipurpose Dance Studio). Wellness Yoga.
  • Tuesday, 18 February 2025, 7:15–8:15 p.m., HSSC S1003 (Atrium). Therapy Dogs.

Misc

Other good things

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

  • Monday, 17 February 2025, 8:00–10:00 p.m., Bob’s Underground. Open Mic Night.

Upcoming work

Abbreviated Friday PSA

  • You are awesome people.
  • Others care about you. Perhaps even me.
  • Please take care of yourself.
  • Moderation!
  • Consent is necessary (but insufficient).

SoLA 1

  • Model: Five or Six Learning Assessments
    • Since tracing is “paper only”, there will be five on SoLA 1
  • Somewhat like a take-home exam.
  • Online, rather than on paper.
  • Each should be similar difficulty to the quizzes you’ve been taking.
    • They are nonetheless capped at one hour each.
    • You can spread them out or do them all at once.
    • If you find yourself spending much more than 15 minutes on an LA, it’s probably a sign that you don’t understand the topic well enough and should stop.
  • Topics: See the list of learning objectives.
  • If you already have credit for a topic, such as decomposition, do not do the LA on the SoLA.
  • The sample LA will not be graded.

Q&A

Administrative

Do I have to enter something to get a token for a mentor session?

Yes, mentor sessions require the same reflective paragraph as any other token events.

How do I tell how many tokens I have?

When I get the paperwork up to date, I’ll let you know.

Can you explain how I submit a redo?

Update your program to address the concerns raised in the first submission.

Submit it to make sure it passes all the tests (or as many tests as you’re satisfied passing). If it doesn’t pass tests at first, keep fixing and resubmitting until you’ve achieved a desired level. (Feel free to ask questions along the way.)

Once you’ve reached that level, submit both your updated .rkt file and a CHANGES.txt file that summarizes the changes you’ve made.

Readings

I don’t think we have covered using symbols much in this class yet, is there an example of how it can be used in a procedure?

We will and up using symbols either (a) with existing procedures that use symbols, or (b) when we want to compare them to each other.

Could you elaborate on using symbols “to provide a mnemonic value to a procedure”?

We’ve been using strings for most of our mnemonic values, but here’s one. (solid-square 25 'blue).

How can you turn a string that has “non-numerical” characters & numerical characters into a list of just the numbers. (e.g., ("200/100/30") -> '(200 100 30))

Isn’t that part of MP3?

You could use string-split to break the string apart. You can use string->number to convert each part.

> (string-split "200/100/30" "/")
'("200" "100" "30")
> (map string->number  (string-split "200/100/30" "/"))
'(200 100 30)

What is the difference between 'a, "a", and a?

'a is a symbol. Its primary purpose is for comparing to other symbols.

"a" is a string. We can compare it to other strings. We can also find its length, extract substrings, append it to other strings, etc.

a is an identifier. It names something. (Or doesn’t, if you haven’t used it with define.)

MP3

Could we go over rgb-cyclic-subtract?

Sure.

remainder will be your friend.

For positive numbers, (remainder (+ val 256) 256) is the same as (remainder val 256).

Could we go over gamma-correct-component?

Sure.

Basic idea: Gamma correction makes images lighter or darker in a “sensible” way.

Each component of an RGB color is between 0 and 255.

We want to convert them to a number in the range 0-1. (Divide by 255.)

We then take that number and compute (expt num gamma). If gamma is 1/2, we take the square root of num, if gamma is 2, we square num.

The result is also between 0 and 1.

Convert it back to an a number between 0 and 255. Multiply by 255 (and then round).

Exponents below 1 will make it lighter and exponents above 1 will make it darker.

When should you use cut vs. composition?

You generally use cut when you’re calling another procedure and filling in some of the parameters, but not all of them.

(define blue-square (lambda (size) (solid-square size 'blue)))

(define blue-square (cut (solid-square <> 'blue)))

If you’re calling multiple one-parameter procedures in sequence, you will often want to use composition.

(pixel-map (lambda (color) (hsv->rgb (hsv-transformation (rgb->hsv color)))) (image-load "kitten.jpg"))

(pixel-map (o hsv->rgb hsv-transformation rgb->hsv) (image-load "kitten.jpg"))

Why can’t I use (max 1 (cut (- <> 1)))?

Because max needs numbers, not procedures.

Let’s break down your steps. First you want to subtract 1. (cut (- <> 1)). Then you want to take the max of 1 and that result. (cut (max 1 <>)). We have two procedures that you want to do in sequence, so we’ll use composition.

(o (cut (max 1 <>)) (cut (- <> 1)))

Lab