Sorting strings fails

33 views
Skip to first unread message

Руслан Сорокин

unread,
Jul 2, 2023, 5:12:54 AM7/2/23
to CLIPSESG
Dear CLIPS users and team!

I try to sort strings using a function sort, but encountered with the problems:
...
CLIPS>
(sort string> "B" "A" "D" "C")
[ARGACCES2] Function 'sort' expected argument #1 to be of type function name, deffunction name, or defgeneric name.
FALSE
CLIPS>
(sort str-compare "B" "A" "D" "C")
("C" "D" "A" "B")
CLIPS> (sort string> ax aa bk mn ft m)
[ARGACCES2] Function 'sort' expected argument #1 to be of type function name, deffunction name, or defgeneric name.
FALSE
...
Last example literally from the 12.7.8 Sorting a List of Values paragraph of The Basic Programmer Guide.

Thanks in advance for the any help.

Sincerely,
  Ru

CLIPS Support

unread,
Jul 2, 2023, 12:29:49 PM7/2/23
to CLIPSESG
In the example, the string> deffunction is defined before being referenced by the sort function with the symbol string> as the first argument. If you leave that step out, you'll get an error. You didn't need to do that for the first example of calling sort because the > function is a predefined function in CLIPS.

CLIPS> (sort > 4 3 5 7 2 7)
(2 3 4 5 7 7)
CLIPS> 
(deffunction string> (?a ?b) 
   (> (str-compare ?a ?b) 0)) 
CLIPS> (sort string> ax aa bk mn ft m) 
(aa ax bk ft m mn) 
CLIPS> 

Руслан Сорокин

unread,
Jul 3, 2023, 3:08:35 AM7/3/23
to CLIPSESG
Thank you. Sorry. This is again my inattention :(

воскресенье, 2 июля 2023 г. в 19:29:49 UTC+3, CLIPS Support:
Reply all
Reply to author
Forward
0 new messages