LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Sorting a list of words in LISP! (https://www.linuxquestions.org/questions/programming-9/sorting-a-list-of-words-in-lisp-175255/)

Hady 04-27-2004 04:15 PM

Sorting a list of words in LISP!
 
hi!

how can i sort a list of WORDS in LISP?

(is there any function in LISP that is equivalent to C++'s strcmp?)
(can i get the ASCII code of a character in LISP?)

thank you

eric.r.turner 05-01-2004 03:29 PM

ANSI Common Lisp has a sort function and a few string comparison functions.

Code:

(sort sequence predicate &key key)
(string< string1 string2 &key start1 end1 start2 end2)
(string> string1 string2 &key start1 end1 start2 end2)
(string-greaterp string1 string2 &key start1 end1 start2 end2)
(string-lessp string1 string2 &key start1 end1 start2 end2)

To sort a list of strings in ascending order try this:

Code:

(sort '("foo" "baz" "bar") #'string-lessp)


All times are GMT -5. The time now is 06:16 PM.