Skip to main content

CSC 151.01, Class 08: Writing Your Own Procedures

Overview

  • Preliminaries
    • Notes and news
    • Upcoming work
    • Extra credit
    • PSA
    • Questions
  • Quiz!
  • Review: Algorithm components
  • Detour: Sequencing operations
  • Review: Types
  • User-defined-procedures
  • Start lab (?)

News / Etc.

  • Continue partners!
  • Sam’s grading of HW1 is now done! (Our graders get to work on the lab writeups and HW2. They should be done on Sunday.)
  • If there are things I do in class that don’t seem to end up in the eboard, and you’d like them there, please let me know.
  • Lots of talking today (prelims, topics, etc.). That’s okay, we’ve reserved two days for today’s lab.
  • In the CS commons, we now have a supply “store” (free will donation) with pens.

Reminders

  • I’m always happy to (try to) answer questions via email. There is no need to apologize when sending me questions.
  • We have tutors available Sunday through Thursday evening from 7-10 p.m. in Science 3813/15.
  • Starting this week, we will have mentor sessions on Wednesday and Thursday evenings from 8:00-9:00 p.m. in the CS Commons. Wednesdays will be more Q&A, Thursdays will include sample quizzes.
  • I run review sessions on Thursdays at 9am in this room.
  • We have individual tutors available for those who take advantage of the above and find that it’s not enough.

Upcoming Work

Extra credit (Academic/Artistic)

  • CS Table, Tuesday, 7 Feb 2017. Something on privacy.
  • Thursday extras, Thursday, 9 Feb 2017, 4:15 p.m., Science 3821: Something on computer graphics (visitor from UMN).
  • Scholars Convocation, next Thursday, 9 Feb 2017, 11:00 a.m., JRC 101. David Orr: Climate Change and the Crisis of American Democracy.

Extra credit (Peer)

  • Swimming and Diving meet 1pm on Saturday.
  • Ritalin Test Squad Improv Troupe is looking for new members and will be holding try outs this weekend. Auditions will be on Saturday Feb 4th, 1-3 pm in The Wall (Bucksbaum 152).
  • Pun Club, Saturday at 4pm in (private), which appears to be a pun on “Younker 1st Lounge”.

Good things to do

  • Divest rally Friday at 3pm in ARH 302.

Friday PSA

  • Take care of yourselves.
  • Don’t swim in the Macalester pool.
  • I’ll have new data next week.

Questions

Why do we use lambda and section when we can just write (define (f x) (+ 2 x))?

  • I’m mean?

  • It helps you learn other important concepts.

Can you walk us through self-check 2 on the reading on image transformations?

  • To undo “redden”, (image-variant modified-image (section irgb-subtract <> (irgb 32 0 0)))
  • To undo “redden” (image-variant modified-image (o irgb-complement irgb-redder irgb-complement))
  • If the red component was over 223, it will end up at 223 when we add 32 and subtract 32.

My account seems screwed up. Hewlp!

I’ll hwelp you during lab.

What is that o?

Shorthand for “compose”

Why didn’t it work when I typed the same thing you did in the eboard?

You forgot the w?

Computers are sentient and malicious.

Sam lied on the eboard. There is no color->string.

Do you care whether we know the order in irgb-rotate and do you realize that whatever you said in the reading is backwards?

No. Yes.

If your mentors screwed up as badly as you did, you’d threaten to fire them. Should we fire you?

I have tenure.

Quiz

Done.

Review: Algorithm components

What did we decide goes into writing algorithms? Which have we already seen in Scheme?

  • How did you answer this question?
    • I remembered stuff!
    • I looked at my notes.
    • I looked at the reading.
    • I’m fortunate that I have a really good partner.
  • Basic values
    • Numbers
    • Symbols
    • Strings
    • (Procedures)
    • Colors
    • Images
  • Variables
    • (define NAME EXP).
  • Parameters or inputs
    • Not sure
  • Conditionals
    • Nope
  • Subroutines
    • Build our own with compose
    • Build our own with section
    • Build our own with lambda
  • Sequencing
    • Nested functions suggest sequencing (+ (* a b) (- c d))
      • The * and - are done before the +
      • But we don’t know the order of the * and the -.
    • Compose does some sequencing (right-to-left)
    • When you write things in sequence, they are computed in sequence
      • (define a 10) (define b (+ a a))
      • (define b (+ a a)) (define a 10))
  • Repetition
    • We have not learned general repetition yet, other than typing it again and again and again.
    • image-variant repeatedly applies a procedure to each pixel.
  • Basic operations
    • +

Detour: Sequencing operations

See above.

Review: Types

Postponed.

User-defined-procedures

Postponed

Lab (?)

Postponed