=====
CS 111 - Week 5 Lecture 2 - 2026-09-24
=====

=====
TODAY WE WILL:
=====
*   announcements
*   finish our ITEMIZATION-data example
*   intro our first DATA STRUCTURE
*   ...intro to LISTS
*   prep for next class

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

=====
fun fact: functions error and check-error
=====
*   error function, given a string argument error message,
    will have the SIDE-EFFECTS of causing an error to occur
    and printing the given string argument as the error message
    to the screen

*   check-error function can be used to test if an error function
    expression is working -- check-error's first argument is the
    expression to test, and its second is the string
    error message printed if that error occurs

=====
idea of a DATA STRUCTURE
=====
*   lets us collect MULTIPLE instances within a SINGLE
    collection-thing...!

*   programming languages frequently provide some "core"
    data structure data types;

    *   in Racket, arguably the most "basic" data structure data type is
        a list
    
    *   in C++, arguably the most "basic" data structure data type
        is a 1-dimensional array

*   in problem solving, if you choose an appropriate choice
    of data structure, it makes programming your solution
    a LOT easier!

    *   famous quote from Software Engineering Dr. Fred Brooks:
        (last line of Chapter 9, "The Mythical Mon-Month"):

        "Representation *is* the essence of programming."
	
=====
BSL Racket's list data type
=====
*   our first data structure! (one of MANY...)

*   built-in type, like image, number, boolean, string

*   BUT - it is easiest to describe in an itemization-style way:

;=====
; DATA DEFINITION
; an Anything is an expression of any type

;=====
; DATA DEFINITION
; a list is one of:
;    *   empty
;    *   (cons Anything list)

*   this is a SELF-REFERENTIAL data definition!!!!

    *   it DOES define a list in terms of a list...!
    
    *   BUT: it has a "base case", at least one item in the itemization
        that is NOT defined in terms of a list

        ...and if you "took apart" a list using the above definition,
	you'd eventually reach one of the "base case" items

*   see more about BSL Racket's list data type in the posted
    examples for today!
    
=====
*   CONFESSION: there IS a list shortcut operator,
    named list ---

    (list elem1 elem2 ... )

    BUT under the hood, this is implemented using
    cons!

    (equal? (list 1 "b" #true)
            (cons 1 (cons "b" (cons #true empty))))