a simple problem
problem
- write a procedure exp such that (exp x k) evaluates to x to the power k
- exp should be tail-recursive
solution
- code
(define (exp x k)
(define (helper x k s)(if (= k 0) s
(helper x (- k 1) (* x s))))
(helper x k 1))
- note
helper is defined locally within exp
helper is unbound at the top level
question
- what does (helper x k s) compute? s.xk
- can argue inductively that helper works, then use this result to argue that exp works