Louis Reasoner tries to evaluate the expression
is the object shown in figure 2.24. To his surprise, instead of the answer
he gets an error message from
, saying there is no method for the operation
on the types
. He shows this interaction to Alyssa P. Hacker, who says ''The problem is that the complex-number selectors were never defined for
numbers, just for
numbers. All you have to do to make this work is add the following to the
(put 'real-part '(complex) real-part) (put 'imag-part '(complex) imag-part) (put 'magnitude '(complex) magnitude) (put 'angle '(complex) angle)
Describe in detail why this works. As an example, trace through all the procedures called in evaluating the expression
is the object shown in figure 2.24. In particular, how many times is
invoked? What procedure is dispatched to in each case?
Figure 2.24: Representation of
3 + 4i
in rectangular form.
There are no comments yet.
You must log in to post a comment.Login