Post Reply 
newRPL - Updated to build 1510 [official build remains at 1487]
08-20-2023, 10:45 PM (This post was last modified: 08-20-2023 11:29 PM by Claudio L..)
Post: #302
RE: newRPL - Updated to build 1510 [official build remains at 1487]
(08-16-2023 02:21 PM)Gilles Wrote:  Hi Claudio,

There is a problem with the SORT command, both with build 1510 and 1487 :

Code:
{ "a" "c" "b" } SORT
returns an error : " Expected a real number"

and
Code:
{ { 1 "A" } { 2 "B" }} SORT
=> Crash badly

EDIT : I just saw in the newRPL WIKI that SORT only applies to numbers for now. I will add in LstX a LSORT command that sorts other types of objects , and a command inspired by KSORT for specific sorts. Could be something like :

{ "ABCD" "AAAAA" "B" "BB" } « SIZE » KSORT
=> { "B" "BB" "ABCD" "AAAAA" }

new EDIT ;D : I ve created a thread for the new and futures versions of LstX :
https://www.hpmuseum.org/forum/thread-20345.html

I've add strings manipulation commands and comparaison, and a new DOSORT command (to sort list of strings, or things like "sort this list of words by number of letters).

I took a quick look and here's what's happening:
SORT uses the overloaded operator CMP (compare) to compare individual items. For lists, this operator is not atomic, as it triggers a DOLIST comparing element-by-element as per list processing rules. There was a bug that caused a crash, since SORT was supposed to run CMP as an atomic operation, allowing DOLIST to complete. I fixed that in the source code, will come fixed in the next release.

As far as why string comparisons don't work, it's because the operations to compare strings aren't well defined for Unicode strings (what's the order of "a","á", "ä" and "b"?), so they aren't implemented in newRPL (therefore there's no CMP operator for strings, which makes SORT fail).

For lists, there's currently some missing logic as well. CMP between 2 lists will return a list with CMP applied to all elements, and SORT should probably look through the list to find the first "not equal" element to decide. I'll see if I can add the logic to make this more robust. EDIT: Just did... will come out in the next update. Still no joy with the strings.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Navigating through sub-menus - Gilles - 05-13-2023, 11:31 AM
RE: newRPL - Updated to build 1510 [official build remains at 1487] - Claudio L. - 08-20-2023 10:45 PM
It's a mystery to me... - Klaus - 11-27-2023, 12:24 PM



User(s) browsing this thread: 6 Guest(s)