=====
CS 111 - Week 2 Lecture 2 - 2026-09-03
=====
=====
TODAY WE WILL:
=====
* announcements
* review of Racket identifiers
* review of Racket named constants
* intro to check-expect
* intro to writing your OWN functions
using the DESIGN RECIPE
* prep for next class
=====
* should be working on Homework 1, submitting early and
submitting often!
* Problems 1 and 2 are completed on Canvas
* the remaining problems are answered in a Racket .rkt
file, that you submit (like you submitted the Week 1
Lab Exercise's Racket .rkt file)
* at-least-first-attempts at its problems are
due by 11:59 pm this Friday, September 4
* Should be working through the Week 2 readings
* (given on the public course web page under "Reading Assignments",
and the "Reading Assignments" section under Modules on the course
Canvas site)
=====
REMINDER: BONUS OPPORTUNITY: to ENCOURAGE an early first visit to
student hours!
=====
* During the FIRST TWO WEEKS of class --
(so, by Friday, September 4)
COME to BSS 322 during student hours
and tell me a JOKE,
and you will receive a 1-point BONUS on
Homework 1
* (Since the main point is to come by my office in
BSS 322, you must tell me a joke there to receive
this bonus.)
* (If you find me in BSS 302 at a time other than
student hours, and tell me a joke then, you can
also receive this bonus.
But you can be more sure that I will be there
during student hours.)
=====
REMINDER: SYNTAX of a BSL Racket identifier
=====
* identifier: any name determined by a programmer
* Some examples of identifiers are named constants,
function names, parameter names, and more
* In BSL Racket, syntax for an identifier
is a consecutive collection of characters that:
* does NOT include a blank or tab or newline
* does NOT include any of the special characters:
( ) [ ] { } " , ' ` # | \
* AND ALSO does not follow the syntax rules for
a Racket data type
* (also: it can't have already been defined in the
current Definitions window/.rkt file! 8-) )
* REMINDER: some identifier-related CS 111 CLASS STYLE rules:
* make identifier names DESCRIPTIVE, MEANINGFUL
and NON-misleading
* start them with a letter (even though BSL Racket syntax does
NOT require that...)
* write identifiers that are named constants in ALL-UPPERCASE
AND now we will ALSO add the following ADDITIONAL CS 111 CLASS STYLE rules:
* write identifiers that are function names in all-lowercase
(but will also accept camelCase starting with a lowercase letter)
* write identifiers that are parameter names in all-lowercase, also
(but will also accept camelCase starting with a lowercase letter)
* what is a parameter? a parameter (or parameter variable)
is like a variable in a math function -- it stands for an
argument to be determined later!
* once you GIVE a value to an identifier, then THAT identifier,
by itself, is ALSO a simple expression;
* (of what data type? the data type of its value)
=====
REMINDER: one kind of identifier: a NAMED CONSTANT
=====
* a named constant is a name representing a value that will
NOT change in your program
* define can be used to define several different kinds of
identifiers, DEPENDING ON HOW ITS ARGUMENTS ARE WRITTEN
* syntax for a named constant in BSL Racket:
(define DESIRED-NEW-NAME expression)
* semantics: define does not return anything!
* BUT when define is written using the above syntax,
it has the SIDE-EFFECT of making DESIRED-NEW-NAME
a simple expression whose value is the value of
the given argument expression,
and its data type is the type of its given argument
expression
* reminder: class style: use ALL-UPPERCASE for a named constant's name
(define MAX-SAFE-TEMP 80)
;-----
; now MAX-SAFE-TEMP is a simple expression of type number:
MAX-SAFE-TEMP
;-----
; ...and MAX-SAFE-TEMP can be used anywhere an expression of
; type number can be used:
(< 50 MAX-SAFE-TEMP)
=====
check-expect - for TESTING functions
=====
* BSL Racket provides several functions to allow you to
write automatic tests for your functions (or just to
check stuff)
* these functions' names start with check-
* let's start with the function check-expect
* syntax:
(check-expect desired-expr-to-test
expected-value-of-desired-expr)
semantics - rather sophisticated!
* it DOES compare the desired-expr-to-test
and expected-value-of-desired-expr to see if they are equal;
but Racket does this for ALL the check- expressions in
the .rkt file, and SUMMARIZES at the END of the Interactions
window the number passed if all passed;
and if any fail? it pops up a separate window showing which
failed, and the values that were expected and gotten,
and a link to each that failed;
=====
INTRO to DESIGN RECIPE - see today's posted Racket examples file!
=====