[alexandria-devel] Some number patches
Robert Smith
quad at symbo1ics.com
Wed Apr 25 07:07:36 UTC 2012
On Wed, Apr 25, 2012 at 12:30 AM, Tamas K Papp <tkpapp at gmail.com> wrote:
> MULF and DIVF could be useful (but note that many people spell the first
> as MULTF). However, I don't think that MUL(T)F and DIVF should take a
> default factor/divisor argument --- personally, I would find (DIVF FORM)
> somewhat confusing.
I agree with not having default arguments, now that you say it. I
think my original intention was to be more consistent with INCF and
DECF, but "inc" and "dec" both implicitly imply "increment/decrement",
which in turn imply by 1.
> I don't really see the value of aliases for PLUSP and MINUSP, and I have
> some doubts about NON-ZERO-P too.
Not unreasonable.
All of these show up in a lot of mathematical code I (and coworkers)
write. I only argue for POSITIVEP, etc., because that is an extremely
common term. If we need to make it more substantial than just aliasing
PLUSP, then we can let POSITIVEP also return T for +0.0, similarly for
NEGATIVEP and -0.0. I don't really like that, but at least it has
utility.
As for doubts about NON-ZERO-P: yes, it can of course be written (NOT
(ZEROP N)), as the definition says, but I don't think anyone has
really disagreed with the Lisp standard having CL:1+, which in many
implementations is transformed to (LAMBDA (N) (+ 1 N)).
Having its own function is also useful for functional operations, like
filtering. Real-world example: finding non-zero values in the diagonal
of one of the matrices in a singular value decomposition and finding
those indexes in the other factor lets us find the basis of the
kernel/null space of the matrix.
Quite simply, I'd say, the concept of non-zeroness as an almost atomic
notion is pervasive in especially mathematics, which Lisp happens to
be good at.
Thanks for the comments.
Robert Smith
More information about the alexandria-devel
mailing list