Why in chicken scheme by default (i.e., without loading extensions such as the numbers egg) are defined the procedures real-part
, imag-part
, angle
, magnitude
, complex?
but there aren't make-rectangular
and make-polar
? What should I do with them, if I can't create a complex number?
In Chicken Scheme without the number egg you can create a real number.
Now the real part of a real number is a real number. This means that the result of real-part
will always be a real number.
For a real number the imaginary part is always zero. The result of imag-part
on a real number is therefore a real number.
The magnitude of any number is real, thus magnitude
always produces a real number.
This explains why real-part
, imag-part
and magnitude
are included - they are easy to implement for real inputs.
The reason make-rectangular
and make-polar
aren't supported is that they produce complex numbers. And complex numbers aren't supported (without the egg).
That is: Operations that never produces complex numbers work (when applied to real numbers). Operations that produce complex numbers are left out.