Programming is The How of Functions.
There are lots of examples of functions:

So functions aren't always about numbers. That said, today we'll only use functions on numbers. (We'll start enriching our world starting next time.)

You have been programming and computing for a long time, in elementary school and junior high. In this class, we'll spend ten weeks just exploring implications of pre-algebra.

expression (arithmetic)expression (scheme)value
2 + 2 (+ 2 2) 4
7 / 3 (/ 7 3) 2 1/3
3 * (((4 * 5))) (* 3 (* 4 5)) 60
3 + (4 * 5) (+ 3 (* 4 5)) 23
(3 + 4) * 5 (* (+ 3 4) 5) 35
  ___
-/16
(sqrt 16) 4
  ______________
-/ 7*7 + 24*24
(sqrt (+ (* 7 7) (* 24 24))) 25
         _____________
 -5 +  -/ 5*5 - 4*1*7
----------------------
       2*1
???
let owes(p) = 12*(p/8)
(define (owes p)
  (* 12 (/ p 8)))
n/a
let dough-area(r) = pi*r^2
(define (dough-area r)
  (* pi (* r r)))
n/a
let pizza-topping-area(d) = dough-area(d/2 - 1)
(define (pizza-topping-area d)
  (dough-area (- (/ d 2) 1)))
n/a

The pizza industry is a tough biz; it's hard to stand out from the competition. [Not actually true in houston, but we'll ignore that.] What if we want to switch to hexagonal pizzas? What code needs to be changed? Well, certainly we change dough-area, to reflect the formula for area of a hexagon ("radius" now means to dist-from-center-to-middle-of-side). But what about pizza-topping-area? No change needed! (Imagine that we'd used the weird pi/4*d^2... version -- we'd be wading through a long list of various pizza functions, and trying to figure out which were dependent on being a circle.) Thus, by re-using dough-area, we don't have to re-write other functions!

The Second Law of Programming: Re-use existing code.
We call this a "single point of control". Other uses of this (very general management) principle:

If you ever find yourself writing the same code to do the same thing (in this case, squaring a radius and multiplying by pi), you should stop and think about how to re-use the common code.

To do before next lecture:
Start up DrScheme, and double-check your expression for

         _____________
 -5 +  -/ 5*5 - 4*1*7
----------------------
       2*1
(/ (+ -5 (sqrt (- (* 5 5) (* 4 1 7)))) (* 2 1))

Summary:
End responsibilities/rights For next lecture: - stress that xxx(d-1), means call the function xxx and pass in d-1. - hand-eval of a function. Show stepper. Note to 210 prof: An update in the semester's notes, hw, exams, and homework-guides: rename "hand-evaluation" to "full hand-evaluation", and "limited hand-evaluation" to "hand-evaluation".