EBoard 06: Conditionals

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]
  • Reading notes [~5 min]
  • Q&A [~10 min]
  • Quiz [~10 min]
  • Labs [~55 min]

Administrative stuff

Notes and News

  • Happy Monday!
  • I was not able to get all my planned work done over the weekend. I hope to make more progress today.
  • 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.
    • If evening tutors + mentor sessions are not enough, we do have individual tutors available.
    • Evening tutors like visitors.
  • I’m still working on getting the autograders working well on Gradescope. You may see some errors from the autograder. You can ignore them. (It takes a while to write an auto-grader and the auto-grader system is imperfect.)
  • We have a mailing list in which we announce a variety of things (talks, job opportunities, etc.). Let me know if you’d like to join it.
  • Thank you for your comments on Teams.
  • Don’t forget to use the Whatchaupto channel.
  • If you ask me a question of general interest in Teams Chat, I will likely push you to use the Q&A channel. Let’s support each other with questions (and answers).

Upcoming activities and other token earning things

When appropriate, I will post details to the Announcements channel.

Upcoming work

I’m not sure if all of these links are correct. Let me know if any are not.

  • Lab writeup from today
  • Reading writeup
  • Mini-project 1 (due TONIGHT at 10:30 p.m. CST)
  • We will have another short (8 min) quiz today.
    • Topic: More simple procedures and image stuff.
    • Today’s quiz will involve programming. Make sure to open DrRacket.
    • You can also open appropriate Web pages.
    • You need not cite on quizzes. (You can, but need not.)

Attendance

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

Notes from the reading responses

(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

  • The cond falls on a line by itself. (Putting the first guard on the same line forces a lot of indentation.)
  • Guards and consequents are on separate lines. (Putting them on separate lines makes it easier to separate the two.]

Q&A

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.

Reading

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 and and cond

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.

Miscellaneous

When we have (op p1 p2), what’s the meaning?

Think of it as p1 op p2 in normal notation.

(- 2 3) is 2 - 3 in human notation

(< 0 x) is 0 < x in human notation

What’s the difference between between Q&A and Whatchaupto?

I don’t feel like retyping what I just said.

Project

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 ….

Quiz

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.

Lab

New partners!

Please make sure to title your group correctly.