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?

- 539
- 3
- 9
-
Chickens manual states that it doesn't support complex numbers in core. Those procedures you mention return the correct values when used on any number lower in the tower (they only have a real part). Why they are defined in core maybe only a developer can answer. And what you should do with them? Only you can answer. Maybe you will have better luck asking this on their mailing list or IRC channel (#chicken) – Rptx Aug 10 '15 at 22:39
-
See below for the answer. Note that CHICKEN 5 will have built-in support for the full numeric tower, so if you're patient it will become available by itself :) – sjamaan Aug 11 '15 at 10:38
1 Answers
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.

- 30,661
- 4
- 57
- 106