Question: How to compare symbols alphabetically in Common Lisp?

Question

How to compare symbols alphabetically in Common Lisp?

Answers 1
Added at 2016-12-26 14:12
Tags
Question

I trying to compare a symbol to another alphabetically, but I can't do this. In particular, I've done this.

CL-USER 1 > (string-lessp 'k 'a)
NIL

CL-USER 2 > (string-lessp 'a 'k)
0

Thank you guys

Answers to

How to compare symbols alphabetically in Common Lisp?

nr: #1 dodano: 2016-12-26 14:12

In Common Lisp, NIL is false, and anything else is true. So in your transcript, 0 is a true value, indicating that A is before K. Rather than simply returning T and NIL, STRING-LESSP returns a mismatch index:

The inequality functions return a mismatch-index that is true if the strings are not equal, or false otherwise. When the mismatch-index is true, it is an integer representing the first character position at which the two substrings differ, as an offset from the beginning of string1.

0 is the index of the first character where the designated strings don't agree.

Source Show
◀ Wstecz