[plt-scheme] Test a numbers representation to see if it's complex?
How about this `0-imag-part?'?
(define (exact-zero? x)
(and (exact? x)
(zero? x)))
(define (0-imag-part? z)
(exact-zero? (imag-part z)))
Chongkai
Ryan Newton wrote:
> Yes, this is not normally a nice thing to do. But I have a need to
> distinguish 3.0 and 3.0+0.0i. As far as I can tell, while PLT *could*
> turn 3.0+0.0i into 3.0, but for whatever reason the complex
> representation seems closed under PLT's arithmetic, which makes what I
> want to do somewhat sane.
>
> (For reference, I'm embedding a statically typed language in Scheme,
> and I would like to sanity check the object representations
> periodically.)
>
> -Ryan