灯下 登录
计算机科学 / SICP / 2.5.2 Combining Data of Different Types

Exercise 2.86 · 习题

Exercise 2.86: Suppose we want to handle complex

numbers whose real parts, imaginary parts, magnitudes, and angles can be either

ordinary numbers, rational numbers, or other numbers we might wish to add to

the system. Describe and implement the changes to the system needed to

accommodate this. You will have to define operations such as sine and

cosine that are generic over ordinary numbers and rational numbers.

练习 2.86:假设我们希望处理这样的复数:其实部、虚部、模和辐角可以是普通数、有理数,或者我们将来可能加入系统的其他类型的数。请描述并实现系统所需的修改以支持这一需求。你需要定义一些操作,如 sine 和 cosine,使其对普通数和有理数都是通用的。