Subject: string comparisons, was: Maxima 5.21.1 release
From: Richard Fateman
Date: Mon, 26 Apr 2010 16:12:42 -0700
Sometimes it helps to compare to other languages, e.g. Common Lisp.
There are functions string=, string>, string>= etc.
they require that each of the arguments be strings. We can use these
functions directly
from Maxima, e.g.
?string\=("abc","def").
If you overload ">" to apply to strings, it seems to me that you should
require
that each of the arguments be a string.
Also, string>, etc. returns a number, related to the location in the
strings where the order is established.
Comparing strings with symbols (symbol names) may possibly make sense,
but comparing complex numbers
(an UNORDERED field) strikes me as (mathematically) batty, even if you
can make up something to write into
a program. There are programs that provide an order for symbolic
expressions. The underlying
lisp program can even be called as ?great(a,b) .
RJF
Robert Dodier wrote:
> On 4/26/10, Stavros Macrakis <macrakis at gmail.com> wrote:
>
>
>> As for is("x">0) giving an error, that is perfectly correct -- it is
>> meaningless to compare a string to a number.
>>
>
> Disagreed on this point -- %i and 0 are incomparable but is(%i > 0)
> => false, not an error. By analogy, seems like is("x" > 0) should
> likewise yield false.
>
>
>> But in fact Maxima's comparison functions (other than = and #) don't even
>> work on strings -- probably they should.
>>
>
> Agreed, < <= >= > should be able to compare strings.
>
> best
>
> Robert Dodier
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>