Details for Wednesday Morning
Morning Lecture
An LON is empty or (cons NUMBER LON). What's unusual about such a definition?
Think of a LON as an inventory price list.
Examples of LONs.
Let's apply our question-and-answer game to get as far as possible.
Two functions:
;; sum : LON -> num
;; how-many : LON -> num
The DESIGN RECIPE FOR REC DATA: _self-references_ in data definitions
imply similar self-references in program definitions
Slogan: "recursion in programs for recursion in data"
---------------------------------------------------------------------------------
An LOS is empty or (cons SYMBOL LOS).
;; contains-a : LOS -> bool
---------------------------------------------------------------------------------
What other example of recursive data do we know (since the age of 5)?
A -natural number is either or (+ n 1)
Examples.
A natural number is either 0 or (add1 0).
A function:
;; factorial : NatNum -> Num
;; triangle : NatNum -> Num
;; hellos : NatNum -> LOS
Morning Lab:
RECAP:
DESIGN RECIPE: list of symbols; member-mary : LOS -> bool
when we design a function, ask - which design recipe
when we design an expression, ask - re-use of function
ASSIGNMENTS:
- 9.7; 9.8; 9.10
Yet another example: LON; eliminate0 : LON -> LON
- 11.3; 11.5
Suggest "Read 10 over a beer tonight"