Page 1 of 1

Defaults for equality operators

Posted: Sat Dec 23, 2006 11:42 pm
by Jeremy Dunn
Lutz,

I would like to suggest modifying the equality operators so that they behave differently when presented with a single number as input. Currently an expression like (< 3) always returns true. If n is an input I want to propose that the equality operators behave as follows:

(f n) is (f n 0) where f are the operators <.<=,>,>=,=,!=

This makes testing a number simple to see if it is negative, strictly positive, etc.

Posted: Sun Dec 24, 2006 2:00 pm
by Lutz
I thought it was a nice idea at first but then ran into all kinds of situations, thinking of an implementation. Remember that the comparison operators work on all datatypes and also do comparison between data types.

But I will revisit the idea at a later time.

There is also the 'sgn' function which has the added faeture that it can call other functions.

Lutz

Posted: Sun Dec 24, 2006 6:13 pm
by Lutz
... look for it in 9.0.12 (for numbers, strings and lists)

Lutz

Posted: Sun Dec 24, 2006 6:22 pm
by Jeremy Dunn
That will be great, my primary interest was in just the numerical comparison aspect anyhow.