EBoard 12: Naming local variables

This class will be recorded! Its use is limited to members of the class. Please do not share with others.

Approximate overview

  • General administrative stuff [~10 min]
  • Q&A [~10 min]
  • Quiz [~10 min]
  • Lab [~60 min]

Administrative stuff

Notes and news

  • Sorry for starting class at the last minute. Since I did so, we’ll wait a minute or two for people to join.
  • Don’t worry about the checks for the reading; they are not due until Monday.
  • Happy Diwali! (Or happy start of Diwali.) One of the few good things about remote learning is that some of you who celebrate can be home for a real celebration. (But please celebrate carefully.)
  • Beware! Friday the 13th falls on Friday this month. (That probably explains all the stuff that went wrong yesterday.)
    • At least class 13 isn’t on Friday 13th
  • I’d love to hear questions from more of you. (Volunteering answers also works.)
  • I may send out information about your current status this weekend (e.g., how many tokens you’ve earned/used).

Fun with technology

I will demo each. (Or at least I hope I will demo; computers have not been my friends of late. And there’s that date thing.)

  • It appears that some of you did not know how to see your comments on Gradescope.
    • Bring up the assignment
    • Click on each problem in turn
    • The “rubric” (such as it is) and the comments will appear (or at least I hope they will)
  • Please update your csc151 library by using
    • File -> Install Package
    • Enter https://github.com/grinnell-cs/csc151.git
    • Click “Update”
  • How to avoid the strange issues when you upload your Racket files
    • Use a special command when saving the file.
    • File -> Save Other -> Save Definitions As Text…
    • Issue: Racket has a special file format.

Tutoring reminders

  • Evening tutoring will be available 3-5 p.m. Sundays and 8-10 p.m. Sundays through Thursdays in the tutoring channel on the CS team.
    • Please don’t expect them to be available, say, 6 p.m. on Sundays.
  • Individual tutors are also available.
    • Those who are working with them say that they are awesome.

Upcoming activities

Attend (or watch recording) and send a one-paragraph reflection.

  • 3:30 p.m. Saturday, Maker Lab Virtual Open House (+1 token)
  • Noon, Monday, CS Table (+1 token)

Upcoming work

  • Mini-project 3 (due Wednesday at 10:30 p.m. CST)
  • Mini-project 1 redo (due Sunday at 10:30 p.m. CST)
  • Mini-project 2 redo (due Sunday the 22nd at 10:30 p.m. CST)
  • Reading for Monday
  • Lab writeup(s) for Monday.
  • Quiz today: composition, sectioning, list procedures, etc.
  • Quiz Monday: Local bindings (likely a tracing example)

Getting to E on MP1

Things that categorized (or we hope will categorize) E-level work on mini-project 1.

  • Met all the expectations of the assignment (e.g., name of image at top, minimum number of definitions, procedures, etc.)
  • Met “readability” expectations.
    • Functions formatted correctly (indentation, spacing, etc.)
    • Blank lines to separate sections.
    • Header at top giving author etc.
    • Comments!
    • Especially good names.
    • Correct spelling / grammar / etc.
  • Especially good design
    • Concise
    • Not a lot of replicated code
    • Easy to adapt / change. What if colors change? What if sizes change?
  • Awesomely cool images (not strictly required)
  • No real flaws (that’s harder to make concrete)

If you redo MP 1, make sure to stick to things you knew at the time of MP 1 (unless you are one of the few who Bingled more advanced solutions).

We’ll work on making sure there are more detailed comments on the next mini-project to help you achieve E in your redo.

Q&A

General

How do we ask questions about our grading?

Chat Sam on Teams.

What is the “logic” of reduce? It seems unpredictable.

Basic idea: Combine neighboring pairs using a procedure until you have a single value.

     (reduce + (list 4 1 2 3 6 4 7))
---> (reduce + (list 4 1 5 6 4 7))
---> (reduce + (list 4 1 5 6 11))
---> (reduce + (list 5 5 6 11))
---> (reduce + (list 5 11 11))
---> (reduce + (list 5 22))
---> (reduce + (list 27))
---> 27

Why is it unpredictable?

We’ve made it unpredictable to model what happens with reduce in the real world.

If you want predictable, reduce-left and reduce-right.

Or you should choose an operation in which the order doesn’t matter.

We sometimes need to escape impurity.

let vs. let*

Today’s lab will explain.

Why move the bindings outside the lambda?

See today’s lab.

Quiz

Detour: Moving bindings outside the lambda, using today’s lab

    (define years-to-seconds-b
      (let* ([days-per-year 365.24]
             [hours-per-day 24]
             [minutes-per-hour 60]
             [seconds-per-minute 60]
             [seconds-per-year (* days-per-year hours-per-day
                                  minutes-per-hour seconds-per-minute)])
        (lambda (years)
          (* years seconds-per-year))))

--> (define years-to-seconds-b
      (let* ([hours-per-day 24]
             [minutes-per-hour 60]
             [seconds-per-minute 60]
             [seconds-per-year (* 365.24 hours-per-day
                                  minutes-per-hour seconds-per-minute)])
        (lambda (years)
          (* years seconds-per-year))))

--> (define years-to-seconds-b
      (let* ([minutes-per-hour 60]
             [seconds-per-minute 60]
             [seconds-per-year (* 365.24 24
                                  minutes-per-hour seconds-per-minute)])
        (lambda (years)
          (* years seconds-per-year))))

--> (define years-to-seconds-b
      (let* ([seconds-per-minute 60]
             [seconds-per-year (* 365.24 24
                                  60 seconds-per-minute)])
        (lambda (years)
          (* years seconds-per-year))))

--> (define years-to-seconds-b
      (let* ([seconds-per-year (* 365.24 24
                                  60 60)])
        (lambda (years)
          (* years seconds-per-year))))

--> (define years-to-seconds-b
      (let* ([seconds-per-year 31556736.0])
        (lambda (years)
          (* years seconds-per-year))))

--> (define years-to-seconds-b
      (lambda (years)
        (* years 31556736.0)))

Lab —

  • Don’t forget to introduce yourselves.
  • Please follow naming conventions for your conversations.
  • Remember: If you know your group, you can join even if you haven’t been invited.