Error comparing strings



I got it to work with sort using this form

(defun $strless(a b)
     (cond
         ((string< a b) t)
         (t nil)))



It's a little faster than orderlessp too.

Thanks,

Rich

 ------------Original Message------------
From: Alexey Beshenov <al at beshenov.ru>
To: maxima at math.utexas.edu
Date: Sun, Sep-7-2008 1:07 PM
Subject: Re: [Maxima] Error comparing strings

On Sunday 07 September 2008 20:25:31 Richard Hennessy wrote:
> (%i1) is("John">"Barry");
> Maxima encountered a Lisp error: Error in PROGN [or a callee]:
> Caught fatal error [memory may be damaged]
> Automatically continuing.
> To reenable the Lisp debugger set *debugger-hook* to nil.
>
> (%i2) build_info()$
> Maxima version: 5.16.3
> Maxima build date: 22:48 8/24/2008
> host type: i686-pc-mingw32lisp-implementation-type: GNU Common Lisp
> (GCL) lisp-implementation-version: GCL 2.6.8
>
> Is this a bug or is it illegal to try to compare strings this way?

I think that

  is ("a" < "b")  =>  unknown

is intended. Of course, not a "fatal error".

Try something like

  (defun $strcmp (a b)
      (cond
          ((string< a b) -1)
          ((string= a b) 0)
          (t 1)))

-- 
Setting Orange, Bureaucracy 31, 3174 YOLD
Alexey Beshenov http://beshenov.ru/
_______________________________________________
Maxima mailing list
Maxima at math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima