Functional Problem Solving (CSC 151 2014F) : EBoards

CSC151.01 2014F, Class 30: Preconditions, Revisited


New partners!

Overview

Preliminaries

Admin

Work Returned

Upcoming Work

Extra Credit Opportunities

Academic

Peer Support

On Meeting with SamR

Some of you meet with me regularly. Some of you just asked for help on the exam. Some of you don't meet with me at all. I hear from our upper-level students that meeting with me was helpful when they were in 151.

Questions

Key Concepts

What did you see as the key concepts in the reading?

Key concepts:

Lab

What's going on with the following weird procedure?

(define all-drawings?
  (lambda (lst)
    (or (null? lst)
        (and (drawing? (car lst))
             (all-drawings? (cdr lst))))))

It's the wonder of recursion using Boolean values. It's also more concise (and, arguably, clearer) than something like the following.

(define all-drawings?
  (lambda (lst)
    (if (null? lst) 
        #t
        (if (drawing? (car lst))
            (all-drawings? (cdr lst))
            #f))))

Let me know if you need more explanation.

How do I tell if an element is in a list?

Option one: Look at the reference page for list procedures. There are at least two functions that help you tell.

Option two: You know at a certain point that the value is not in the list. You could just issue an error message at that point. : It's when the list is empty.)

What's the format for 6P's?

Three semicolons. One space. The word "Procedure". A colon. A newline.

Three semicolons. Three spaces. The name of the procedure. A newline.

Three semicolons. One space. THe word "Parameters". A colon. A newline.

And so on and so forth.