Skip to main content

CSC 151.03, Class 22: Naming local procedures

Overview

  • Preliminaries
    • Notes and news
    • Upcoming work
    • Extra credit
    • Fall Break PSA
    • Questions
  • Prebrief
  • Quiz
  • Lab
  • Debrief

News / Etc.

  • Thank you AM.
  • Have a wonderful fall break.

Upcoming Work

Extra credit (Academic/Artistic)

Extra credit (Peer)

Extra credit (Misc)

Other good things

Friday PSA

  • You deserve a break.
  • Please stay healthy.
  • Be moderate.
  • Encourage moderation in others.
  • Consent is absolutely, positively, necessary.

Questions

Prebrief

Answers to many of the problems are available at the end of the lab. DO NOT REFER TO THE ANSWERS until you’ve spent some time working on the problems yourself.

On Monday, you wrote all-odd?. That pattern will be helpful for at least one problem on today’s lab.

Remember that the single quotation mark means “Take this verbatim and do not evaluate individual elements.” So, just as '(a b 3 c) is the list of the symbols 'a, 'b, and 'c with an interspersed number 3, '(a sqrt 2 (sqrt 2)) is a list that contains the symbol 'a, the symbol 'sqrt, the number 2, and a list of the symbol 'sqrt and the number 2.

When you hit helper recursion, a table may be helpful.

Quiz

When you are done, bring up the lab (not pictures of students in this class).

Lab

How do I tell if all the elements of numbers are real?

Option 1

(letrec ([all-real? (lambda (lst)
                       (or (null? lst)
                           (and (real? (car lst))
                                (all-real? (cdr lst)))))])
  ...
  (cond
    [(not (all-real? numbers))
     ...]
    ...))

Option 2

(cond
  [(not (all real? numbers))
   ...]
  ...)

Debrief