Skip to main content

CSC 151.01, Class 04: Introducing lists

Overview

  • Preliminaries
    • Notes and news
    • Upcoming work
    • Extra credit
    • Questions
  • Topics:
    • Context: What and why lists?
    • Building lists
    • Mapping lists
    • Reducing lists
    • Sorting lists
    • Other list operations
  • Structure
    • Quiz
    • Lab
    • Debrief

News / Etc.

  • New places/partners!
  • No attendance today.
  • Thank you to everyone who is pointing out broken links and mangled text!
  • Make sure to send writeups to your grader, not me. Also make sure to carbon copy your parter.

Upcoming Work

Extra credit (Academic)

  • Rosenfield symposium, next week. (Lots of different events)
  • CS Table, Tuesday at noon: TBD.

Extra credit (Peer)

  • Women’s Soccer vs. Simpson, TODAY, 5:00 pm, Springer Field
  • Women’s Soccer vs. Alumnae, Sunday, Noon, Springer Field
  • Men’s Soccer vs. Coe, TODAY, 3:00 pm, Springer Field
  • Men’s Soccer vs. Alumni, Sunday, 2:00 pm, Springer Field
  • Volleyball vs. Wisconsin-Whitewater, TODAY, 4:00 pm, Coe College (Cedar Rapids)
  • Volleyball vs. Wisconsin-La Crosse, TODAY, 8:00 pm, Coe College (Cedar Rapids)
  • Tiger Football. Tonight at 7pm ish.

Extra Credit (Misc)

  • Community Hour (Dialogues Across Difference), Tuesday at 11 a.m. in JRC 209.
  • CLS Kick-Off Event, Tuesday at 11 a.m. in “North Campus Grove”.

Friday PSA

  • You are clearly awesome. I do not want you damaged. (Others don’t want you damaged either.)
  • Think about what is right for you, in advance, and stick to it.
  • CONSENT IS ABSOLUTELY POSITIVELY NECESSARY.

Questions

I left Firefox open on another machine. What do I do?
Ask Sam or Marli to type some magic incantations.
What locations are available for me to work on MathLAN machines?
3813 and 3815. Classes in the rooms during the days, available at night.
CS Learning Center (3828, I think). All the time, except if there’s a mentor sessions there.
  1. (See 3813)
Math Lab, when it’s open.
Science 2401.
If we emailed the lab writeup to you by mistake (or because Sam’s instructions
were not clear enough), should we resend it to the grader?
Yes, please.
How long should lab writeups be?
Enough to get the job done, but not much more.
Sam will send out an example.
Can we take notes in DrRacket while we are working on labs?
Yes. Stuff preceded by a semicolon is a comment and is ignored by DrRacket.
So put notes in the definitions pane, add semicolons, and save to desktop (or somewhere else)
Consider the following definitions: (define one 1), (define two 2),
(define three 3). If we type (list one two three), we get
'(1 2 3). Why? And what about symbols?
What does one mean? There’s a variable named one which contains (or references) (or names) the value 1.
When DrRacket sees something like (list one two three), the first thing it does is looks up the variables in its table of values.
In contrast, 'one means “the symbol one”.
DrRacket is weird: '1 means “the numeral 1” not “the symbol 1”.
Symbols must not look like numbers. ' operation is a bit more complex than “make this a symbol”.
Procedure calls and lists look similar. Really? I see a quotation mark
in front of lists, both when I type them in the “don’t do it this way”
approach and when DrRacket gives them back to me.
Some Scheme interpreters don’t include the quotation mark, which can lead to confusion. That’s why we mention it.
The mentors are awesome, aren’t they?
Yes.

Quiz

  • Ten minutes.
  • Questions
    • “Sift flour” means to put the flour in a mesh and to shake it back and forth in order to remove larger particles. I make cultural assumptions. Ask me about it when I use terms that you don’t understand. The failing is mine, not yours.
    • Yes, you can use the back of the page.
  • When you finish, bring up the lab (if possible) and start reading through it until your partner is ready.
  • Once both partners are ready, start.
  • I will return graded quizzes on Monday.

Lab

Do the first lists lab.

Be prepared to debrief.

Debrief

What’s the writeup?
Exercise 5
I’m stumped as to how to add 1.5 to each element of a list. I could
add 1 with increment, but I don’t know a procedure that adds 1.5.
Right now, your tools are limited, so you have to think about how to use those tools. Your problem solving abilities grow when you problem solve with restricted tools.
Since we want to do an operation that involves two values (addition), you’ll need to make a second list and then use map.
How do I know when to include csc151/lists, csc151/hop, and
csc151/numbers?
Just make it practice to do so.
Wow. That’s a lame answer. I really want to know what’s defined in
those files.
csc151/lists currently provides iota, map1, reduce (and variants), and possibly something else.
csc151/hop currently provides o, section (next class), and some other things we’ll cover later in the semester.
csc151/numbers currently provides increment and decrement.
Why do you keep typing those backticks?
It makes things format nicely when I turn this into a Web page.
Can you help me think about the relationship between map and reduce?
You use map when you want to go from a list of values to another list of values. It’s a cool mechanism for one form of repetition. We might, for example, add two to each element in a list. (map (o increment increment) (list 1 2 3 4 5)) =>
You use reduce when you have a bunch of values that you want to combine into a single value. It’s a cool mechanism for a different form of repetition. We might, for example, add up all the numbers in a list.