This class will be recorded! Its use is limited to members of the class. Please do not share with others.
Approximate overview
When appropriate, I will post details to the Announcements channel.
I’m not sure if all of these links are correct. Let me know if any are not.
(odd? x) is clearer than (= (remainder x 2) 1).
Which of the following is clearest? Least clear?
(positive? x)(> x 0)(< 0 x)Consistent formatting of cond statements can aid clarity. I
very much prefer (but don’t always use) the following.
(cond
[guard
consequent]
[guard
consequent]
[guard
consequent]
[else
alternate])
That is
cond falls on a line by itself. (Putting the first guard
on the same line forces a lot of indentation.)Please try to ask questions on the Q&A channel and leave this section for (a) things I am unclear about in that channel and (b) things that came up while you were listening to me this a.m.
I wanted to say that complex numbers are neither negative nor positive. How could I write that?
(define categorize
(lambda (num)
(cond
[(and (complex? num) (not (real? num)))
'neither]
[(positive? num)
'positive]
[(negative? num)
'negative]
[else
'neither])))
You were enountering the problem that we are not allowed to use the basic comparison operations with complex numbers because there is not a clear ordering on complex numbers. (1+2i vs 2+1i?)
Something you’ll learn is that the order of the tests in a cond ends up being important.
I forget to do one of the problems on the reading. Can I fix that?
Yes. No penalty for this reading. (Maybe in the future.)
Sam, you claim that you will respond to questions on the Q&A channel, but it looks like you didn’t. What’s up with that.
Sorry. Tag me!
What’s the difference between “true” and “truish”?
In “pure” Boolean logic, there are only two values: true (#t) and false (#f).
The designers of Scheme decided that it’s okay to use impure Boolean values. “Anything that’s not false behaves like true”. So we call truish.
(if (+ 1 2) 5 7) -> (if 3 5 7) -> 5
(or #t 5) -> #t
(or (+ 1 2) 5) -> (or 3 5) -> 3
(or #f 5) -> 5
We’ll see similar behavior with
andandcond…
Schemers do some horribly strange things that take advantage of this feature.
Every string is truish.
Every number is truish.
Every symbol is truish.
Every list is truish.
Every image is truish.
When we have (op p1 p2), what’s the meaning?
Think of it as
p1 op p2in normal notation.
(- 2 3)is2 - 3in human notation
(< 0 x)is0 < xin human notation
What’s the difference between between Q&A and Whatchaupto?
I don’t feel like retyping what I just said.
Can we use reflection for MP1?
I suppose so.
Can we use text for MP1 part 2?
Certainly.
Can I continue to revise until the deadline?
Yes.
I overlaid seventy variables. Is that okay?
I’m not sure that that was a good use of your time, but okay ….
Bring up readings in your browser.
Open DrRacket.
Go to the Quiz in Gradescope.
Eight minutes (more or less).
When you are done, head over to the lab channel.
New partners!
Please make sure to title your group correctly.