Problem 8.3: Make Exp (optional, 0 pts)
Implement a data abstraction for exponentiation: a base
raised to the power of an exponent
. The base
can be any expression, but assume that the exponent
is a non-negative integer. You can simplify the cases when exponent
is 0
or 1
, or when base
is a number, by returning numbers from the constructor make-exp
. In other cases, you can represent the exp as a triple (^ base exponent)
.
You may want to use the procedure
pow
implemented in problem 1 or the built-in procedureexpt
, which takes two number arguments and raises the first to the power of the second.
; Exponentiations are represented as lists that start with ^.
(define (make-exp base exponent)
'YOUR-CODE-HERE
)
(define (exp? exp)
'YOUR-CODE-HERE
)
(define x^2 (make-exp 'x 2))
(define x^3 (make-exp 'x 3))