Skip to main content

CSC 151.01, Class 04: Introducing lists

Overview

  • Preliminaries
    • Notes and news
    • Upcoming work
    • Extra credit
    • Questions
  • Lab
  • Debrief

Preliminaries

News / Etc.

  • Welcome back to our permanent version of Shelby.
  • Thanks for keeping the room neat.
  • When you speak in class, please say your name first.
  • I’m already behind on grading. I apologize.
  • I talk fast. I try to slow myself down by writing a lot. But it could can be difficult. Question for you (I’ll close my eyes for the answer): How is my speed?
    • Please try to slow down a bit.
    • It’s fine, or at least acceptable.
    • Please try to speed up.

Upcoming work

About flash cards

  • A chance to summarize some key points or confusing points.
  • A potential study mechanism.
  • Both aspects have documented effect on learning basic concepts.
    • And you can’t do the complex stuff in CSC 151 unless you know the “language”: vocabulary, syntax, etc.
  • Examples:
    • What is (round 3.4)?
    • How does 1/2 differ from 0.5?
    • How does 1/2 differ from (/ 1 2)?
    • What are the parameters to substring?
    • What is (substring "Hello" 1 3)?
  • Answers:
    • 3.0
    • 1/2 is exact; 0.5 is inexact.
    • 1/2 represents a number. (/ 1 2) represents a computation.
    • (substring string start-pos after-end-pos)
    • "el"
  • I will provide you with a summary of the questions and answers.
  • You may use them in whatever way you consider best.
  • Usually about a week’s worth of work (WFMW)

Extra credit (Academic/Artistic)

Extra credit (Peer)

  • Posse Plus Retreat Recap, February 6 at 11am, JRC 101.

Extra credit (Misc)

Other good things

Questions

Why do you write some strange symbols, such as backticks, when you write the eboards?
I use a “language” called Markdown to format my text; it allows me to make the “pretty” Web pages without too much effort.
Why am I getting stupid errors from map1, like “that’s not an integer”, when it is?
Sam needs examples.
I want to do the self-checks on my own computer. What do I do?
Download DrRacket. (Free.)
Add the CSC151 package. (See day 1 lab.)
Email me an example of it not working.
Can I do without the (require csc151).
Probably, but I don’t know what it is.
How should we separate the different examples in HW 1?
In a way you think it will be easy for the grader to understand.
Is there a citation format you prefer?
I like APA.
I care more about the act of citing than the precise format. A URL suffices.

Lab

Note: You can comment stuff out by surrounding it with pound-bar and bar-pound.

#|
Look, DrRacket will ignore this.  So I can type incorrect stuff
(3 + 4), examples, and more.
|#

Keyboard shortcuts

  • Ctrl-up - Previous command
  • Esc-p - Previous command
  • Ctrl-down - Next command

Debrief

  • Which of the following is easier for you to do: count the number of elements of a list by hand or write (length lst)? Take advantage of what the computer can do!
    • Using length can also lead to more general solutions.
  • I’m happy to see that some of you are checking the answers (e.g., on the calculator you carry with you).
    • I wrote reduce. You’ve already seen that I sometimes lack competenence (e.g., in building Web sites). I could have written an incorrect definition of reduce.
  • There are at least three ways to add 2 to each element of a list.
    • (map increment (map increment lst))
    • (map (o increment increment) lst)
    • (map + lst (make-list (length lst) 2))
  • Some of you are already encountering the issue of “I should be able to write this, but I can’t.” Welcome to working within limits.
  • You will learn better ways to write things like “add 1.5” in the next lab.

A solution to problem 5

(map min
     (make-list (length ratings) 6)
     (map max
          (make-list (length ratings) 0)
          ratings))

Theme of next few weeks: What we can do with individual values, we can do with lists of values.