=====
CS 111 - Week 4 Labs - 2025-09-19
=====
=====
TODAY WE WILL
=====
* announcements/prep for next class
* review clicker questions
* Week 4 Lab Exercise
=====
* at-least-first-attempts at Homework 3's problems
are due by 11:59 pm TONIGHT (Friday, Sept 19)
* REMEMBER: as discussed in the course syllabus,
to be able to submit improved versions of Problems 4-7
after that deadline,
you need to submit attempts at Problem 1's, 2's, and 3's short
answer questions, AND submit a 111hw3.rkt file attempting at least
one of Problems 4-7, by that deadline
* watch for class e-mail letting you know when Homework 4 is available
=====
another boolean function to compare for equality
=====
* (this came up during a question in the 9:00 am lab,
adding this to remember to mention in 3:00 pm lab, also)
* we know that:
* = can be used to see if arguments of type *number*
have the same value;
(= 3 4) ; #false
* string=? can be used to see if two arguments of
type *string* have the same value;
(string=? "moo" "Moo") ; #false
* boolean=? can be used to see if two arguments of
type *boolean* can have the same value;
(boolean=? #true true) ; #true
* image=? can be used to see if two arguments of
type *image* can have the same value;
(image=? (circle 10 "solid" "red")
(circle (+ 5 5) "solid" "red")) ; #true
* notice: any of the above will give an error if
used with arguments of a type they do NOT expect;
(= 3 "moo") ; causes an error, "moo" is a string, not a number
(= 3 4) ; no error, just returns #false
* we'll see -- next week! -- that because Racket
is loosely-typed, we can sometimes have some informal
"combo" types;
in THAT case, we sometimes NEED a less-type-sensitive
equality-comparison function!
* that function is equal?
* equal? expects two arguments of ANY type,
and returns #true if they have the same value,
and #false otherwise -- so,
(equal? 3 "moo") ; just returns #false, not an error
* WHY don't we just always use equal? then?
* this is a bit subtle, but: if your function ALWAYS
expects a particular type, using the more-specific
test-for-equal function returns a possibly-better
error message;
so, if your function expects numbers, using =
causes an expects-a-number error, which might be
useful!