justinethier / cyclone

:cyclone: A brand-new compiler that allows practical application development using R7RS Scheme. We provide modern features and a stable system capable of generating fast native binaries.
http://justinethier.github.io/cyclone/
MIT License
823 stars 42 forks source link

abs of complex number #506

Closed lassik closed 1 year ago

lassik commented 1 year ago

(abs -3-4i) => 3.0

Returns abs of the real part, discards the imaginary part.

lassik commented 1 year ago

Via https://github.com/schemedoc/surveys/pull/50 cc @jpellegrini

jpellegrini commented 1 year ago

As @lassik said somewhere else, if you interpret R7RS as saying "abs" only applies to reals, it's not strictly wrong -- it would be an error, and in such situation the implementation may do anything it wants. But it would be nice to return something useful, like the complex norm! :grin:

justinethier commented 1 year ago

Thanks for the report! For now, Cyclone will return an error in this case.