Defaults for equality operators

For the Compleat Fan
Locked
Jeremy Dunn
Posts: 95
Joined: Wed Oct 13, 2004 8:02 pm
Location: Bellingham WA

Defaults for equality operators

Post 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.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post 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

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

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

Lutz
Last edited by Lutz on Sun Dec 24, 2006 6:35 pm, edited 1 time in total.

Jeremy Dunn
Posts: 95
Joined: Wed Oct 13, 2004 8:02 pm
Location: Bellingham WA

Post by Jeremy Dunn »

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

Locked