=====
CS 111 - Week 5 Lecture 1 - 2025-09-23
=====

=====
TODAY WE WILL:
=====
*   announcements
*   intro to big-bang's on-key clause (and another example
    of enumeration data)
*   intro to itemization data
*   if time: the idea of a DATA STRUCTURE <-- did NOT get to;
*   prep for next class

=====
*   if interested: can see the set of functions setting
    up event handlers for big-bang when the world type
    is string (code is on the public site, recording on
    the Canvas site)
    *   on Canvas: go to Modules,
        see the new "CS 111 recordings" section

    *   on public site: go to in-class examples,
        go to the "POST Week 4 - Lecture 2 EXTRA example"
	section (right above the Week 4 Lab section)

=====
*   should be working on Homework 4!
    *   at-least-first attempts due by 11:59 pm Friday, Sept. 26

=====
*   another of the big-bang function's optional clauses is:
    on-key
=====
*   you can give on-key a function that specifies how big-bang's
    world should change on the event of a user typing a key
    on the keyboard

    *   on-key's function is expected to be the name of a function
        that expects TWO arguments,
	the type of the current world and a string,
	and that returns the type of the current world

    *   when a key is typed, then,
        big-bang CALLS this function with the current world value
	and a string representing the key typed,
	and the result of that function call is the NEW value
	of the world

*   see posted examples to see function change-elevation, which
    can work with a big-bang expression's on-key clause to change
    a penguin's elevation by typing up- and down-arrow keys

=====
itemizations
=====
*   HtDP/2ed section 4.5:

    "An interval distinguishes different subclasses of numbers;
     an enumeration spells out item for item the useful elements in
         an existing class of data.

     Data definitions that use ITEMIZATIONS *generalize* intervals
         and enumerations.

     They allow the COMBINATION of any existing data types (defined
         elsewhere) with each other and with individual pieces of
	 data."

*   Data definition?
    ...we've been informal about these so far;

    we could be one step more formal and say that we'll call
    a data definition a comment using this format:

    ; DATA DEFINITION
    ; a DesiredType is [and describe it]

    ...if it is for itemizations, it would take THIS form:

    ; DATA DEFINITION
    ; a DesiredType is one of:
    ;    - possibility
    ;    - possibility
    ;    ...
    
    *   OK, you only need the list part above for
        itemization data, and sometimes it is useful for enumeration data

    *   for example:

    ; DATA DEFINITION
    ; a Color is one of:
    ;   - a string whose name is a color (according to Racket)
    ;   - (make-color red-val green-val blue-val)
    ;   - (color red-val green-val blue-val transp-val)

    *   CS 111 class style:
        IF you include a data definition comment like the above,
	you can then use that informally-defined type in a
	function signature comment that follows this data definition

    *   CS 111 class style:
        Unless the data definition is for a built-in Racket data type,
	write your new defined type in CamelCase starting with
	an uppercase letter

*   for a function driven by itemization-style data, can you see that you
    might need a cond with a branch for each item in the
    itemization's data definition?

    for tests? ah, you might need more! depends on the items
    in the itemization!
    *   should have at least 1 per itemization item,
    *   BUT if that item involves interval or intervals, you might need
        more -- such as boundary tests!
    *   and if an item involves enumeration data, might need one for
        each,
    *   and if the function you are writing specifies exceptions,
        you should test for those also;

*   can see how the function equal? (discussed briefly in the Week 4 Lab)
    can be useful in a cond involving Itemization data?

    *   reminder: equal? expects two expressions of ANY type, and
        returns a boolean, returns whether they have the same value
	*   unlike =, string=?, boolean=?, image=?, it expects
	    arguments of ANY type;

    *   if an itemization type has items of different data types
        amongst its items, you can use equal? in a cond branch
	to compare to a parameter of that
	itemization type without getting a syntax error...

*   hope to do an example of a function driven by itemization-syle
    on Thursday,

    then proceed to LISTS,
    which are our first DATA STRUCTURE,
    and, while a built-in data type in BSL Racket,
         can also be said to be itemization-style with a TWIST...