EBoard 14: Lists, continued (Section 2)

Please follow the standard start-of-class routine.

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

Approximate overview

  • Administrative stuff
  • Some notes on MP redos
  • Some notes on Monday’s lab
  • Q&A
  • Lab

Administrative stuff

Introductory Notes

  • Note that Scamper is now at 4.7.0! Please reload before starting the lab.
  • When the readings rely on Scamper updates, they may sometimes show errors for unknown reasons. Try Shift-Reload.
  • Today is another “Continue the lab next class” day.
  • Please make use of the evening tutors. If you make use of an evening tutor, I’d appreciate it if you’d drop me a note with their name and how the meeting went.
  • Some of you were asking the evening tutors for clarification on part 3 of MP2. You should really ask such questions earlier than the night a project is due.
  • Time on readings continues to vary significantly. Here are the results from the first 25 submissions on the latest reading. 15min, 20min, ~20min, 30min, 30min, 30min, 30min, 30min, 30min, ~30min, ~30min, ~30min, 35min, 40min, ~40min, 42min, 45min, 45–60min, 1hr, 1hr, 1hr, 1.25hrs, 1.5hrs, 1.5hrs, 2hrs

Upcoming activities

Scholarly

  • Wednesday, 30 September 2026, 8:00–9:30 p.m., HSSC A2231. Reading as a Way of Life
  • Thursday, 1 October 2026, 11:00 a.m.–Noon, JRC 101. Scholars’ Convocation: Christian Flemm: Medium Intimacy
  • Thursday, 1 October 2026, 4:15 p.m., HSSC S3325. John Aerni-Flessner ’01: “White Gold and Thirsty Communities: The Cold War, Apartheid, and the Lesotho Highlands Water Project. New
  • Friday, 2 October 2026, 4:15–4:45 p.m., HSSC A1231 (the Kernel). Cory McCarten ‘19: What Math and Data Can (and Cannot) Tell us about Gerymandering and Voting Rights
  • Friday, 2 October 2026, 5:30–7:30 p.m., Weingart Pavilion. Pioneer Weekend Kickoff
  • Monday, 5 October 2026, 4:15–5:15 p.m., HSSC 1325. AI and the Future of Democracy New (Highest Recommendation)
  • Tuesday, 6 October 2026, Noon–1:00 p.m., JRC 224C (I think). CS Table: ???
  • Thursday, 8 October 2026, 11:00 a.m.–noon, JRC 101. Scholars’ Convocation: Alan Schrift: From the Origins of the Grinnell College Center for the Humanities to the Past and Current Crises of the Humanities New

Artistic/Cultural

  • Any day. Visit the GCMOA for at least 30 minutes.
  • Thursday, 1 October 2026, 4:00–5:30 p.m., HSSC S1325. Writers@Grinnell presents a conversation with Poet Maggie Millner
  • Thursday, 1 October 2026, 4:15–5:30 p.m., GCMOA. Johnnie Chatman: The Artist as Researcher
  • Thursday, 1 October 2026, 4:00–5:30 p.m., HSSC A2231. Writers@Grinnell presents a reading by Poet Maggie Millner
  • Friday, 2 October 2026, 7:00 p.m., Wall Theatre. Neverland Players
  • Saturday, 3 October 2026, 2:30 p.m., Wall Theatre. Neverland Players
  • Saturday, 3 October 2026, 7:00 p.m., Wall Theatre. Neverland Players
  • Sunday, 4 October 2026, 2:30 p.m., Wall Theatre. Neverland Players

Multicultural

  • Friday, 2 October 2026, 4:10–5:00 p.m., HSSC N1170 Middle of Everywhere (Turkiye)
  • Friday, 9 October 2026, 4:10–5:00 p.m., HSSC N1170 Middle of Everywhere (Somewhere)
  • Saturday, 10 October 2026, 3:00–5:00 p.m., JRC 101. Walking Tacos with SOL New

Peer

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

  • Wednesday, 30 September 2026, 4:00–6:00 p.m., Springer Field. Men’s Soccer vs. Luther College
  • Saturday, 3 October 2026, 1:00–3:00 p.m., Springer Field. Men’s Soccer vs. U. Dubuque
  • Saturday, 3 October 2026, 1:00–4:00 p.m., Rosenbloom Field. Football vs. Knox

Wellness

  • Wednesday, 30 September 2026, 4:15–5:45 p.m., Undisclosed Location. Forest Bathing
  • Wednesday, 30 September 2026, 6:30–8:00 p.m., Bear Dance Studio. Brazilian Jiu-Jitsu
  • Monday, 5 October 2026, 8:00–9:00 p.m., Prayer Garage. Meditation Group
  • Tuesday, 6 October 2026, 4:30–6:00 p.m., Bear P103. Wellness Yoga
  • Tuesday, 6 October 2026, 5:00–8:00 p.m., HSSC North Atrium. Therapy Dogs New
  • Wednesday, 7 October 2026, 11:00 a.m.–1:00 p.m., JRC 1st Floor Lobby. The return of Mom Hugs New
  • Thursday, 8 October 2026, 11:00 a.m.–3:00 p.m., Goodnow 2nd. Visit the Ombuds for Ombuds Day New
    • Get swag.
    • Tell Deborah that I sent you.
  • Saturday, 10 October 2026, All Day, Somewhere. Mental Health Training
    • Sign up on Handshake.
    • It’s all day, so you will earn 3 tokens.

Misc

  • Wednesday, 30 September 2026, 8:00–9:00 p.m., Science 3820. Mentor Session
  • Thursday, 1 October 2026, 8:00–9:00 p.m., Science 3820. Mentor Session
  • Thursday, 1 October 2026, 4:00–5:30 p.m., CS Commons. Matcha and Milk Study Break
  • Tuesday, 6 October 2026, 4:15–5:15 p.m., HSSC 1231. Semester at CERA information program New
  • Thursday, 8 October 2026, 4:15–5:15 p.m., Noyce 3821.
    CS Major Information Session New
    • I’m not completely certain about when/where this one is.
    • We should have snacks beforehand.

Other good things

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

  • Saturday, 3 October 2026, 3:30–5:30 p.m., Springer Field. Women’s Soccer vs. U. Dubuque
  • Friday, 9 October 2026, 7:00–9:00 p.m., Darby. Volleyball vs. Knox New
  • Saturday, 10 October 2026, 1:00–3:00 p.m., Darby. Volleyball vs. Illinois. New

Upcoming work

  • Due Thursday, 2026-10-01
    • Nothing
  • On Friday, 2026-10-02
    • NEW Quiz/LA on collaboration (identify your classmates; just first name)
    • NEW Quiz/LA on lists and list operations.
    • MAKEUP Quiz/LA on conditionals.
    • MAKEUP Quiz/LA on compose, cut, and section.
    • MAKEUP Quiz/LA on tracing.
    • MAKEUP Quiz/LA on decomposition.
    • MAKEUP Quiz/LA on procedures.
  • Due Sunday, 2026-10-04
  • Due Tuesday, 2026-10-06
    • Mini-project 1 redo
      • When submitting a mini-project redo, please include a file called CHANGES.txt that describes what you’ve changed.

Notes on MP redos

The submission for the first redo deadline is free. Remaining redos are one token each.

If you didn’t turn in the assignment for the original deadline (or its late deadline), the redo is free, but you are charged two tokens for failing to turn in the original. (This policy holds starting with MP2.)

If you don’t turn in a redo for the first redo deadline (or up to two days late with a token), you will be charged a token for each remaining redo deadline, even though they may be your “first” redo.

Please make sure that your redo is accompanied by a CHANGES.txt file that summarizes the changes you’ve made. For example,

  • I added an eye procedure to part 2 because I had neglected to include a procedure for that part. I use it in making my cat.
  • my-image was a procedure. It is now an image, as the assignment requested.
  • I forgot to build images for part four. I’ve done so now.

Some notes on Monday’s lab

char->digit

Many of you wrote

(define char->digit
  (lambda (char)
    (- (char->integer char) 48)))

I’d prefer that you write

(define char->digit
  (lambda (char)
    (- (char->integer char) (char->integer #\0))))

Can you tell why?

Conceptually, we are subtracting the value of the zero character.

It means the same thing; the second one is clearer. (Perhaps slightly less efficient, but clearer.)

We might end up working in a different collating sequence. Our code will continue to work in a different collating sequence as long as it makes the sensible decision to collate digit characters in order.

I might even prefer

(define char->digit
  (o (r-s - (char->integer #\0)) 
     char->integer))

string->integer

I hope this served as a useful example of decomposition and/or bottom-up design.

A sample thought process.

  • I’ll need to convert each character to a digit at some point.
  • Once I convert one, I’ll need many.
  • Whoops! I have only single digits. I’ll need to multiply by their place values.
  • How do I get a list of place values?
  • How do I get an individual place value.

Making a concentric palette

Some of you asked that we go over the last question from the lab.

b. Write a procedure, (concentric-palette colors), that takes a list of colors as a parameter and makes an image of concentric squares of sizes 20, 30, 40, … (* 10 (length colors)).

We should decompose the problem a bit. I’ll try to ask the kinds of questions one might ask in developing a solution to the problem. YMMV.

How do I make a square?

(solid-rectangle width height color).

(solid-square size color) - the size represents both width and height

Suppose I wanted a list of squares of size 20 (instead of varying sizes). How do I write a procedure that takes a color and makes a single square of size 20?

(define square20 (lambda (color) (solid-square 20 color)))

Next, suppose I wanted a list of squares of size 20. We’ll use colors as the list we’re working with.

We could use list and do it individually

(list (square20 (list-ref colors 0)) (square20 (list-ref colors 1)))

We could make this more concise with

(map square20 colors)

Can we do this without separately defining square20?

We could replace square20 by its definition.

(map (lambda (color) (solid-square 20 color)) colors)

(map (l-s solid-square 20) colors)

How can we get the squares to vary in size?

Use map with two lists: One of sizes and one of colors.

(map solid-square (list 20 30 40 50 60) colors)

We need to build the number list programatically. What function might help?

make-list can make a list of numbers. It takes two inputs: a number that represents the desired size of the list and a second value which represents the element. It then makes a list of that many copies of the same element.

range will be useful for making a list of non-identical elements.

(range (length colors)) -> (list 0 1 2 3 4)

How do I convert (list 0 1 2 3 4) to (list 20 30 40 50 60)?

Use map of a function that adds 2 and multiple by 10

(define fun (lambda (n) (* 10 (+ 2 n))))

(map fun (range (length colors)))

Can we do this without defining fun separately?

We could put in the lambda, or we could use cut.

(map #(* 10 (+ 2 %1)) (range (length colors)))

If we preferred section to cut?

(map (o (l-s * 10) (l-s + 2)) (range (length colors)))

Let’s put it together

(define palette
  (lambda (colors)
    (map solid-square
         (map #(* 10 (+ 2 %1)) (range (length colors)))
         colors)))

This is close, but we still have a list of squares rather than a single square. What next?

Use overlay

(define palette
  (lambda (colors)
    (apply overlay 
           (map solid-square
                (map #(* 10 (+ 2 %1)) (range (length colors)))
                colors))))

Sectioning and map

“I have to add 2 to each element of a list.”

(map (l-s + 2) lst)

(define add2
  (lambda (val)
    (+ 2 val)))
(map add2 lst)

“I have to add 2 to each element of a list and then multiply each element by 10.”

(map (o (l-s * 10) (l-s + 2)) lst)

(define something
  (lambda (num)
    (* 10 (+ 2 num))))
(map something lst)

(map #(* 10 (+ 2 %1)) lst)

Can we trace (map (o (l-s * 10) (l-s + 2)) lst)

    (map (o (l-s * 10) (l-s + 2)) (list 0 1 2 3))
--> (list ((o (l-s * 10) (l-s + 2)) 0)
          ((o (l-s * 10) (l-s + 2)) 1)
          ((o (l-s * 10) (l-s + 2)) 2)
          ((o (l-s * 10) (l-s + 2)) 3))
; Note ((o f g) val) --> (f (g val))
--> (list ((l-s * 10) ((l-s + 2) 0))
          ((o (l-s * 10) (l-s + 2)) 1)
          ((o (l-s * 10) (l-s + 2)) 2)
          ((o (l-s * 10) (l-s + 2)) 3))
; Note ((l-s fun left) right) --> (fun left right)
--> (list ((l-s * 10) (+ 2 0))
          ((o (l-s * 10) (l-s + 2)) 1)
          ((o (l-s * 10) (l-s + 2)) 2)
          ((o (l-s * 10) (l-s + 2)) 3))
--> (list ((l-s * 10) 2)
          ((o (l-s * 10) (l-s + 2)) 1)
          ((o (l-s * 10) (l-s + 2)) 2)
          ((o (l-s * 10) (l-s + 2)) 3))
--> (list (* 10 2)
          ((o (l-s * 10) (l-s + 2)) 1)
          ((o (l-s * 10) (l-s + 2)) 2)
          ((o (l-s * 10) (l-s + 2)) 3))
--> (list 20
          ((o (l-s * 10) (l-s + 2)) 1)
          ((o (l-s * 10) (l-s + 2)) 2)
          ((o (l-s * 10) (l-s + 2)) 3))
...

Questions

Administrative questions

Will redos be available for the LAs that I’m still missing?

Yes. Redos for each LA will be available until everyone has passed that LA or we reach the end of the semester.

There’s an estimate of the number of classes I missed. Will I be charged tokens for missing those classes?

If I’ve charged you tokens for missing classes, you’ll see them under “Attendance” in the tokens section.

What determines how many semicolons you use at the start of a line?

We use three semicolons to mark the documentation for individual function or values.

We use two semicolons for broader comments for the reader.

We use one semicolon either to “comment out” code that is not yet ready to run or to insert comments in the middle of a function.

Can we see traces of reduce?

Not currently, but perhaps in the future.

Can I take quizzes tomorrow because I’ll be unavailable on Friday?

Yes, during office hours. You need not book a slot. I’ll hand you a quiz.

Reading questions

Why is and a keyword and not a function? I didn’t follow along well with the given example.

We have a standard approach to evaluating procedure calls (function calls): Evaluate all of the arguments and then apply the function. and doesn’t behave that way. It evaluates its parameters one by one, making it similar to a function, but different.

Could you please explain further the difference between apply and reduce? How do we know which one to use?

Apply works with any function and a list that contains exactly as many values as the number of arguments the function expects. It calls the function on those values.

(apply fun (list a b c d e)) -> (fun a b c d e).

Reduce works with a binary procedure and a list of any length. It repeatedly replaces pairs of neighboring elements by the result of applying the procedure until we’re down to one element.

(reduce fun (list a b c d e)) -> (fun (fun a b) (fun c (fun d e)))

(reduce-left fun (list a b c d e)) -> (fun (fun (fun (fun a b) c) d) e)

(reduce-right fun (list a b c d e)) -> (fun a (fun b (fun c (fun d e))))

Some functions, like + and string-append behave the same way when used with either reduce or apply. In part, that’s because they can take a variable number of parameters. In part, that’s because their semantics are the same either way.

Other functions, like list, may take an arbitrary number of parameters, but do not behave the same way if we do things pair-by-pair.

(apply list (list 1 2 3 4 5)) -> (list 1 2 3 4 5).

(reduce list (list 1 2 3 4 5)) -> (list (list (list (list 1 2) 3) 4) 5)).

Can you go over self-check 2b from Monday?

Sure!

b. Using apply and map, make a picture of seven outlined circles in darker versions of the rainbow colors (using two calls to rgb-darker). Note that you’ll need to convert the color names to RGB colors with color-name->rgb and then make them darker with two calls to rgb-darker.

Note: You might need three or four calls to map (or a particularly good composition of functions).

(define rainbow-colors (list "red" "orange" "yellow" "green" "indigo" "violet"))
(define thickly-outlined-circle
  (lambda (color)
    (overlay (outlined-circle 20 "black" 5)
             (solid-circle 20 color))))
(map thickly-outlined-circle
     (map (o rgb-darker rgb-darker) (map color-name->rgb rainbow-colors)))
(map (o thickly-outlined-circle rgb-darker rgb-darker color-name->rgb) rainbow-colors)

Lab

Don’t forget to reload Scamper to ensure that you are using 4.7.0.

The Scheme file should be called list-more.scm. If it’s not, go back to the schedule, reload, click on the lab link, and cross your fingers.