Class 23 Objectives
At the end of today's class you should
KNOW:
- What a state variable is
- How to make Racket remember a result that changes over time
- Why set! can't be used to change the value of a function argument
- That begin can be used to run any number of Racket
expressions, but only returns the result of the last expression
- When to use begin
- That it is OK to define a function which takes no inputs
BE ABLE TO:
- Use set! to redefine a named variable
- Write programs that change the values of variables
- Document variables
- Document a function that changes the value of a variable
Sample Exam Question:
Using the data definitions for Account and ListOfAccount
and the variable Citibank
that we defined in class, write a function remove-account that consumes
an account number and removes the account with the given account number from
Citibank.
Hint:
Use remove-account to call another function, remove-from-list. remove-from-list consumes an account number and a list of accounts
and produces a list of accounts with the named account removed.