Closed jpellegrini closed 10 months ago
R7RS says the signature is (abs x)
. For the number procedures, x
means a real number. z
("zahl") means any number.
Nevertheless, R7RS doesn't forbid procedures that work with more data types than is standard.
R7RS says the signature is
(abs x)
. For the number procedures,x
means a real number.z
("zahl") means any number.
I haven't paid attention to the signature... Indeed! Anyway, @egallesio, here's the PR. Any decision seems to be fine! :)
Hm, I think I hadn't had coffee when I proposed this PR. If one wants to make abs
work for complexes, it would be simpler to do something like
(define abs magnitude)
No?
I have applied your patch (and simplified the writing of magnitude, BTW)
R7RS says it "computes the absolute value of its argument", but doesn't imply it should be real... So we do compute the norm,
(abs a+bi)
$= \sqrt{a^2+b^2}
$ as usual.A very small patch... :)
Here's a list of how other lisps deal with
(abs -3-4i)
: