Comparison of compound objects



On 12/27/06, Stavros Macrakis <macrakis at alum.mit.edu> wrote:

> Currently, Maxima cannot compare strings or lists using is(x<y):
>
>         is(    "a"<"b"  )    => unable to evaluate predicate
>         is(  [1] < [2]   )    => unable to evaluate predicate
>         is( [1] < [1,.2] )   => arguments with incompatible structure
>                 (even an error with prederror:false )
>
> I think it would be useful to extend "<" to these cases in the natural
> way, using lexicographic ordering for lists/vectors.

Some people might expect < to map over lists.
If is(a < b) is OK for lists, what about matrices or other objects?
Defining is(a < b) for lists seems inconsistent with the treatment of
other expressions -- is(list(...) < list(...)) would be OK but not
is(foo(...) < foo(...)) for some random operator foo, and when foo is
an arithmetic operator, is(foo(...) < foo(...)) would be defined, but
not consistent with lexicographic ordering for lists.

I guess I'm not comfortable with extending is(a < b) to lists.

But certainly is(a < b) can be usefully defined as orderlessp(a, b)
when a and b are strings.

> 1) Vector norm might be a more natural mathematical comparison.

Well, vector norm only establishes equivalence classes,
and I don't like the general conflation of vectors and lists anyway.

> 2) It might cause some programming errors to not be caught.

That doesn't bother me.

Thanks for thinking about this problem,

Robert