LinuxAnswers - the LQ Linux tutorial section.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-27-2004, 05:15 PM   #1
Registered: Nov 2003
Posts: 55

Rep: Reputation: 15
Sorting a list of words in LISP!


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
Old 05-01-2004, 04:29 PM   #2
Registered: Aug 2003
Location: Planet Earth
Distribution: Linux Mint Debian Edition (LMDE)
Posts: 215

Rep: Reputation: 31
ANSI Common Lisp has a sort function and a few string comparison functions.

(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:

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Search and Replace: Asian Words to English Words ieeestd802 Linux - Software 0 10-27-2004 08:48 PM
Lisp phoenix7 Programming 4 09-24-2004 08:40 AM
Gnome panel - window list (sorting) dnar Linux - General 0 06-06-2004 11:41 PM
This might sound strange, but I need a big list of dirty words. Travis86 Programming 12 07-18-2003 12:06 AM
Lisp, emacs-lisp aizkorri Programming 1 09-04-2002 07:16 PM

All times are GMT -5. The time now is 05:36 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration