Skip to main content

CSC 151.03, 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!
  • Please make sure to send writeups to our grader and not to me. (I also get the grader email, but it helps me to keep things separated.) Make sure to carbon copy your partner.

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

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”.
  • The Big Sick, Tonight at 7:15 or 9:30.

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 to type some magic incantations.
Type firefox --ProfileManager in the terminal and create a new profile.
Use Chromium.
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.
You have long sequences of code in many of the readings. Am I expected
to memorize those?
No. They are intended as illustrative. You should use them to check and build understanding (and perhaps to generate questions).
Is CS table usually Tuesdays at noon.
Yes, for most of the semester.
Why is there a map1?
It’s a more specific version of the generalized map which may be a bit more efficient because it works on only one list.
I’m not sure that I understand map and map1?
Wednesday we learned some operations we can do to numbers (or strings or …)
What happens when we have a bunch of values? (define values (list 7 1 4 2 4 8 -3))
(list (square 7) (square 1) (square 4) (square 2) (square 4) (square 8) (square -3))
map1 exists for “I want to do the same thing to every one of these values”
I’m not sure that I understand symbols.
(Sam wonders why we bother talking about symbols since all they really serve to do is confuse people.)
Symbols exist to represent concepts. Strings might suffice, but advanced Schemers find symbols work better.
How do I do this [more complex thing we haven’t covered yet]?
Let’s master the basics first.
Which element is the first element of a list?
It’s element 0, since we start counting with 0.
We count “How many elements do you have to remove before getting to the value.”

Quiz

  • Questions
    • “sift” means to put in a wire mesh and shake so as to remove larger particles. (Sam makes cultural assumptions. When he does so, the problem should be his, not yours. Ask.)
    • Yes, you can use the back of the sheet.
    • Some things are a bit ambiguous. You may find that you want to use the same letter twice. You may do so.
  • Ten minutes.
  • 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.

Note: Our goal is that you work in pairs. If DrRacket is running on your computer, you are not working in pairs. If we see DrRacket running on your computer during lab time, we will confiscate that computer and give it to Zander.

Be prepared to debrief.

Debrief

I don’t seem to be able to use increment.
Make sure that you (require csc151/numbers)
Shouldn’t you have told us to do that?
Yes.
Why didn’t you?
I did. See the preliminaries.
Could you help me think through the “add 2 to each value in the list”
problem?
That seems like an opportunity to use map1.
But we don’t have a procedure that adds 2.
Can we make one? Yes, if you add 1 twice, you add 2. (o increment increment) adds 2.
So we can write (map1 (o increment increment) lst).
Could you help me think through the “add 1.5 to each value in the list”
problem?
Sure.
We don’t have a procedure to add 1.5. We don’t even know how tou build one (yet).
But we do know how to add two lists, using (map + lst1 lst2).
So we just need to make a second list.
The length of that list is the same as the length of large-illness-ratings.
So (map + large-illness-ratings (make-list (length large-illness ratings) 0.5))
What’s that magic incantation?
Open a terminal window
Type /home/rebelsky/bin/magic-incantation (without any backtics)
Hit the enter key afterwards.
Cross your fingers
Try to start Firefox
Let me know if it works