Richard Hennessy | 7 Sep 18:23
Favicon

Error comparing strings

(%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?

Rich
Richard Hennessy | 7 Sep 18:43
Favicon

Re: Error comparing strings

okay,

https://sourceforge.net/tracker/?func=detail&atid=104933&aid=2098866&group_id=4933

Rich

 ------------Original Message------------
From: "Richard Hennessy"<rvh2007 <at> comcast.net>
To: "Maxima List" <maxima <at> math.utexas.edu>
Date: Sun, Sep-7-2008 12:25 PM
Subject: Error comparing strings

(%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?

Rich
Alexey Beshenov | 7 Sep 19:07
Favicon

Re: 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)))

--

-- 
(Continue reading)

Richard Hennessy | 8 Sep 00:03
Favicon

Re: Error comparing strings

I just got this way to work but I had to change it a little.  I can't get it to work with sort though

Rich

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

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
(Continue reading)

Richard Hennessy | 8 Sep 01:43
Favicon

Re: 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
(Continue reading)

Robert Dodier | 7 Sep 20:49

Re: Error comparing strings

On Sun, Sep 7, 2008 at 10:25 AM, Richard Hennessy <rvh2007 <at> comcast.net> wrote:

> (%i1) is("John">"Barry");
> Maxima encountered a Lisp error: Error in PROGN [or a callee]:

Well, that's a bug. A work-around is to call ordergreatp or orderlessp
for which all Maxima expressions are comparable.
e.g. ordergreatp("John", "Barry") => true.

The function "sort" orders stuff according to orderlessp by default.

Should be easy to make strings comparable by < <= >=  and > .
(Already = # equal and notequal are OK.)

best

Robert Dodier
Richard Hennessy | 7 Sep 23:17
Favicon

Re: Error comparing strings

Thanks,

That does the trick.  I was sorting a list and my own function concoction workaround was a lot slower.

Rich

 ------------Original Message------------
From: "Robert Dodier" <robert.dodier <at> gmail.com>
To: "Richard Hennessy" <rvh2007 <at> comcast.net>
Cc: "Maxima List" <maxima <at> math.utexas.edu>
Date: Sun, Sep-7-2008 2:49 PM
Subject: Re: [Maxima] Error comparing strings

On Sun, Sep 7, 2008 at 10:25 AM, Richard Hennessy <rvh2007 <at> comcast.net> wrote:

> (%i1) is("John">"Barry");
> Maxima encountered a Lisp error: Error in PROGN [or a callee]:

Well, that's a bug. A work-around is to call ordergreatp or orderlessp
for which all Maxima expressions are comparable.
e.g. ordergreatp("John", "Barry") => true.

The function "sort" orders stuff according to orderlessp by default.

Should be easy to make strings comparable by < <= >=  and > .
(Already = # equal and notequal are OK.)

best

Robert Dodier
(Continue reading)


Gmane