defining and applying procedures
example
- (define (square i) (* i i))
- (define (sum-of-squares i j) (+ (square i) (square j)))
- (sum-of-squares 3 4) –> 25
terminology
- in the definition (define (square i) (* i i))
i is the formal parameter
(* i i) is the body
- in the application (square i)
how are procedures applied?
- to apply a compound procedure to its arguments,evaluate the body with each formal parameterreplaced by the corresponding argument
this is the substitution model
- called a model because it isn’t exactly right
- but it’s still very useful