Functional Problem Solving (CSC 151 2016S) : EBoards

CSC151.02 2016S, Class 38: Vectors


Overview

Preliminaries

Admin

Reminders

Upcoming Work:

Extra Credit

Academic / Artistic

Peer

Miscellaneous

Regular Peer

Misc

Far in the Future

Questions

What was yesterday's writeup?

Exercise 3.

What should rac and rcd return when given null as input?

What do car and cdr return when given null as input?

What's wrong with my stencil procedure?

Most common answer: You don't have to fit everything into one let or letrec. You can nest forms of let.

Second most common answer: You need to recompute the random column and row at each repetition. Think about your ordering of operations.

Third most common answer: Since there's call to image-new at the top of stencil-quarter-circle, don't recursively call stencil-quarter-circle. Use repeat or use a helper. (Sam prefers local helpers, but will cope with non-local helpers in many cases.)

Can you demo image-set-pixel!?

Sure. Done.

Can you explain the formula for problem 6?

The area of a circle is pirr. If the radius is 1, the area of a circle is pi. If it's a quarter circle, the area is pi/4. We're approximating the area of the quarter circle. We can then run the formula backwards to get pi.

See the board for more details.

But how do I get a random number between 0 and 1?

(random).

I've written irgb-closest using that "doubly recursive method" which we've seen is horribly inefficient. Will you penalize us for that?

Yes. Lots! (If I'm in a good mood when grading, and you have nothing else wrong with your solution, you'll be lucky to get a 6/10 on that problem.)

Do you expect us to think at least a little bit about efficiency?

Yes.

What about empty substrings?

Look at the postconditions.

> (define str "Hello World")
> (define substr "")
> (define pos 0)
> (equal? (substring str pos (+ pos (string-length substr))) substr)
#t
> (define pos 5)
> (equal? (substring str pos (+ pos (string-length substr))) substr)
#t
> (define pos 1253)
> (equal? (substring str pos (+ pos (string-length substr))) substr)
. . substring: starting index is out of range
  starting index: 1253
  valid range: [0, 11]
  string: "Hello World"

How much extra credit should we get for identifying the massive typo on how to submit?

At least two units. Email it to me, like always.

What is my number?

The same one as last time.

I lost it.

(random 1000000) ; add any leading 0's

Do you really want dead trees?

No. Point.

Are we ever getting to the main class material?

Maybe. Conveniently, tomorrow is a "pause for breath" and you can do the lab then.

Are you really taking off one point for each minute a student was late to today's class?

Considering it. (And yes, that's 50 points for people who missed class, and 30 minutes for ....)

A Bit More on Pair Structures

Why are we doing this? (That is, looking at pair structures and vectors.)

Why are we studying pair structures, given that we know about list?

Why are we studying vectors?

Vectors Lab