Defaults for equality operators

Started by Jeremy Dunn, December 23, 2006, 03:42:01 PM

Previous topic - Next topic

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.

Lutz

#1
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

Lutz

#2
... look for it in 9.0.12 (for numbers, strings and lists)



Lutz

Jeremy Dunn

#3
That will be great, my primary interest was in just the numerical comparison aspect anyhow.