EBoard 04: Procedures, subroutines, and such

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

Approximate overview

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

Administrative stuff

Notes and News

  • No, class is not cancelled for the blizzard.
  • 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.
  • I’m still working on getting the “auto graders” working on Gradescope. You may see some errors from the autograder. You can ignore them.

Upcoming activities

I will post details to the Announcements channel.

  • Scholars’ Convocation, noon, today. (Whoops!)
    • If you went, you can write it up.
    • I am checking on the availability of a recording.
  • CS Extras, 5pm, Thursday, 4 February, in Events Channel on CS Team.
  • Try out the campus Maker Space (well, the Satellite Maker Space) https://makerlab.sites.grinnell.edu/satellite-home/

Upcoming work

Attendance

  • Our wonderful mentors will take attendance by looking at the the list of also-wonderful people here.

Reading notes

Here’s a sample solution.

-> (add-3 (* 2 3) (+ 8 3) (/ 1 2))
-> (add-3 (* 2 3) (+ 8 3) ( 0.5 ))
-> (add-3 (* 2 3) ( 11 ) ( 0.5 ))
-> (add-3 ( 6 ) ( 11 ) ( 0.5 ))
-> (+ (+ 6 11 ) ( 0.5 ))
-> (+ ( 17 ) ( 0.5 ))
=>  17.5 

Some notes

  • Don’t leave values in parentheses. In Racket, parentheses usually mean “the thing that appears next is a procedure”.
  • When possible, keep numbers in the same “type”. 1/2 and 0.5 are different kinds of numbers in Racket.
  • You should be able to evaluate any of the intermediate expressions along the way and get the same result.
  • At this point in your career, it’s worth doing each step.

Q&A

Quizzes

Clarification: Are quizzes satisfactory / non-satisfactory?

Yes (1 for satisfactory and 0 for non-satisfactory/redo)

Do you have a recommendation on how to approach coding quizzes?

Type the code in Gradescope.

Click “Submit”.

Click “Resubmit”. (That way, it’s ready for your next submission.)

Copy and paste the code into DrRacket.

Work on it for a bit.

Copy and paste the improved code into Gradescope

Click “Submit”.

Continue as appropriate.

Why submit before working in DrRacket?

At least one person got caught up in working in DrRacket and never submitting anything.

But if you’re really fast, you can start in DrRacket.

I screwed up the quiz. What happens next?

I will release a makeup quiz. You can take it on your own time.

Note that you only need a satisfactory on 21 of 25 quizzes to meet that component of an A grade.

What do quizzes cover?

Generally, the prior day (and before).

Often a problem related to the prior day’s lab.

What are the answers to the quiz?

(define ball (circle 20 'solid 'black))
(above ball
       (beside ball ball)
       (beside ball ball ball))

Can we have the answers to today’s quiz?

Yes.

Do makeup quizzes cost tokens?

No.

When are makeup quizzes released?

Usually the day or day after the quizzes are returned?

When do you return quizzes?

Usually the day after you take the quiz, sometimes a day later.

Labs

What should we do if we run out of time on a lab?

Option one: Continue to work for the next twenty minutes or so. I’ll generally stick around. Submit after those twenty minutes.

Option two: Set another time to meet and finish up.

Option three: Split up, finish it individually, make sure to cite/acknowledge each other. “I did problems 1–3 with Yksleber.”

Note: Please negotiate with your partner.

What should we do if we finish a lab early?

Option one: Do the extra problems (if we’ve written any).

Option two: Work on the next mini-project. It’s nice to have time when you can ask questions.

Option three: Leave.

Note: Please negotiate with your partner.

Readings

When would you want to write a zero-parameter procedure?

There are some procedures that we call for “side effects”; they do something other than return a value. The most frequent side effect is to write something out.

Here’s an example. You need not understand.

(define seven
  (lambda ()
    (display "The user wants the value seven")
    (newline)
    7))

(define six
  (lambda ()
    (display "The user wants the value six")
    (newline)
    6))

> (* (seven) (six))
The user wants the value seven
The user wants the value six
42

Other

Do you realize you screwed up the due date on today’s lab writeup?

Thanks. I’ll fix it.

Why don’t we need black in quotation marks in the following? (define ball (circle 20 'solid 'black))

The designers of the circle procedure allow you to use strings (in double quotation marks) or symbols (preceded by tick marks).

What does a non-coding quiz look like?

Likely questions on algorithms or how we approach problems in Scheme/Racket.

More conceptual, less “write code to do this”.

What is the relation between a parameter and a defined variable of the same name?

They are independent. They may confuse the human, but the computer treats them differently.

Quiz

Bring up readings in your browser.

(Don’t bother opening DrRacket.)

Go to the Quiz in Gradescope.

Eight minutes (more or less).

Lab

New pairs! Let’s hope Sam can get the code to run.

You will not be able to finish in class. Sorry. You may finish on your own or arrange a time to meet with you partner later.

  1. Sam (well, Sam using a computer program he wrote) assigns groups.

  2. First person in the group goes to the Lab Sessions channel, clicks the camera (or something equivalent) and then “Meet Now”. Please get the channel right. We won’t see you in other channels.

  3. Add a subject. “Group # (Names)”, such as “Group 1 (SamR & JohnG)” Please get the group name right. It makes it much easier for us.

  4. Click “Meet Now”.

  5. Invite the other members of the group.

  6. Other members of the group join. (Today, you can start discussions once you have two in the group. Generally, you’ll wait until everyone is there.)

  7. Discuss/work/whatever.

There are four problems. You should submit at least the first three by the end of class. Sam will warn you when there are ten minutes left in class so that you can decide whether to submit the first three problems or try to do all four together.

Debrief

We probably won’t have time, but I like to leave the potential there.

M vs. E

I’m not sure whether or not we’ll get to this today, but it’s a reminder for me to discuss it with you some time soon.

Most work that is correct will be M (meets expectations) rather than E (exemplar / exceeds expectations). E work is code we could share with your fellow students as, well, an exemplar. (A good exemplar.)

  • If you don’t get an E, you will likely receive some guidance as to how to get closer to an E.
  • The sample rubric in each mini-project helps you know waht you need for an E.

Meets expectations

(above (circle 20 'solid "black")
       (beside (circle 20 'solid "black")
               (circle 20 'solid "black"))
       (beside (circle 20 'solid "black")
               (circle 20 'solid "black")
               (circle 20 'solid "black")))

Also meets expectations, even though it doesn’t work.

(above circle 20 'solid "black")
       beside (circle 20 'solid "black")
               (circle 20 'solid "black"))
       (beside (circle 20 'solid "black")
               (circle 20 'solid "black")
               (circle 20 'solid "black"))))))))

Better (probably the best you can do right now)

(define ball (circle 20 'solid "black"))
(above ball
       (beside ball ball)
       (beside ball ball ball))

Overkill (beyond what you can do right now)

(define ball (circle 20 'solid "black"))
(define row-of-balls 
  (lambda (n)
    (if (= n 1)
        ball
        (apply beside (make-list n ball)))))
(define pyramid
  (lambda (rows)
    (apply above (map row-of-balls (cdr (iota (+ 1 rows)))))))
(pyramid 3)