=====
CS 111 - Week 4 Lecture 1 - 2024-09-17
=====

=====
TODAY WE WILL:
=====
*   announcements
*   concept of REFACTORING
*   intro to BRANCHING - cond expression
*   big-bang's stop-when clause
*   [if time] modulo function
*   prep for next class

;=====
*   should be starting Homework 3;
    deadline/at least first attempts due by this Friday, Sept. 20

    *   submit early, submit often!

=====
aside: what it means to REFACTOR code
=====

*   have an error in your code?
    you fix it -- that's DEBUGGING

*   sometimes you want to extend or add to code,
    make it work on a new device or environment, etc. --
    arguably, that might be called maintenance

*   refactoring is a LITTLE different from these --
    sometimes you want to improve working code (without
    really changing what it is doing) --
    *   to be more READABLE
    *   to be more EFFICIENT
    *   to be easier to REUSE in various ways later
    *   probably etc.

*   NOTE: any time you change your code, there is a chance you
    might accidentally introduce an error --

    do you see how check-expect (and other check- expressions)
    may help make refactoring less dangerous, since these are
    re-run every time you click Run?

    so if all your tests still pass after you refactor, that
    increases your confidence that you have not introduced
    an error while refactoring; (not a guarateee, but helps!)

=====
cond (conditional) expression
=====
*   multi-way branching expression!
    ...make ONE choice from 2 or more options

*   syntax:

    (cond
        [boolean-expr1 expr1]
	[boolean-expr2 expr2]
	[boolean-expr3 expr3]
        ...
	[else expr-else]
    )

*   semantics (meaning):

    when a cond expression is reached,
        the boolean-expr1 is is evaluated -- if it is #true,
	    expr1 is the value of this cond, and its DONE

        else, boolean-expr2 is evaluated -- if IT is #true,
	    expr2 is the value of this cond, and its DONE

        else...

        if an else clause is reached, it is always considered
	    #true, and its expr-else becomes the value of this cond.

    *   NOTE:
        AT MOST one branch will be "taken" --
	as soon as one of the clauses' boolean expression is #true,
	    that clause's expr becomes the value of this cond.

        so the order of the cond clauses matters;